[Insight-users] Problem in setting pixel values for RGB Image
Harish Doddi
harish.slicer at gmail.com
Wed Nov 18 19:17:09 EST 2009
Hi all,
I have created a RGBImage and copied a gray scale image to it. Now I would
like to set some pixel values in RGBImage to some colors lets say red,
green, etc.
My code is like this
/* For RGB Pixels */
RGBImageType::Pointer rgbImage = RGBImageType::New();
rgbImage->SetRegions( image1->GetRequestedRegion() );
rgbImage->CopyInformation( image1 );
rgbImage->Allocate();
/* Iterate through the images */
/* Here image1 and image2 are gray scale MRI images */
IteratorType it1( image1, image1->GetRequestedRegion());
IteratorType it2( image2, image2->GetRequestedRegion());
RGBIteratorType it3( rgbImage, rgbImage->GetRequestedRegion());
for ( it1.GoToBegin(), it2.GoToBegin(), it3.GoToBegin(); !it1.IsAtEnd() &&
!it2.IsAtEnd();
++it1, ++it2, ++it3)
{
/* Find x and y */
float x,y;
x = it1.Get();
y = it2.Get();
int val = func(x,y);
if(val == 0)
it3.Set(RED_COLOR);
else
it3.Set(GREEN_COLOR);
}
What should RED_COLOR and GREEN_COLOR be replaced with??
Thanks,
Harish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091118/50e190b6/attachment.htm>
More information about the Insight-users
mailing list