[ITK-users] read palette image as scalar image + palette, instead of RGB image

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Wed Jan 25 08:52:20 EST 2017


This sounds like a great addition.

I would not implement the method in ImageFileReader yet. It should be easily enough to add it later.

Are you planning of exposing the palette after loading? The MetaDataDictionary could be used for this. But we don’t have any palette data structure or established conventions yet.

I look forward to seeing your patch.
Brad

On Jan 24, 2017, at 10:06 AM, asertyuio via Insight-users <insight-users at itk.org<mailto:insight-users at itk.org>> wrote:


Hi Dženan,

Thanks, you gave me the right direction!

I have adapted itkBPMImageIO, itkTiffImageIO, and itkPNGImageIO so that the user have the choice to expand the color palette or not, and retrive a vector of RGBPixel corresponding to this palette. I will try to submit these changes to gerrit.

I'm not quite sure whether I should push a bit more so that this choice could be set directly in itkImageReader. Do you have any advice ?

Thanks for your answer,

Yann

Le 16/01/2017 à 15:50, Dženan Zukić a écrit :
Hi Yann,

the relevant part of code for PNG format is in itkPNGImageIO.cxx, approximately lines 365-395 (link<https://github.com/InsightSoftwareConsortium/ITK/blob/578d3660e71022680d3abf313ad8b84ce2a7dd66/Modules/IO/PNG/src/itkPNGImageIO.cxx#L365-L393>). You will need to modify that. If you modify it in a way so it can be useful for others, please submit your patch to code review<https://itk.org/Wiki/ITK/Git/Develop>.

To get access to the specialized functions of the PNG reader, you would instantiate it directly:
itk::PNGImageIO::Pointer imageIO = ...
std::vector<RGBPixel> colorTable = imageIO->GetColorTable(); //call a function you added to PNG reader

Hope this helps,
Dženan

On Sun, Jan 15, 2017 at 11:07 AM, asertyuio via Insight-users <<mailto:insight-users at itk.org>insight-users at itk.org<mailto:insight-users at itk.org>> wrote:

Hi all,

I want to read a palette image as a scalar image with its indexes + a vector of RGB, corresponding to the image palette. The format of the image is TIFF, but can be png or gif as well.

When I'm reading such palette image, the itk::ImageIOBase, as implemented here<https://itk.org/ITKExamples/src/IO/ImageBase/ReadUnknownImageType/Documentation.html>, tels me that the image has a RGB pixel type.

itk::ImageIOBase::Pointer imageIO =
    itk::ImageIOFactory::CreateImageIO(
        fileName, itk::ImageIOFactory::ReadMode);

Is it possible to know, through ITK, whether the image is actually a palette image, i.e. scalar image along with a color palette, and read this image as a scalar image + palette ? I need have access to the index, as stored in the file as well as the color palette used in the file.

For now, my only solution is to use freeImagePlus to identify and read this type of image. I haven't found any function in the class ImageIOBase that could relate to that.

Any help would be appreciated, thanks a lot ! Yann

_____________________________________ Powered by www.kitware.com<http://www.kitware.com/> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Kitware offers ITK Training Courses, for more information visit: http://www.kitware.com/products/protraining.php Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170125/0bf23108/attachment.html>


More information about the Insight-users mailing list