[Insight-users] Superimposing images

Chris Farmer cfarmer at scitegic.com
Fri Sep 9 20:17:53 EDT 2005


Hi all,

I clearly have a problem with terminology, so if someone could suggest
the proper terms here, I'd really appreciate it!

I have a collection of three images that need to be superimposed on one
another.  They're all grayscale at the moment, but I'd like to use them
as the R, G, and B in a composite RGB image.  I guess I can use a cast
filter to convert my grayscale image into RGB, but I'm not sure how to
then modify the colors.

On a related note, I thought I'd use the AddImageFilter to combine them.
I can't seem to compile when I use an input pixel type of
RGBPixel<unsigned char> when I use the AddImageFilter, though.  When I
use a pixel type of unsigned char, the image addition appears to work
nicely, but it's of course just grayscale.

Here's what I tried:

// Won't compile with this first typedef 
typedef itk::RGBPixel<unsigned char>	RGBPixelType;
// Works with this typedef, but no color
//typedef unsigned char	RGBPixelType;
typedef itk::Image< RGBPixelType, 2 >   RGBImageType;

typedef itk::ImageFileReader<RGBImageType> ReaderType2;
ReaderType2::Pointer reader1 = ReaderType2::New();
ReaderType2::Pointer reader2 = ReaderType2::New();

reader1->SetFileName("C:\\redline.PNG");
reader2->SetFileName("C:\\blueline.PNG");

typedef itk::AddImageFilter<RGBImageType, RGBImageType, RGBImageType>
AddType;
AddType::Pointer adder = AddType::New();
adder->SetInput1(reader1->GetOutput());
adder->SetInput2(reader2->GetOutput());
	
typedef itk::ImageFileWriter<RGBImageType> WriterType;
WriterType::Pointer writer = WriterType::New();

writer->SetFileName("c:\\redplusblue.png");
writer->SetInput(adder->GetOutput());
writer->Update();


Can someone point out any good resources on using ITK with RGB images
like this, or at least suggest some better search terms so I can more
precisely research my problem in the list archives?


Thanks,
Chris





More information about the Insight-users mailing list