[Insight-users] Problem in setting pixel values for RGB Image
Kishore Mosaliganti
kishoreraom at gmail.com
Thu Nov 19 11:58:47 EST 2009
Hi Harish,
You may also want to use a while loop rather than a for-loop which
contains about 7 statements on one line. This is not easy to read nor
debug.
So your code would read:
it1.GoToBegin();
it2.GoToBegin();
it3.GoToBegin();
while ( !it1.IsAtEnd() )
{
......
++it1;
++it2;
++it3;
}
Kishore
Wed, Nov 18, 2009 at 8:19 PM, C.Cagatay Bilgin <bilgic at cs.rpi.edu> wrote:
> Hi Harish,
> you want something like:
> RGBImageType::PixelType pixelValue;
> pixelValue[0] = 255;
> pixelValue[1] = 0;
> pixelValue[2] = 0;
> it3.Set(pixelValue);
> Regards,
> C.Cagatay Bilgin
>
>
> 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
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list