[Insight-users] Set RGB pixel

Ashish Singh mrasingh at gmail.com
Wed Jan 24 10:48:33 EST 2007


Hi,

I am trying to modify a certain portion of an RGB image. I use an Iterator
to which the desired region and the image are passed, but I am having
trouble using the 'Set' function to set the pixel values. Can anyone please
help me pass the new pixel values using the 'Set' command.
The relevant portion of my code is as follows:

---------------
const unsigned int InputDimension =2;
typedef unsigned char InputPixelType;
typedef itk::Image< InputPixelType, InputDimension > InputImageType;
typedef itk::ImageRegionIterator< InputImageType > IteratorType;

InputImageType::SizeType size;
InputImageType::IndexType start;
InputImageType::RegionType desiredregion;

//set the desired region
size[0]=300;
size[1]=20;
start[0]=500;
start[1]=0;
desiredregion.SetIndex(start);
desiredregion.SetSize(size);

IteratorType out2( image, desiredregion ); //image is previously read
    for(out2.GoToBegin();!out2.IsAtEnd();++out2)
    {
         out2.Set(0);//this is where I have problem
    }

-----------

What should my ' out2.set() ' line look like to be able to set the color to
black or any other value? Or is there any other simpler way to do this?

Thanks in advance.
Ashish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070124/b6020c0b/attachment.html


More information about the Insight-users mailing list