[Insight-users] Problems with ImageMaskSpatialObject

Markus Mehrwald mehrwald at ira.uka.de
Tue Mar 6 05:26:07 EST 2007


In addition to that the offset to compute ObjectToWorldTransform is 
completely ignored. Maybe I am wrong with the origin and the offset but 
I thing ignoring the offset for world transform should not happen, 
should it?

Markus Mehrwald schrieb:
> Hi,
>
> I just had a look at the code of the ImageSpatialObject. In the method 
> SetImage there is code to compute the offset of the spatial object. In 
> my mind it should be better to use the index of the RequestedRegion 
> instead of the origin because in my case this is the image I want the 
> spatial object from. In case of having the whole image origin and the 
> index of the RequestedRegion are the same anyway.
>
> Regards,
> Markus Mehrwald
>
> Markus Mehrwald schrieb:
>> Hi Julien,
>>
>> I do not really need ValueAt() at the moment. I used this code just 
>> for debug reasons. As I wrote before I have created my binary image 
>> first and than want it as spatial object to save it because if I only 
>> save the image the translation information is gone. At the moment I 
>> need ValueAt() I do not have the translation information anymore 
>> (after a restart of the application and without calculating 
>> everything again).
>> I have tried some other things with transform and offsets but the 
>> only case in which I get the correct result (but without translation) 
>> is if the image passed to the ImageMaskSpatialObject has its origin 
>> at 0,0.
>>
>> Greetings,
>> Markus
>>
>> Julien Jomier schrieb:
>>> 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
>>>>
>>>>
>>>
>>
>>
>
>


-- 
---------------------------------------------------------
Cand. Dipl.-Inf. Med. Markus Mehrwald
Institut für Prozessrechentechnik, Automation und Robotik

Universität Karlsruhe (TH)
Gebäude 40.28
Engler-Bunte-Ring 8
76131 Karlsruhe

E-Mail: mehrwald at ira.uka.de
---------------------------------------------------------



More information about the Insight-users mailing list