[Insight-users] Iterators and RGB images

Karthik Krishnan Karthik.Krishnan at kitware.com
Sun Jun 26 20:37:05 EDT 2005


Sure you can use the Set method.

itk::ImageRegionConstIterator< BlackAndWhiteImageType >
bwIt( blackAndWhiteImage, region );

itk::ImageRegionIterator< RGBImageType > rgbIt( rgbimage, region );
....
while( !bwIt.IsAtEnd() )
{
itk::RGBPixel< DataType > pixel;
pixel.SetNthComponent( 0, number1 );
pixel.SetNthComponent( 1, number2 );
pixel.SetNthComponent( 2, number3 );
rgbIt.Set( pixel );
rgbIt++; bwIt++;
}

HTH 
-karthik

On Sun, 2005-06-26 at 16:01 -0400, Julian Tam wrote:
> Hello,
> 
> I have a series of black and white input images.  I am hoping to
> output an RGB image based on the intensity of the input image (eg.
> within a certain intensity range, the pixel should appear as red, and
> within another, blue).
> 
> For the sake of efficiency, I would be interested in using an iterator
> to access every pixel and check if the processing is needed.  However,
> I can't seem to find a suitable method to do this.    I've been able
> to use the Set() method to modify the intensity of a black and white
> image, but haven't come across a way to set the individual red, green,
> and blue values of the image.
> 
> Could someone please suggest a possible approach for my problem?
> 
> Thank you,
> Julian Tam
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list