pyramidal tiff issues
From my understanding, the following code should create a pyramidal tiff that goes from the lowest resolution (highest level) to the highest resolution (lowest level). So in other words if it is possible to see a svs file in a magnification of 0X to 20X, the magnification of the tiff files should be seen in that range?:
import pyvips
image = pyvips.Image.new_from_file("file.svs",level=3)
image.write_to_file("file.tif", pyramid=True, tile=True, compression="jpeg")
But when I do this it does not go until 20X. Is there something I am missing or not understanding?
Hi @Toby132,
libvips works in pixels rather than resolution, and pyramid layers are in order from largest (most pixels) to smallest (fewest pixels).
You can test this at the command line:
$ vipsheader CMU-2.svs
CMU-2.svs: 78000x30462 uchar, 4 bands, srgb, openslideload
So level 0 of the SVS file is 78000 x 30462 pixels, and that's the one that corresponds to 20x (at least in this case).
Level 3 is many fewer pixels:
$ vipsheader CMU-2.svs[level=3]
CMU-2.svs: 2437x951 uchar, 4 bands, srgb, openslideload
This is zoomed out compared to level 0 by a factor of about 32.
I think you've selected the 32x level and made a pyramid of that, so you'll only get the very zoomed out views. Try removing the level=3 from your new_from_file and you should get all the pyramid layers.
Thank you for the quick response, but what I was trying to do is open it at the lowest amount of pixels and then be able to zoom into the higher amount of pixels. Doing it this way only gives me the very zoomed-in views.
Image pyramids always have the level with the highest number of pixels first. Perhaps this is an issue with your image viewer? What are you using to view these things?
I am using aperio imagescope to view the pyramidal tiff images
@jcupitt But I do not believe it would be the imaging software since the pyramids made from the lower amount of pixels do not have this problem
moved to the new issue, sorry :)
I'm sorry you're having problems @Aiosa, but could you open a new issue, please?
It's best to have one issue per question, or it becomes very hard for other people to search for answers.
@Toby132, sorry, I still don't really understand your problem.
If you set level, you will not get all the pixels. I would just remove that, eg.:
import pyvips
image = pyvips.Image.new_from_file("file.svs")
image.write_to_file("file.tif", pyramid=True, tile=True, compression="jpeg")
If you set level, you are asking pyvips to throw away pixels.