[Insight-users] Resampler filter giving blank output
Luis Ibanez
luis.ibanez at kitware.com
Wed Nov 11 17:48:04 EST 2009
Hi SuperZZ
Transformations can be very misleading.
In order to analyze them correctly you MUST take into account
the following:
1) Origin of the image
2) Orientation (direction cosines) of the image
3) Pixel spacing.
In order to help you with your question we will need the
information above, along with the *exact* parameter that
you have in your Transform, and the *exact* values of the
point coordinates that you pass as input to the transform,
and the values of the point coordinates that you get back.
In summary: We need numbers :-)
Thanks
Luis
-----------------------------------------------
On Tue, Nov 10, 2009 at 9:46 PM, <jxdw_zlf at yahoo.com.cn> wrote:
> 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.
>
> BTW: itk mail list always reject my post, I do not know why. So I have to send this rely to user personally mail. Sorry for that.
>
> 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
>>
>>
> Quoted from:
> http://old.nabble.com/Resampler-filter-giving-blank-output-tp25801238p25913235.html
>
>
More information about the Insight-users
mailing list