[Insight-users] Finding out when a neighborhood iterator is o
utside the image?
Miller, James V (Research)
millerjv at crd.ge.com
Thu Jul 29 15:57:16 EDT 2004
Usually the boundary conditions are handled "internally" so the
user doesn't worry about whether the offset is a boundary condition
or not.
But I suppose in your case, relying on the boundary condition
(constant or zeroflux) would bias your statistics.
If the entire scalar range of the pixel type is not being used,
you could use a ConstantBoundaryCondition with a constant value
that is not used in the image, say NumericTraits<>::NonpositiveMin().
Then when you access the "offset" within the neighborhood, if the
value is your boundary condition value, then you know the offset
if off the boundary.
We could add a method to ConstNeighborhoodIterator to query an offset.
I would pull the code from GetPixel() from lines 73-100 into a separate
method, say
virtual bool IsInBounds( const unsigned int i ) const;
and change the GetPixel() code to call this method.
Let me know if this new method would help.
Jim
-----Original Message-----
From: Zachary Pincus [mailto:zpincus at stanford.edu]
Sent: Thursday, July 29, 2004 3:35 PM
To: insight-users List
Subject: [Insight-users] Finding out when a neighborhood iterator is
outside the image?
Hello,
I seem to recall seeing somewhere a method in ITK for determining when
a particular element of a neighborhood (or shaped neighborhood) is
outside of the real image. Unfortunately, neither searching the list
nor wracking my brain can retrieve this information.
Basically, I'm using shaped neighborhoods to get pairs of pixels to do
statistics on. Previously, I had just used the BoundaryFacesCalculator
to get the region of an image where a given neighborhood could not
possibly be outside the image. The problem is that just using that
region is too conservative: there are parts of the image where a given
neighborhood center and offset are still both on the image, even though
other parts of the neighborhood might be dangling off.
Maybe the best thing here would be to create a
"ThrowExceptionBoundaryCondition" and then catch the exception when
necessary to determine whether a given pixel is actually outside of the
image. Would that work, or are there other better ideas?
Zach Pincus
Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list