[ITK] [ITK-users] Resampling after SetDirection() and SetOrigin()

Matt McCormick matt.mccormick at kitware.com
Sun Jun 29 22:28:03 EDT 2014


Hi Mathew,

The image does not retain the original parameters somewhere.  However,
can must be take, because if the image is generated by a filter in a
pipeline, that filter will reset the original value when the pipeline
is re-run. ChangeInformationImageFilter will ensure this reset does
not happen during a pipeline update.

The Set methods doo reorient/reposition the whole image volume in
world space.  The resampling filter does not select a subregion or
rotates the images -- to get the same out, the  sampling locations of
the output image for the ResampleImageFilter must be set as desired.
Set SetOutputOrigin [1], SetOutputDirection [2], etc.

Hope this helps to clarify.

I checked by wrapped install, and I have ChangeInformationImageFilter
instantiations for float images.

Hope this helps,
Matt

[1] http://www.itk.org/Doxygen/html/classitk_1_1ResampleImageFilter.html#ac4b197ddefd3b3344bd9c9471acd5b00

[2] http://www.itk.org/Doxygen/html/classitk_1_1ResampleImageFilter.html#a9fdd6b862ab6cbaa03702da393bd0474


On Sun, Jun 29, 2014 at 10:01 PM, Mathew Guilfoyle
<mrguilfoyle at gmail.com> wrote:
> Matt, thanks for the reply.
>
> I would be grateful if you could you explain why this is the desired
> behaviour.  If I use the SetDirection() or SetOrigin() methods does the
> image object retain the original parameters somewhere?  Subsequently calling
> GetDirection() or GetOrigin() reports the changed parameters.
>
> Intuitively you would expect both Set methods to reorient/reposition the
> whole image volume in world space, and on the face of it that is what they
> seem to do.  However, on passing the image to a resampling filter they act
> to select a subregion or to rotate the image. I would have thought that
> rotations and region selections should be options passed to the filter and
> not set in the image itself?
>
> How does the ChangeInformationImageFilter do it differently?  Incidentally I
> have wrapped for float but don't get this as an option for this filter.
>
> Thanks
> Mathew
>
>
>
> On 30 June 2014 01:45, Matt McCormick <matt.mccormick at kitware.com> wrote:
>>
>> Hi Mathew,
>>
>> Yes, that is the correct and expected behavior. I do not know if
>> ImageJ is using the actual location in world space.
>>
>> It sounds like ChangeInformationImageFilter is what you are looking
>> for.  It will be wrapped for float images if wrapped for float images
>> is enabled in you CMake configuration (ITK_WRAP_float).
>>
>> Hope this helps,
>> Matt
>>
>>
>> On Sat, Jun 28, 2014 at 9:55 PM, Mathew Guilfoyle <mrguilfoyle at gmail.com>
>> wrote:
>> > If I change an image's direction and origin using SetDirection() and
>> > SetOrigin() methods and then write the image back to a file, the volume
>> > stack viewed in (e.g.) ImageJ is unchanged.  This is the behaviour I
>> > would
>> > expect as changing the direction and origin shouldn't alter the array of
>> > image pixels, just its location and orientation in 'world space'?
>> >
>> > However, if I take the same image, adjust the origin and direction as
>> > before, and then input it to ResampleImageFilter with an identity
>> > transform
>> > (and set spacing, origin, direction, and size to those of the input
>> > image)
>> > the output is a translated and rotated image.
>> >
>> > It seems the difference between the original and adjusted origin and
>> > direction are applied as a translation and rotation during resampling,
>> > even
>> > though GetOrigin() and GetDirection() on the input image to the
>> > resampler
>> > return the adjusted parameters.
>> >
>> > Is this the expected behaviour? Is there another image parameter that
>> > needs
>> > to be changed to correctly alter origin and direction?
>> >
>> > (ChangeInformationImageFilter is not wrapped for float images so I can't
>> > use
>> > it for my application)
>> >
>> > Thanks
>> >
>> > _____________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Kitware offers ITK Training Courses, for more information visit:
>> > http://www.kitware.com/products/protraining.php
>> >
>> > 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://public.kitware.com/mailman/listinfo/insight-users
>> >
>> > _______________________________________________
>> > Community mailing list
>> > Community at itk.org
>> > http://public.kitware.com/mailman/listinfo/community
>> >
>
>



More information about the Community mailing list