[Insight-users] previous pixel

Luis Ibanez luis.ibanez at kitware.com
Sun Jun 1 12:02:30 EDT 2008


Hi Zhihong,


Here are a couple of options

A) you could move the iterator backward and forward
    and use the Get() method in between.

    like:

      PixelType v1  = itr.Get();
      --itr;
      // pixel before
      PixelType v2  = itr.Get();
      ++itr;
      ++itr;
      // pixel after
      PixelType v3  = itr.Get();

    Depending on how you are visiting the image,
    this could have been simplified by just keeping
    a cache of the two last visited pixels. In this
    way you can avoid the --itr, and two ++itr,
    which are indeed unnecessary.


0r


B)  You may want to take a look at Neighborhood Iterators.
     You will  find a detailed description in the ITK
     Software Guide

          http://www.itk.org/ItkSoftwareGuide.pdf



It will be easier to give you a more helpful answer
if you describe better the pattern of pixel access
that you have in mind.


    Regards,


        Luis



------------------
zhihong hu wrote:
> Hi Luis,
>  
> I want to use a linear iterator (itk::ImageLinearIteratorWithIndex) to 
> access a few previous and next pixel. By using it.Get(), it can only 
> access current pixel value. Could you please tell me how to do? 
> Thank you very much.
>  
> Zhihong
> 


More information about the Insight-users mailing list