[Insight-users] RGBImageType to FloatImageType wit CastImageFilter

Bradley Lowekamp blowekamp at mail.nih.gov
Fri May 24 09:05:44 EDT 2013


Hello,

You may need some of the operations available in here:

http://www.insight-journal.org/browse/publication/780

I have not done this in ITK my self. But you would need to convert to a color space such as Luv, then process just he L channel, then convert back to RGB.

Alternatively, you can just process the channel as 3 independent components, by running the filter on each component. SimpleITK does this automatically for VectorImages

https://github.com/SimpleITK/SimpleITK/blob/master/TemplateComponents/ExecuteInternalVectorImages.cxx.in#L34

I know I have seen a Wiki example which does a very simular thing too:

http://www.itk.org/Wiki/ITK/Examples

Brad

On May 24, 2013, at 8:50 AM, chasank <chasank at gmail.com> wrote:

> Thanks for quick answers. Yes I've used the RGBToLuminanceImageFilter before
> processing the blur filter. However I'm dealing with an another problem,
> After converting original RGB image to grayscale image. How can I obtain its
> original color map for converting grayscale to RGB ?
> 
> typedef itk::Image< itk::RGBPixel <unsigned char>,  2 >  RGBImageType;
> typedef itk::Image< unsigned char, 2>                    ScalarImageType;
> 
> int main(int argc, char **argv)
> {
>    try
>    {
>        itk::ImageFileReader < RGBImageType >::Pointer reader =
>                itk::ImageFileReader < RGBImageType >::New();
>        itk::JPEGImageIO::Pointer jpegIO = itk::JPEGImageIO::New();
>        reader->SetFileName("./sample.jpg");
>        reader->SetImageIO(jpegIO);
>        reader->Update();
> 
>        RGBImageType::Pointer image;
> 
>        itk::RGBToLuminanceImageFilter<RGBImageType,
> ScalarImageType>::Pointer luminanceFilter =
>                itk::RGBToLuminanceImageFilter<RGBImageType,
> ScalarImageType>::New();
>        luminanceFilter->SetInput(reader->GetOutput());
>        luminanceFilter->Update();
> 
>        FilterCallBack::Pointer callBack = FilterCallBack::New();
> 
>        itk::BinomialBlurImageFilter< ScalarImageType, ScalarImageType
>> ::Pointer blurFilter =
>                itk::BinomialBlurImageFilter < ScalarImageType,
> ScalarImageType> ::New();
>        blurFilter->SetInput(luminanceFilter->GetOutput());
>        blurFilter->AddObserver(itk::ProgressEvent(), callBack);
>        blurFilter->SetRepetitions(3);
>        blurFilter->Update();
> 
>        itk::ScalarToRGBColormapImageFilter< ScalarImageType, RGBImageType
>> ::Pointer colorMapFilter =
>                itk::ScalarToRGBColormapImageFilter< ScalarImageType,
> RGBImageType>::New();
>        colorMapFilter->SetInput(blurFilter->GetOutput());
> 
> colorMapFilter->SetColormap(itk::ScalarToRGBColormapImageFilter<ScalarImageType,
> RGBImageType>::Jet); // Something like reader->GetOutput()->GetColorMap()
> ???
>        colorMapFilter->Update();
> 
>        QuickView view;
> 
>        view.AddRGBImage(reader->GetOutput(), true, "Original");
>        view.AddRGBImage(colorMapFilter->GetOutput(), true, "Blur
> Filtered");
>        view.Visualize();
> 
>    }
>    catch ( itk::ExceptionObject &exception)
>    {
>        std::cerr << exception << std::endl;
>    }
> 
>    return 0;
> }
> 
> 
> 
> --
> View this message in context: http://itk-users.7.n7.nabble.com/RGBImageType-to-FloatImageType-wit-CastImageFilter-tp31552p31554.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
> _____________________________________
> 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 Insight-users mailing list