[Insight-developers] What are the bounds of an itkImageRegion?
Steve M. Robbins
steve at sumost.ca
Sun Dec 28 23:52:03 EST 2008
Hi,
While pondering issue 6558 "Physical coordinates of a pixel - Severe
inconsistency and bug in ImageBase", I started writing some
tests for itkImageRegion.
I came to the conclusion that either I misunderstand this class or
there's a more fundamental bug in there.
The class doc says:
* \brief An image region represents a structured region of data.
*
* ImageRegion is an class that represents some structured portion or
* piece of an Image. The ImageRegion is represented with an index and
* a size in each of the n-dimensions of the image. (The index is the
* corner of the image, the size is the lengths of the image in each of
* the topological directions.)
Consider a 1-dimensional region with start=1, size=2. I interpreted
the above to mean that the region is the half-open interval [1,3) on
the real line. Or maybe it's the closed interval [1,3] ?
In either case, I expected 2.99 to be included in the region,
but it isn't as the following test-case shows (written
using Boost.Test; c.f. my earlier post from this evening).
BOOST_AUTO_TEST_CASE( testContinuousIndexPointIsInsideEdgeConvention )
{
Fixture1 line( 1, 2 );
Fixture1::CIndexType p0, p1, p2, p3;
p0[0] = 0.99;
p1[0] = 1.01;
p2[0] = 2.99;
p3[0] = 3.01;
BOOST_CHECK( ! line.mRegion.IsInside( p0 ) );
BOOST_CHECK( line.mRegion.IsInside( p1 ) );
BOOST_CHECK( line.mRegion.IsInside( p2 ) );
BOOST_CHECK( ! line.mRegion.IsInside( p3 ) );
}
See below for the Fixture code. This test fails on the p2 line -- it
is treated as being outside the region.
By the way, is there any concensus to fix this? I believe the code
should be modified to follow the ITK Software Guide; i.e. to
use pixel-centre convention, in which case the test needs to
be modified to:
p0[0] = 0.49;
p1[0] = 0.51;
p2[0] = 2.49;
p3[0] = 2.51;
Regards,
-Steve
P.S. The Fixture code follows.
template< unsigned int VImageDimension >
struct Fixture
{
typedef itk::ImageRegion<VImageDimension> RegionType;
typedef typename RegionType::IndexType IndexType;
typedef typename RegionType::SizeType SizeType;
typedef itk::ContinuousIndex<float,VImageDimension> CIndexType;
RegionType mRegion;
};
struct Fixture1 : public Fixture<1>
{
Fixture1( int start0,
int size0 )
{
IndexType start = {{ start0 }};
SizeType size = {{ size0 }};
mRegion = RegionType( start, size );
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20081228/0087514d/attachment.pgp>
More information about the Insight-developers
mailing list