Tiled Planer RGB. #2052
Replies: 5 comments
-
Hi again, OME TIFFs load as very tall, thin mono images, with #!/usr/bin/python3
import sys
import pyvips
im = pyvips.Image.new_from_file(sys.argv[1])
# OME TIFFs load with bands in pages
ome_height = im.get("page-height")
# crop out a set of pages
pages = [im.crop(0, y, im.width, ome_height)
for y in range(0, im.height, ome_height)]
# interleave to make a regular image
im = pages[0].bandjoin(pages[1:])
# tag as srg b ready for save to jpg or whatever
im = im.copy(interpretation='srgb')
im.write_to_file(sys.argv[2]) |
Beta Was this translation helpful? Give feedback.
-
Thanks again for your prompt and helpful fresponse.
It is common in OME-TIFF for the size of the images in the file to be different as multiple tissues samples may be in the same file and the microscope will crop them differently. It was not clear to me what happens in this case with respect to the image width and heightt with multi page read. Does VIPS end up padding these so that they all have the same width and height, or will it internally track the actual size so that when I crop based on OME-height the right thing happens.
I have tried using the page option to pull out subsets of the file and this has the undesirable effect of dropping all of the additional TIFF metadata in anything other than the first pages, which is kind of what you would expect.
Thanks again,
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
Dean’s Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute Viterbi School of Engineering Professor,
Preventive Medicine Keck School of Medicine
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: carl@isi.edu
Web: http://www.isi.edu/~carl
On Aug 31, 2020, 7:14 PM -0700, John Cupitt <notifications@github.com>, wrote:
Hi again, OME TIFFs load as very tall, thin mono images, with page-height set to the vertical height of each page. You need to crop into a set of pages, then use bandjoin to interleave them.
#!/usr/bin/python3
import sys
import pyvips
im = pyvips.Image.new_from_file(sys.argv[1])
# OME TIFFs load with bands in pages
ome_height = im.get("page-height")
# crop out a set of pages
pages = [im.crop(0, y, im.width, ome_height)
for y in range(0, im.height, ome_height)]
# interleave to make a regular image
im = pages[0].bandjoin(pages[1:]).copy(interpretation='srgb')
# tag as srg b ready for save to jpg or whatever
im = im.copy(interpretation='srgb')
im.write_to_file(sys.argv[2])
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1800 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA3OGXQGXUQTNVWERINF3FDSDRKIFANCNFSM4QQ7CWUQ>.
|
Beta Was this translation helpful? Give feedback.
-
Ah ha… that explains why I have n-pages set, but not page-height!
So it would seem one path would be to read in the file one image stack at a time using page and N (assuming I know the offset and number of image planes), so the width and height are all the same, copy forward the TIFF specific metadata from page 0, and then I can crop the toilet paper roll into the separate pages.
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
Dean’s Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute Viterbi School of Engineering Professor,
Preventive Medicine Keck School of Medicine
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: carl@isi.edu
Web: http://www.isi.edu/~carl
On Sep 1, 2020, 8:20 AM -0700, Carl Kesselman <carl@isi.edu>, wrote:
Thanks again for your prompt and helpful fresponse.
It is common in OME-TIFF for the size of the images in the file to be different as multiple tissues samples may be in the same file and the microscope will crop them differently. It was not clear to me what happens in this case with respect to the image width and heightt with multi page read. Does VIPS end up padding these so that they all have the same width and height, or will it internally track the actual size so that when I crop based on OME-height the right thing happens.
I have tried using the page option to pull out subsets of the file and this has the undesirable effect of dropping all of the additional TIFF metadata in anything other than the first pages, which is kind of what you would expect.
Thanks again,
Carl
----------------------------------------------------------
Dr. Carl Kesselman
Dean’s Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute Viterbi School of Engineering Professor,
Preventive Medicine Keck School of Medicine
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: carl@isi.edu
Web: http://www.isi.edu/~carl
On Aug 31, 2020, 7:14 PM -0700, John Cupitt <notifications@github.com>, wrote:
Hi again, OME TIFFs load as very tall, thin mono images, with page-height set to the vertical height of each page. You need to crop into a set of pages, then use bandjoin to interleave them.
#!/usr/bin/python3
import sys
import pyvips
im = pyvips.Image.new_from_file(sys.argv[1])
# OME TIFFs load with bands in pages
ome_height = im.get("page-height")
# crop out a set of pages
pages = [im.crop(0, y, im.width, ome_height)
for y in range(0, im.height, ome_height)]
# interleave to make a regular image
im = pages[0].bandjoin(pages[1:]).copy(interpretation='srgb')
# tag as srg b ready for save to jpg or whatever
im = im.copy(interpretation='srgb')
im.write_to_file(sys.argv[2])
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1800 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA3OGXQGXUQTNVWERINF3FDSDRKIFANCNFSM4QQ7CWUQ>.
|
Beta Was this translation helpful? Give feedback.
-
Yes, libvips can only read many-page TIFFs where every page is the same size. Usually OME has same size pages together, so you'll need to read each 'volume' (or modality?) out separately. It always takes the metadata from the first page (I think?), so you might need to fetch metadata for other pages. That example ^^ can be run with eg.:
I should have said. |
Beta Was this translation helpful? Give feedback.
-
Right….
So just for point of information, if the OME is generated from a vendor format file, like CZI, it will have multiple series in it, where a series is XYZCT (multi channel, multi timepoints) and each series can have a different XY value. I will explore pulling out separately as you propose and see how that goes.
Thanks,
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
Dean’s Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute Viterbi School of Engineering Professor,
Preventive Medicine Keck School of Medicine
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: carl@isi.edu
Web: http://www.isi.edu/~carl
On Sep 1, 2020, 10:03 AM -0700, John Cupitt <notifications@github.com>, wrote:
Yes, libvips can only read many-page TIFFs where every page is the same size. Usually OME has same size pages together, so you'll need to read each 'volume' (or modality?) out separately.
It always takes the metadata from the first page (I think?), so you might need to fetch metadata for other pages.
That example ^^ can be run with eg.:
$ ./ome2inter.py multi-channel-z-series.ome.tif[n=3,page=1] x.jpg
I should have said.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1800 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AA3OGXVWZ4OAGJTDI7NEEPTSDUSPFANCNFSM4QQ7CWUQ>.
|
Beta Was this translation helpful? Give feedback.
-
I'm trying to use VIPS to do some processing of OME TIFF images. The OME tooling seems to generate tiled images in a planer configuration. I've tried various paths to attempt to convert these to interleaved, so that VIPS can output a tiff, but so far have not been successful. use of the bandjoin to combine doesn't seem to do anything and colorspace conversion doesn't seem to work either.
Is there a path by which I can convert the planer tiled RGB into a format that tiffsave will not choke?
Thanks,
Carl
Beta Was this translation helpful? Give feedback.
All reactions