We're Hiring!

Write Bioformat images into JPG/PNG files

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Write Bioformat images into JPG/PNG files

Postby n_biocoder » Wed Mar 31, 2010 7:09 am

Initially i had some issues writing some of the formats that used 16 bits per pixel (like ABD TIFF) into jpg files (i think jpg supports only 8 bits per pixel). Issue being the jpg files would just be empty. So i started writing 8 bits per pixel files into jpg and 16 bits per pixel into png. This method worked for most formats except a few.

In case of Zeiss LSM,
Code: Select all
formatReader.getBitsPerPixel()
returns 8 bits however the openImage function from BufferedImageReader returns a BufferedImage object that uses 16 bits per pixel ( check this using
Code: Select all
bufferedImageObject.getColorModel().getPixelSize()
). Also, the Openlab LIFF doesn't seem to be written to jpg or png files correctly.

I use ImageIO.write to write the BufferedImage onto disk after i get the the BufferedImage from the openImage function. Has anyone come across these issues? Also, is there some more accurate way to decide which format (jpg, png or bmp) would be most suited to write a IFormatReader file into.
n_biocoder
 
Posts: 4
Joined: Tue Mar 30, 2010 5:49 pm

Re: Write Bioformat images into JPG/PNG files

Postby cxallan » Wed Mar 31, 2010 7:22 am

Is there a particular reason you want to get data into a lossy format? Just compression? I would think that using PNG for all formats across the board would be your best bet. We'll look into the issue with OpenLab LIFF. This format is notoriously metadata poor however so there may not be much we can do.
cxallan
Site Admin
 
Posts: 509
Joined: Fri May 01, 2009 8:07 am

Re: Write Bioformat images into JPG/PNG files

Postby n_biocoder » Wed Mar 31, 2010 8:33 pm

1. If we were to serve these images via a browser (or to a remote client), we're probably better off getting the most ideal compression. 2. Also, being sure that they are written correctly would also be helpful.

When i wrote whatever sample data i had into PNG files (by default) the openLAB file got written fine however i was having issues writing the LSM format into PNG. The LSM format got written as TIFF correctly. Thus, having a way to find out which formats could this image be written into could be helpful.

Thank you the prompt reply.
n_biocoder
 
Posts: 4
Joined: Tue Mar 30, 2010 5:49 pm

Re: Write Bioformat images into JPG/PNG files

Postby mlinkert » Mon Apr 05, 2010 9:41 pm

When i wrote whatever sample data i had into PNG files (by default) the openLAB file got written fine however i was having issues writing the LSM format into PNG.


What sorts of problems were you having when converting LSM files? Do you see an error message, or is the converted file incorrect?

Thus, having a way to find out which formats could this image be written into could be helpful.


OME-TIFF and regular TIFF are generally the best formats to use, as they support the widest range of pixel types and preserve the most metadata. Several compression types are supported; you can see which ones are available as follows:

Code: Select all
IFormatWriter writer = new TiffWriter();
String[] compressionTypes = writer.getCompressionTypes();


To set which compression type is used:

Code: Select all
// compressionType is a String, and must be an element of the 'compressionTypes' array above
writer.setCompressionType(compressionType);


If you would prefer not to use TIFFs, and do not need to preserve any metadata, then JPEG-2000 and PNG are reasonable choices. Both formats should handle 8 and 16 bit data, but note that JPEG-2000 files will use lossy compression. You can see exactly which bit depths are supported by a particular format using the 'int[] getPixelTypes()' method in IFormatWriter.

Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest