[Insight-users] Problems with ImageMaskSpatialObject
Julien Jomier
julien.jomier at kitware.com
Wed Feb 21 08:11:20 EST 2007
Hi Markus,
Can you take into account the origin of your image when you request the
ValueAt()?
If you are using the SpatialObjectToImageFilter to create your binary
image you can set the origin of the output image, if you set it to the
same origin as the input image then it should work.
One other option is to reset the IndexToObjectTransform of your
ImageMaskSpatialObject with an offset of zero:
myImageSO->GetIndexToObjectTransform()->SetOffset( offset );
myImageSO->ComputeObjectToParentTransform();
This will not modify the origin of the image passed using the SetImage()
function so you can use it later.
Hope that helps,
Julien
Markus Mehrwald wrote:
> Hi,
>
> I found the problem. The image starts at 180, 130 and that is the
> problem. If I translate the image to 0, 0 the code from my last mail
> works correct. The problem now: I need the information of the
> translation for further calculations.
> Any suggestions how to keep the translation? I tried
>
> ImageMaskSpatialObjectType::TransformType::OffsetType offset;
> offset[0] = thresholder->GetOutput()->GetRequestedRegion().GetIndex()[0];
> offset[1] = thresholder->GetOutput()->GetRequestedRegion().GetIndex()[1];
> imageMaskSpatialObject->GetObjectToParentTransform()->SetOffset(offset);
> imageMaskSpatialObject->ComputeObjectToParentTransform();
>
> but this leads to the same problem I had before. Also with WorldTransform.
>
> Greetings,
> Markus
>
> Markus Mehrwald schrieb:
>> 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
>> _______________________________________________
>> 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