[Insight-users] Problems with ImageMaskSpatialObject
Markus Mehrwald
mehrwald at ira.uka.de
Tue Feb 20 12:54:31 EST 2007
Hi,
I just implemented some code which uses a ImageMaskSpatialObject. I
created a binary image in my filter chain and want this now to be a
spatial object so I use the SetImage method of the spatial object but
nothing happens. The output of the object looks good. Coordinates (,
...) are correct but at every point of the so created object ValueAt
gives me 0. The code looks like the following:
thresholder->Update();
ImageMaskSpatialObjectType::PointType point;
imageMaskSpatialObject = ImageMaskSpatialObjectType::New();
imageMaskSpatialObject->SetImage(thresholder->GetOutput());
imageMaskSpatialObject->SetRequestedRegion(thresholder->GetOutput()->GetRequestedRegion());
imageMaskSpatialObject->Update();
imageMaskSpatialObject->UpdateOutputInformation();
imageMaskSpatialObject->ComputeObjectToWorldTransform();
double ret;
for (int i = 0; i < 640; i++)
{
for (int j = 0; j < 512; j++)
{
point[0] = i;
point[1] = j;
imageMaskSpatialObject->ValueAt(point, ret);
if (ret != 0)
std::cout << "ret: " << ret << std::endl;
}
}
The image coming from the thresholder has indeed a size of 300x280 but
changing the for-loops has no consequence on the outcome.
I took a look at the image coming from the thresholder and it is what it
should be, a binary image with white areas too. The code above never
writes anything to the standard output because it does not find any
values differing to 0.
Did I anything wrong or is it a problem of the ImageMaskSpatialObject?
Thanks in advance,
Markus
More information about the Insight-users
mailing list