Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB & color handling #96

Merged
merged 4 commits into from
Feb 22, 2023
Merged

Conversation

sbesson
Copy link
Member

@sbesson sbesson commented Jan 31, 2023

Primarily driven by the discussion at https://forum.image.sc/t/nikon-slide-scanner-brightfield-nd2-files-lacking-rgb-information-after-conversion-to-ome-tif-when-viewed-in-omero/76438

The scenario can be reproduced by using a file similar to

% cat test.fake.ini
sizeC=3
color_0=16711935
color_1=16711935
color_2=16711935

and either running NGFF-Converter 1.1.4 with the--rgb flag in the arguments list or directly:

% bioformats2raw test.fake test.zarr
% raw2ometiff test.zarr test.ome.tiff --rgb

The generated OME-TIFF is a RGB image (SizeC=3, 1 channel with SamplePerPixels=3) as expected but its Channel metadata still contains the green color information

 % tiffinfo ~/Downloads/test.ome.tiff 
=== TIFF directory 0 ===
TIFF Directory at offset 0x27c7f (162943)
  Image Width: 512 Image Length: 512
  Tile Width: 512 Tile Length: 512
  Resolution: 0, 0 pixels/cm
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Planar Configuration: separate image planes
  SubIFD Offsets: 162516
  ImageDescription: <?xml version="1.0" encoding="UTF-8"?><OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"><Image ID="Image:0" Name="test"><Pixels BigEndian="true" DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" SignificantBits="8" SizeC="3" SizeT="1" SizeX="512" SizeY="512" SizeZ="1" Type="uint8"><Channel Color="16711935" ID="Channel:0:0" SamplesPerPixel="3"><LightPath/></Channel><TiffData IFD="0" PlaneCount="1"/></Pixels></Image><StructuredAnnotations><MapAnnotation ID="Annotation:Resolution:0" Namespace="openmicroscopy.org/PyramidResolution"><Value><M K="1">256 256</M></Value></MapAnnotation></StructuredAnnotations></OME>
  Software: OME Bio-Formats 6.11.1

When importing such a file into OMERO, all channels are now populated as green by default. This is at odds with the user expectation when passing a --rgb flag.

dcb6642 expands the RGB conversion tests to covert the scenario above and add channel metadata assertions
2cfbd1e proposes to change the behavior of the converter to remove the Channel.Color metadata when --rgb is passed and adjusts the newly introduced unit test accordingly

/cc @DavidStirling

Test the sizeC, channel count and channel SamplesPerPixel values
Add a test with a fake file with a color
@melissalinkert
Copy link
Member

I think this generally makes sense. Two thoughts:

  • is it worth warning if colors are present but will be removed?
  • should all of the EmissionWavelength, ExcitationWavelength, LightSource, and Filter metadata under Channel be removed as well?

@sbesson
Copy link
Member Author

sbesson commented Feb 1, 2023

The last commits should remove any channel metadata that could be used as the source of truth for setting the color as defined in https://github.com/ome/omero-blitz/blob/c4e4d2bbd3ac6d5cdc14621fb89fb97187eca22e/src/main/java/ome/formats/model/ChannelProcessor.java#L129.
The channel name is also removed.

All of the above could be made configurable via some command-line options if deemed valuable.

Copy link
Member

@melissalinkert melissalinkert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this as-is. I don't think an option to keep channel metadata when --rgb is specified adds much value - most of the channel metadata would be lost either way. In most cases where --rgb is useful, the source data would have been RGB anyway.

@melissalinkert
Copy link
Member

Merging as discussed during today's PR review meeting.

@melissalinkert melissalinkert merged commit 930a17c into glencoesoftware:master Feb 22, 2023
@sbesson sbesson deleted the rgb_color branch May 25, 2023 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants