Booritas / slideio

BSD 3-Clause "New" or "Revised" License
49 stars 2 forks source link

Problems for reading images over 100 000 size svs #3

Closed mmlyj closed 2 years ago

mmlyj commented 2 years ago

dear author, this package is the fastest one i met in reading big images, thanks for your work.when i was dealing big svs, i found it seems doesn't support images which's size over 100 000, and i also didn't get a way to read low resolution in a multiresolution svs images, could you give me some advice for these problems,thanks very much

Booritas commented 2 years ago

Dear mmlyj, slideio library allows reading images from the any available resolution level. It heavily uses internal zoom/resolution pyramids. To read a region or the whole image on any resolution you should specify the size of the scaled image and the library will scale it for you. For example, block below reads a rectangle with size 300 000x300 000 pixels and returns downsampled image with size 500x500. The library will use the best suitable resolution level in zoom/resolution pyramid.

import slideio
slide = slideio.open_slide("/data/test.svs", "SVS")
scene = slide.get_scene(0)
image = scene.read_block((0,0,300000,300000), (500,500))

Note, you don't have to specify the rectangle region if you want to read the whole image. Just size of the downscaled image:

import slideio
slide = slideio.open_slide("/data/test.svs", "SVS")
scene = slide.get_scene(0)
image = scene.read_block(size=(500,0))

In the snipped above, we defined only the width of the downsampled image. The height will be calculated automaticaly to minimize image distortion.

mmlyj commented 2 years ago

thanks for your quick replies. i understood how slideio reading from your replies. i tried more svs files in these days, and i found it is not the size of images causing failed reading, for some svs files , core segment faults was reported. image

the svs file is here.https://drive.google.com/file/d/1oR2PnX7nF5b0rg5zJJPEJlBx3CoDN2h1/view?usp=sharing

Booritas commented 2 years ago

Thanks a lot for the file. I will test it and fix the problem ASAP. Best regards, Stanislav

On 2. Mar 2022, at 04:41, mmlyj @.***> wrote:

dear author, this package is the fastest one i met in reading big images, thanks for your work.when i was dealing big svs, i found it seems doesn't support images which's size over 100 000, and i also didn't get a way to read low resolution in a multiresolution svs images, could you give me some advice for these problems,thanks very much

— Reply to this email directly, view it on GitHub https://github.com/Booritas/slideio/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKRZCT2YASAV25SSSWOSBDU53PPHANCNFSM5PWB2YJA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.

Booritas commented 2 years ago

I can confirm the issue. There is a bug in the library that prevents reading of images with CIE Lab color-space. Fortunately, there is a workaround for the problem. You have to specify image channels manually. Here is a code snippet:

import slideio
slide = slideio.open_slide("/data/S1303802-11-HE-DX1.svs", "SVS")
scene = slide.get_scene(0)
image = scene.read_block((0,0,1000,1000), channel_indices=[0,1,2])

This should work for any 3-channel image (like the brightfiled image you submitted). If you have more channels in the image, just extend the index array ([0,1,2,3] for 4 channel images). I hope this helps. I will fix the issue and make a new version available soon. Thanks a lot for the image sample, it helped to locate the issue. Please consider adding a star to the git repository. Best regards, Stanislav

mmlyj commented 2 years ago

thank you very much