openslide_get_best_level_for_downsample and numeric stability

Derek Magee D.R.Magee at leeds.ac.uk
Tue Dec 13 08:52:47 EST 2016


Hi Jan,

I'm suspecting you have Aperio images (and their quirky not quite integer downsamples). Personally I don't use openslide_get_best_level_for_downsample, manually getting the levels with openslide_get_level_count<http://openslide.org/api/openslide_8h.html#a19eedd09aef2bd65db7e3b0a44e54738> / openslide_get_level_downsample<http://openslide.org/api/openslide_8h.html#a60daced5880dc3e4cf428dd81ba67bee> and finding the closest level (or best level for a particular purpose). Why do I do this when openslide_get_best_level_for_downsample exists?.. I actually have no idea. I'm guessing at some point in the past I had exactly the issue you have and this was a workaround that worked. openslide_get_best_level_for_downsample definitely rounds down, which is kind of sensible in many use cases ..  asking for 4 and getting  4.0001 is actually lower resolution than you  wanted .. where do you draw the line? 4.1? 5?

D.

From: openslide-users [mailto:openslide-users-bounces+d.r.magee=leeds.ac.uk at lists.andrew.cmu.edu] On Behalf Of Jan Hudecek via openslide-users
Sent: 13 December 2016 12:40
To: openslide-users at lists.andrew.cmu.edu
Subject: openslide_get_best_level_for_downsample and numeric stability

Hi,

I've noticed openslide_get_best_level_for_downsample doesn't always return the best level. I have an image with 4 levels:

{w:85655 h:42392}
{w:21413 h:10598}
{w:5353 h:2649}
{w:2676 h:1324}

So openslide_get_level_downsample for second level returns downsample value 4.0000700509036573.

When I call openslide_get_best_level_for_downsample(handle, 4) it returns 0. When I call it with 4.001 it returns 1 as expected.
I'm not sure what's best solution. Should get_best_level_for_downsample also "look" upwards - ie. if there is a level with a slightly larger downsample use it? Or should I just add epsilon (how big?) to the downsample before calling it myself?
I would like to avoid scaling the image 4x as it is a performance hit and completely unnecessary.

Regards,
Jan Hudecek

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20161213/26b2a7dc/attachment-0001.html>


More information about the openslide-users mailing list