[Insight-users] Resampler filter giving blank output

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 15 13:57:20 EDT 2009


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
>>
>
>


More information about the Insight-users mailing list