[Insight-users] How to combine three color component data into a RGB image

Fucang Jia jiafucang@hotmail.com
Sat, 22 Feb 2003 20:19:02 +0800


Hi everyone, hi Luis,

I use iterator to extract red, green, blue component from a color image, 
after some operation on each component data, finally I want to combine these 
three component data into a RGB color image again. But I do not know how to 
do that? Could you help me? Thanks!

Here is the former code:

RGBImageType::Pointer image = reader->GetOutput();

// extract red channel component  
itk::AdaptImageFilter<RGBImageType,GrayImageType,RedAccessorType>::Pointer 
adaptImageToRed = 
itk::AdaptImageFilter<RGBImageType,GrayImageType,RedAccessorType>::New();

adaptImageToRed->SetInput(image);
adaptImageToRed->UpdateLargestPossibleRegion();
myIteratorType 
it1(adaptImageToRed->GetOutput(),adaptImageToRed->GetOutput()->GetRequestedRegion());


// extract green channel component
itk::AdaptImageFilter<RGBImageType,GrayImageType,GreenAccessorType>::Pointer 
adaptImageToGreen = 
itk::AdaptImageFilter<RGBImageType,GrayImageType,GreenAccessorType>::New();

adaptImageToGreen->SetInput(image);
adaptImageToGreen->UpdateLargestPossibleRegion();
myIteratorType 
it2(adaptImageToGreen->GetOutput(),adaptImageToGreen->GetOutput()->GetRequestedRegion());


// extract blue channel component
itk::AdaptImageFilter<RGBImageType,GrayImageType,BlueAccessorType>::Pointer 
adaptImageToBlue = 
itk::AdaptImageFilter<RGBImageType,GrayImageType,BlueAccessorType>::New();

adaptImageToBlue->SetInput(image);
adaptImageToBlue->UpdateLargestPossibleRegion();

myIteratorType 
it3(adaptImageToBlue->GetOutput(),adaptImageToBlue->GetOutput()->GetRequestedRegion());

// execute some operation on each color component
filter1->SetInput(adaptImageToRed->GetOutput());
filter2->SetInput(adaptImageToGreen->GetOutput());
filter3->SetInptu(adaptImageToBlue->GetOutput());

// Some code needed to combine filter1->GetOutput(), filter2->GetOutput(), 
filter3->GetOutput()  into one itk::Image data colorimage, so that 
writer->SetInput(colorimage)

???

Fucang

_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail