We're Hiring!

Ome.tiff file - can't display with colors

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Ome.tiff file - can't display with colors

Postby Charavay » Mon Jun 29, 2015 10:42 am

Hi,

I try to display the different channels contained in an ome.tiff file in a java application with bio-formats.

This file contains 4 channels. When I open it under ImageJ, the image is colorized ; idem if I split the image according to the different channels (see : ftp://ftp.cea.fr/incoming/y2k01/Bio-Formats).

But with my java application, these images are not colorized. Here is my code :
Code: Select all
            BufferedImageReader bufferedImageReader = new BufferedImageReader(new ImageReader());
            BufferedImage bufferedImage = null;
            try {
                bufferedImageReader.setId(imagePath);
                // imageCount (number of images) = effectiveSizeC x sizeT x sizeZ
                int numberOfChannelsPerImage = bufferedImageReader.getEffectiveSizeC();
                if (numberOfChannelsPerImage > 1) {
                    for (int channelNumber = 0; channelNumber < numberOfChannelsPerImage; channelNumber++) {
                        // Index of the image corresponding to z = 0, t = 0 and c = channelNumber
                        int indexImage = bufferedImageReader.getIndex(0, channelNumber, 0);
                        // OpenImage(0) <=> open the image corresponding to the first channel, the first z and the first t
                        bufferedImage = bufferedImageReader.openImage(indexImage);
                    }
                } else {
                    bufferedImage = bufferedImageReader.openImage(0);
                }
            } catch (FormatException ex) {
                // Can not read the image
                bufferedImage = null;
            } catch (IOException ex) {
                // Can not read the image
                bufferedImage = null;
            }


Does someone has an idea ?

Thank you in advance for your help

Céline
Charavay
 
Posts: 14
Joined: Fri Jun 19, 2015 1:49 pm

Re: Ome.tiff file - can't display with colors

Postby rleigh » Tue Jun 30, 2015 10:46 am

Looking at these images, they have RGB PhotometricInterpretation and 4 channels (RGB with 1 associated alpha channel):

Code: Select all
% tiffinfo Image.tiff                                   
TIFF Directory at offset 0x26e8b4 (2549940)
  Image Width: 1402 Image Length: 1102
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Extra Samples: 1<assoc-alpha>
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 23
  Planar Configuration: single image plane
  ICC Profile: <present>, 3144 bytes
  Predictor: horizontal differencing 2 (0x2)
% tiffinfo SplitChannels.tiff                           
TIFF Directory at offset 0x1929b8 (1649080)
  Image Width: 1763 Image Length: 1266
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Extra Samples: 1<assoc-alpha>
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4
  Rows/Strip: 18
  Planar Configuration: single image plane
  ICC Profile: <present>, 3144 bytes
  Predictor: horizontal differencing 2 (0x2)


Code: Select all
% ~/code/bioformats-test/tools/showinf -nopix Image.tiff       
Checking file format [Tagged Image File Format]
Initializing reader
TiffDelegateReader initializing Image.tiff
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
Initialization took 0.077s

Reading core metadata
filename = Image.tiff
Series count = 1
Series #0 :
        Image count = 1
        RGB = true (4)
        Interleaved = false
        Indexed = false (false color)
        Width = 1402
        Height = 1102
        SizeZ = 1
        SizeT = 1
        SizeC = 4 (effectively 1)
        Thumbnail size = 128 x 100
        Endianness = motorola (big)
        Dimension order = XYCZT (certain)
        Pixel type = uint8
        Valid bits per pixel = 8
        Metadata complete = true
        Thumbnail series = false
        -----
        Plane #0 <=> Z 0, C 0, T 0


Reading global metadata
BitsPerSample: 8
Compression: LZW
ExtraSamples: 1
ImageLength: 1102
ImageWidth: 1402
MetaDataPhotometricInterpretation: RGB
MetaMorph: no
NumberOfChannels: 4
Orientation: 1st row - top; 1st column - left
PhotometricInterpretation: RGB
PlanarConfiguration: Chunky
Predictor: Horizontal differencing
SampleFormat: unsigned integer
SamplesPerPixel: 4

% ~/code/bioformats-test/tools/showinf -nopix SplitChannels.tiff
Checking file format [Tagged Image File Format]
Initializing reader
TiffDelegateReader initializing SplitChannels.tiff
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
Initialization took 0.057s

Reading core metadata
filename = SplitChannels.tiff
Series count = 1
Series #0 :
        Image count = 1
        RGB = true (4)
        Interleaved = false
        Indexed = false (false color)
        Width = 1763
        Height = 1266
        SizeZ = 1
        SizeT = 1
        SizeC = 4 (effectively 1)
        Thumbnail size = 128 x 91
        Endianness = motorola (big)
        Dimension order = XYCZT (certain)
        Pixel type = uint8
        Valid bits per pixel = 8
        Metadata complete = true
        Thumbnail series = false
        -----
        Plane #0 <=> Z 0, C 0, T 0


Reading global metadata
BitsPerSample: 8
Compression: LZW
ExtraSamples: 1
ImageLength: 1266
ImageWidth: 1763
MetaDataPhotometricInterpretation: RGB
MetaMorph: no
NumberOfChannels: 4
Orientation: 1st row - top; 1st column - left
PhotometricInterpretation: RGB
PlanarConfiguration: Chunky
Predictor: Horizontal differencing
SampleFormat: unsigned integer
SamplesPerPixel: 4


In terms of the Bio-Formats API, these aren't independent channels (getEffectiveSizeC()), they are RGB subchannels (getRGBChannelCount()). How you choose to interpret and display this data is up to you.

Looking at your code, you're using a BufferedImage for displaying the data. I'm not totally familiar with this component, but one thing is clear: your data is not simple RGB or RGBA data from what I can tell. The 4th subchannel is not alpha; it's a fourth subchannel. I think you might need to look at customising ColorModel (http://docs.oracle.com/javase/7/docs/ap ... Model.html) for your BufferedImage to combine the four subchannels as you see fit i.e. to combine the colours for all four channels to give you a single pixel value. i.e. decide what the colours should be for C1-C4, and then set R=r1+r2+r3+r4, G=g1+g2+g3+g4 and B=b1+b2+b3+b4 (for example).

I hope that's some help. I can't see any problems with either your image data or how bioformats is interpreting and handling the data; it looks like it's down to how you want to visualise the data.

Kind regards,
Roger Leigh
User avatar
rleigh
 
Posts: 217
Joined: Tue Mar 13, 2012 11:45 am

Re: Ome.tiff file - can't display with colors

Postby Charavay » Tue Jun 30, 2015 2:00 pm

Roger,

Thank you for your help.

Best regards

Céline
Charavay
 
Posts: 14
Joined: Fri Jun 19, 2015 1:49 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: Google [Bot] and 1 guest