[Insight-users] Re sampler filter giving blank output

superzz jxdw_zlf at yahoo.com.cn
Tue Nov 10 21:11:33 EST 2009


Hello Luis Ibanez
Your aalImageProcessor is very helpful. Thank you.

I am trying to mapping the output point to input point using
transform->TransformPoint. But the result is apparently incorrect. For
example, execute translatedPoint = transform->TransformPoint(centralPoint)
to translate the centralPoint previously calculated. translatedPoint[1] is
negative. It should be positive.

Is TransformPoint the correct API to mapping output point to input point.

Thanks!

superZZ


Luis Ibanez wrote:
> 
> Hi Andrea,
> 
> It is good to hear that it works fine now.
> 
> To resize, (Scaling), you just need to follow the same process.
> 
> That is, calling one of the Scaling methods in the AffineTransform
> should be enough...
> 
> 
>      Regards,
> 
> 
>            Luis
> 
> 
> -------------------------------------------------
> On Tue, Oct 13, 2009 at 4:45 PM, darkflame2000 at libero.it
> <darkflame2000 at libero.it> wrote:
>> Thank you very much...
>>
>> It works good...
>>
>> Now to resize is it sufficient to set something similar??? For example
>> the method setmatrix applied to the transform???
>>
>> Bye
>>
>> Andrea
>>
>>
>>
>>
>>
>>> Hi Andrea
>>>
>>> Thanks for sending your code.
>>> It was very helpful.
>>>
>>> Here is what happens:
>>>
>>> You input image has a Direction Cosines matrix
>>> that is not an Identity.
>>>
>>> Instead it is:
>>>
>>>   Direction:
>>>               1 0 0
>>>               0 -1 0
>>>               0 0 1
>>>
>>> However, your computation of the image
>>> center in the function that performs the
>>> rotation was done as:
>>>
>>>       double imageCenter[3];
>>>       imageCenter[0] = origin[0] + spacing[0] * size[0] / 2.0;
>>>       imageCenter[1] = origin[1] + spacing[1] * size[1] / 2.0;
>>>       imageCenter[2] = origin[2] + spacing[2] * size[2] / 2.0;
>>>
>>> This way of computing the center physical coordinates
>>> is only valid with the Direction Cosines matrix is an identity.
>>>
>>> In general the computation should be (in vectors):
>>>
>>>           center = origin + DM * SP * Index
>>>
>>> where
>>>
>>> DM = Direction cosines
>>> SP = Spacing (diagonal) matrix
>>>
>>> The simple fix, is to replace the computation of the
>>> center above with:
>>>
>>>  AtlasImageType::IndexType centralIndex;
>>>
>>>   centralIndex[0] = size[0] / 2.0;
>>>   centralIndex[1] = size[1] / 2.0;
>>>   centralIndex[2] = size[2] / 2.0;
>>>
>>>   AtlasImageType::PointType centralPoint;
>>>
>>>   InputImage->TransformIndexToPhysicalPoint( centralIndex, centralPoint
>>> );
>>>
>>>
>>> The image method TransformIndexToPhysicalPoint() will take
>>> into account the image: Origin, Spacing, and Direction Cosines.
>>>
>>> The problem that you were observing was due to the fact
>>> that the previous computation of the image center was actually
>>> setting the center physical coordinates outside of the physical
>>> extent of the image.
>>>
>>> Therefore, as you rotated the image, it was moved away from
>>> the extent of the grid where you could see any of its pixels.
>>>
>>> ---
>>>
>>> Please note also that you can simplify / improve the API
>>> of your functions by passing the second smart pointer by
>>> reference. In this way you don't have to Graft() the output
>>> image in it.
>>>
>>> Please find attached the modified files
>>>
>>>    * aalImageProcessor.h
>>>    * aalImageProcessor.cpp
>>>
>>>
>>> Please give them a try and let us know if you find
>>> any residual problem.
>>>
>>>
>>>      Thanks
>>>
>>>
>>>             Luis
>>>
>>
>>
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 

-- 
View this message in context: http://old.nabble.com/Resampler-filter-giving-blank-output-tp25801238p26294441.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list