[vtkusers] Iterating over an image and getting neighbors
David Doria
daviddoria at gmail.com
Fri Sep 24 07:17:00 EDT 2010
>
> I want to visit each pixel in an image (a 2D vtkImageData) and get its
4-connected neighbors. The tricky part (i.e. that makes it messy to do
directly in the algorithm) is that there is not always 4 valid
neighbors (you might be on the edge of the image).
> Is there any built in mechanism for doing this? It would be very nice
to separate this logic from the core algorithm.
> I saw vtkImageIterator but it just seems to move a pointer but not
know anything about neighborhoods:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/ImageData/vtkImageIterator
> I also saw vtkImageSpatialAlgorithm, but it doesn't seem to have any
concept of neighbors of a pixel either.
> I'd like something like a
> for(every pixel in the image)
{
neighbors = pixel.GetNeighbors()
if(neighbors.HasLeft())
{do something with neighbors.GetLeft()}
}
> Is there anything like this built in?
> Thanks,
> David
On Fri, Sep 24, 2010 at 1:19 AM, Shashwath T.R. <trshash at gmail.com> wrote:
> Hi David,
>
> I'm interested in this idea too. It seems to me that we're talking about
> essentially the same functionality provided by ITK's iterators, at least
to
> some extent.
>
> Right now, I'm happy using ITK for most such processing, but it may be
> overkill for a lot of small applications. But if that's the case, maybe we
> can follow ITK's API to some extent.
>
> Regards,
> Shash
Shash,
Following ITK is a good idea. I haven't worked with ITK in a long time,
would you be able to post an example of what I've described (but using ITK)
here:
http://www.vtk.org/Wiki/ITK/InsightClopedia/ImageProcessing/IteratingOverAnImage
We can then try to "port" this functionality to VTK. If you have a github
username let me know and I'll add you as a contributor on the repository:
http://github.com/daviddoria/vtkImageTraversal
@Luis, if indeed this does not exist in VTK, it seems like a rather
important functionality that should be carefully designed, do you have any
input you can share from your design of ITK?
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100924/16fdec12/attachment.htm>
More information about the vtkusers
mailing list