[ITK Community] [Insight-users] ScalarToRGBColormapImageFilter custom range
Brian Helba
brian.helba at kitware.com
Fri Nov 15 05:40:36 EST 2013
Hi Wei,
You didn't specify a version of ITK that you were using, so I will assume
the most recent release (v4.4.2) for my comments.
First, note that itk::ScalarToRGBColormapImageFilter will always get the
maximum pixel value of the input image and re-call
"m_Colormap->SetMaximumInputValue"
with it [1]. This happens intrinsically when running the
ColormapImageFilter, so I believe there is really no place in user code
that you could set a different maximum that wouldn't be overwritten later.
There is a fairly simple solution, however. The method
itk::HotColormapFunction::SetMaximumInputValue is virtual [2]. You could
create your own subclass of itk::HotColormapFunction, then override
"SetMaximumInputValue" to ignore its parameter and insted set
"m_MaximumInputValue" to be 255 (or even some other value, stored in
another new member variable). Then of course just typedef your new subclass
as the ColormapType and use the rest of your code as normal.
[1]
http://itk.org/gitweb?p=ITK.git;a=blob;f=Modules/Filtering/Colormap/include/itkScalarToRGBColormapImageFilter.hxx;h=2e958db61f7f7639951af24d93baac921534819f;hb=3f8d0a7d84ba3bac4950114e0e0e15f69852496d#l101
[2]
http://www.itk.org/Doxygen44/html/classitk_1_1Function_1_1ColormapFunction.html#a6e3e281b374c86acf427baf2983f879a
Hope this helps.
Enjoy,
Brian
On Tue, Nov 12, 2013 at 1:26 AM, Wei Liu <weiliu620 at gmail.com> wrote:
> Dear itk users,
>
> I'm trying to use ScalarToRGBColormapImageFilter to map a scalar to rgb
> color. According to the document, "The range of values present in the input
> image is the range that is mapped to the entire range of colors". However,
> I want to fix the range of the input image. That is, no matter what
> intensity range of the input image is, I want the range [0, 255] map to the
> full color range. So far I have tried the following approach:
>
> typedef itk::Function::HotColormapFunction< ImageType2DF::PixelType,
> RGBImageType::PixelType > ColormapType;
> ColormapType::Pointer colormap = ColormapType::New();
> colormap->SetMinimumInputValue(0);
> colormap->SetMaximumInputValue(255);
> std::cout << "max input: " << colormap->GetMaximumInputValue() <<
> std::endl;
> rgbfilter->SetColormap(colormap);
>
> I can see the maximum input value is correctly set. But it seems the
> ScalarToRGBColormapImageFilter still define the input range by reading the
> input image's min/max value. Did I miss something?
>
> I have a related question: it looks itk does not have a filter to overlay
> a continuous value image onto a gray level intensity image. That is the
> reason I mannually convert the scalar image to rgb image, and overlay it
> onto the gray level intensity image. Is there better way of doing it?
>
> I appreciate your input.
>
> Wei
>
> _____________________________________
> Powered by 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://www.itk.org/mailman/listinfo/insight-users
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/community
>
>
--
Brian Helba
Medical Imaging
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20131115/81415bcb/attachment.html>
-------------- next part --------------
_____________________________________
Powered by 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://www.itk.org/mailman/listinfo/insight-users
More information about the Community
mailing list