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

Grey scale image decoder color type : InterpretationWithBits(RGBPalette, [8]) #202

Open
aguennecjacq opened this issue Feb 20, 2023 · 1 comment

Comments

@aguennecjacq
Copy link

Hi,
Maybe this is just me being new to rust, but i've had an issue reading the color type from a greyscale 8bits tif image.
Here is the image I've had some issues with : Barbara.tif
When trying to read the color type of the image from the decoder I get the following error:
UnsupportedError(InterpretationWithBits(RGBPalette, [8])).

This also leads to an incorrect reading in the image crate image open function: image::open() ->
Unsupported(UnsupportedError { format: Exact(Tiff), kind: GenericFeature("RGBPalette with [8] bits per sample is unsupported") }).

@Jondeen
Copy link

Jondeen commented Sep 6, 2023

Just to chime in, although somewhat unrelated, this image is not technically greyscale. Instead, it utilizes the ColorMap feature specified in the TIFF format, which employs a lookup table (e.g., x => RGB(r, g, b)). While the data storage type is 8-bit, the lookup table provides 16bit RGB colors.

Here's the tiffinfo output for Barbara.tif:

      $ tiffinfo -r Barbara.tif
      TIFFReadDirectory: Warning, Unknown field with tag 37724 (0x935c) encountered.
      TIFF Directory at offset 0x8 (8)
        Subfile Type: (0 = 0x0)
        Image Width: 512 Image Length: 512
        Resolution: 72, 72 pixels/inch
-->     Bits/Sample: 8
        Compression Scheme: None
-->     Photometric Interpretation: palette color (RGB from colormap)
        Samples/Pixel: 1
        Rows/Strip: 512
        Planar Configuration: single image plane
-->     Color Map: (present)
        Photoshop Data: <present>, 5314 bytes
        Tag 37724: 0x41,0x64,0x6f,0x62,0x65,0x20,0x50,0x68,0x6f,0x74,0x6f,0x73,0x68,0x6f,0x70,0x20,0x44,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x20,0x44,0x61,0x74,0x61,0x20,0x42,0x6c,0x6f,0x63,0x6b,0x0

Barbara.tif contains a lookup table that does indeed generate greyscale colors, but they are techincally represented as 16bit RGB:

Reds: (0, 257, ... , 65278, 65535)
Greens: (0, 257, ... , 65278, 65535)
Blues: (0, 257, ... , 65278, 65535)

Finally, why its not working for you:
Looking into the source of the Rust package, ColorMaps are not yet implemented:

ColorMap = 320, // TODO add support

Some TIFF libraries collapse the color resolution if the color map is consistently grey scale, and some retain it at its full resolution.

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

No branches or pull requests

2 participants