[Insight-users] Using ScaleTransform to stretch an image

Dan Mueller dan.muel at gmail.com
Thu Nov 10 22:46:05 EST 2011


Hi David,

> 1) It seems like the scale is inverse of what I would expect? That is,
> I set the scale to 1.5 and the image seemed to get smaller?
Yes, I have the same experience. Not sure if it is a misunderstanding
on my/our side, or incorrectly implemented (probably the first :D).

> 2) In this example I draw a square in the center of the image as well
> as highlight the border of the image. In the reduced (scaled) image,
> only half of the border is visible. Can you explain this?
Could be an interpolation issue?? Consider using a Nearest Neighbor
interpolator.

Cheers, Dan

On 10 November 2011 22:34, David Doria <daviddoria at gmail.com> wrote:
> Hi Dan -
>
> Just to finish this up, I tried to make an example of the ScaleTransform.
>
> http://www.itk.org/Wiki/ITK/Examples/WishList/ImageProcessing/ScaleTransform
>
> 1) It seems like the scale is inverse of what I would expect? That is,
> I set the scale to 1.5 and the image seemed to get smaller?
>
> 2) In this example I draw a square in the center of the image as well
> as highlight the border of the image. In the reduced (scaled) image,
> only half of the border is visible. Can you explain this?
>
> Thanks,
>
> David
>
>
>
> On Wed, Nov 9, 2011 at 2:07 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>> Hi David,
>>
>>> 1) When would you use a ScaleTransform?
>> ScaleTransform is useful when you want to keep the same output size.
>>
>>> 2) Why did you call DisconnectPipeline a couple of times?
>> Just a habit of mine to make sure the upstream pipeline is not
>> re-executed. In this situation is probably not required, but as I said
>> it's a habit. Sorry for the confusion.
>>
>> HTH
>>
>> Cheers, Dan
>>
>> On 10 November 2011 00:08, David Doria <daviddoria at gmail.com> wrote:
>>> On Tue, Nov 8, 2011 at 3:51 PM, Dan Mueller <dan.muel at gmail.com> wrote:
>>>> Hi David,
>>>>
>>>> Aha. After closer inspection I see that you are forgetting the concept
>>>> of spacing. You need to think carefully about what happens to spacing
>>>> after a scale.
>>>>
>>>> Please find code below which I think does what you want. In fact,
>>>> because you want to change the output size, you don't even need to use
>>>> a ScaleTransform -- an IdentityTransform works just fine.
>>>
>>> Thank you Dan. Just to recap, the idea is:
>>>
>>> 1) Think about the pixels living in a physical space.
>>> 2) Since we set the output size to 200x200, this tells us that we now
>>> have 40,000 pixels, but if the spacing had remained the same, only one
>>> quarter (100x100) would overlap the physical space of the original
>>> 100x100 image.
>>> 3) We change the spacing to 1/2 of the original spacing so that the
>>> new pixels are smaller in the physical space. This means that all
>>> 200x200 now overlap the original image's physical space completely.
>>>
>>> I only have two remaining questions:
>>>
>>> 1) When would you use a ScaleTransform?
>>> 2) Why did you call DisconnectPipeline a couple of times?
>>>
>>> Thanks,
>>>
>>> David
>>>
>>
>


More information about the Insight-users mailing list