Python open jp2 medical images - Scipy, glymur

痴心易碎 提交于 2019-12-05 03:03:11

The standard thing for reading huge medical images is openslide, I'd try that first. I'm not sure it will read jp2 directly, but assuming this is from a slide scanner, perhaps you could save in one of the formats that openslide supports?

ImageMagick will load sections of large jp2 images via OpenJPEG, though it's not especially quick. I have a 10k x 10k jp2 image here, for example, and if I convert to JPG I see:

$ time convert sekscir25.jp2 x.jpg
real    0m25.378s
user    0m24.832s
sys 0m0.544s

If I try to crop out a small piece, it's hardly any quicker, suggesting that IM always decodes the entire image:

$ time convert sekscir25.jp2 -crop 100x100+0+0 x.png
real    0m19.887s
user    0m19.380s
sys 0m0.504s

But if I do the crop during load, it does speed up:

$ time convert sekscir25.jp2[100x100+0+0] x.png
real    0m7.026s
user    0m6.748s
sys 0m0.276s

Not great, but it might work if you're patient.

I'm facing the same problems at them moment using files from a slide scanner. What I found useful was tiling the image using vips and openslide with the following command:

vips dzsave image.mrxs targetdirectoryname --depth one --tile-size 2048 --overlap 0

This will output tiles of level 0 (full resolution) of the source image with tile-size of your choosing and pixeloverlap of 0 to the tartget directory.

Hope this is of any help. Mario

are you try it using openslide.

import openslide
from openslide.deepzoom import DeepZoomGenerator
osr=openslide.OpenSlide('JP2.svs')
im=osr.get_thumbnail((200,200))
im.save('test.jpg')

You can use glymur module in python to easily access each tile of the full resolution image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!