The bounding box of an ImageMaskSpatialObject, as returned by GetMyBoundingBoxInObjectSpace() (introduced with the recent Spatial Object update by Stephen @aylward ) appears smaller than the one returned by GetBoundingBox(), from ITK5 RC1 or previous ITK versions. For example, the following code printed [4, 6, 4, 6], using ITK5 RC1:
const auto image = itk::Image<unsigned char>::New();
image->SetRegions(itk::Size<>{8, 8});
image->Allocate(true); // Zero as background value.
// Little 2 x 2 square of non-zero values:
image->SetPixel({ 4, 4 }, 1);
image->SetPixel({ 4, 5 }, 1);
image->SetPixel({ 5, 4 }, 1);
image->SetPixel({ 5, 5 }, 1);
const auto spatialObject = itk::ImageMaskSpatialObject<2>::New();
spatialObject->SetImage(image);
spatialObject->Update();
std::cout << spatialObject->GetBoundingBox()->GetBounds(); // [4, 6, 4, 6]
With the current git master revision of ITK, April 23, 2019 (which includes the Spatial Object update), the following prints [4, 5, 4, 5], instead:
std::cout << spatialObject->GetMyBoundingBoxInObjectSpace()->GetBounds(); // [4, 5, 4, 5]!!!
Was this behavior change intended?
Just discussed with @kaspermarstal and @stefanklein at our Elastix/SuperElastix sprint meeting. We would like to see a bounding box (in object space) of [3.5, 5.5, 3.5, 5.5] in this case. So in general, taking the size of the pixels at the border of the bounding box into account. What do you think?
Somewhat related topic: https://discourse.itk.org/t/imagemaskspatialobject-isinside-less-than-half-a-pixel-away/1807
Hi
I think returning a continuous index or an index that has a buffer is
appropriate .
So either the 3.5,5.5 or the 3,6 solutions seem valid. A bounding box
without a buffer seems more likely to lead to errors.
Very nice detective work!!
S
Sent via phone.
On Mon, Apr 29, 2019, 8:05 AM Niels Dekker notifications@github.com wrote:
Just discussed with @kaspermarstal https://github.com/kaspermarstal and
@stefanklein https://github.com/stefanklein at our Elastix/SuperElastix
sprint meeting. We would like to see a bounding box of [3.5, 5.5, 3.5,
5.5] in this case. So in general, taking the size of the border pixels
into account. What do you think?Somewhat related topic:
https://discourse.itk.org/t/imagemaskspatialobject-isinside-less-than-half-a-pixel-away/1807—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/InsightSoftwareConsortium/ITK/issues/753#issuecomment-487553397,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACEJL67BBVYAXMYJSQC3WLPS3QB5ANCNFSM4HHXP2CA
.
@N-Dekker has this issue been addressed?
@thewtex Indeed, Matt! Pull request #789 does the job! I'll close the issue!
Most helpful comment
Hi
I think returning a continuous index or an index that has a buffer is
appropriate .
So either the 3.5,5.5 or the 3,6 solutions seem valid. A bounding box
without a buffer seems more likely to lead to errors.
Very nice detective work!!
S
Sent via phone.
On Mon, Apr 29, 2019, 8:05 AM Niels Dekker notifications@github.com wrote: