[Insight-users] RGBImageType to FloatImageType wit CastImageFilter

chasank chasank at gmail.com
Fri May 24 08:50:57 EDT 2013


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.


More information about the Insight-users mailing list