[Insight-users] Getting a reference to a pixel from an iterator

M.Staring at lumc.nl M.Staring at lumc.nl
Mon Feb 28 10:09:00 EST 2011


Hi David,

Would the Value()-function do what you need?

PixelType & Value (void);

HTH,

Marius

-----Original Message-----
From: insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org] On Behalf Of Cory Quammen
Sent: maandag 28 februari 2011 15:55
To: David Doria
Cc: ITK
Subject: Re: [Insight-users] Getting a reference to a pixel from an iterator

> Thanks for confirming there is no way to do this. Using Set() won't 
> work for me - what I was trying to do was:
> std::vector<PixelType*> pixels;
> itk::ImageRegionIterator<ImageType> imageIterator = 
> itk::ImageRegionIterator<ImageType>(image, region);
>   while(!imageIterator.IsAtEnd())
>     {
>     if(someCondition(pixel))
>       pixels.push_back(&pixel);
>     }
> ChangePixels(pixels);

You could switch to an ImageRegionIteratorWithIndex and store the indices of the pixels that pass your condition. After the while loop, you could operate on these pixel values by using the SetPixel() and
GetPixel() methods of your Image.

Cory

--
Cory Quammen
Computer Integrated Systems for Microscopy and Manipulation (CISMM) Department of Computer Science University of North Carolina at Chapel Hill http://www.cs.unc.edu/~cquammen _____________________________________
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