[Insight-users] Applying a transform to the orientation/origin of an image

max power zouookmoetenwerken at gmail.com
Mon Feb 7 09:56:40 EST 2011


Hi all,

I'm trying to transform an image based on a rigid euler 3d transform
that is generated by our code by matching some landmarks.  Normally
I'd resample, but in this case, I would like to just 'impose' this
transform onto the orientation of the image, so that I can use it
in-place.

My guess is that ChangeInformationImageFilter is the key component
here, but I'm not 100% sure that I understand all the intrinsics of
applying a transform to both the origin/center as well as the
directions of an image.

Lets assume I've succesfully built a VersorRigid3DTransform transform,
by feeding a number of landmark points in _physical space_ to a
LandmarkBasedTransformInitializer.

Would something along these lines make sense:

    typedef itk::ChangeInformationImageFilter< ImageType > ChangerType;
    ChangerType::Pointer ch = ChangerType::New();
    ch->SetInput( image );

    ch->SetOutputOrigin( transform->GetTransform()->TransformPoint(
image->GetOrigin() ));

    ImageType::DirectionType dir = image->GetDirection() *
transform->GetMatrix();
    ch->SetOutputDirection( dir );

    ch->SetChangeDirection( true );
    ch->SetChangeOrigin( true );
    ch->Update();

I guess I'm on the right path, but applying the transform like above
does not work, even after fiddling extensively with the order of the
operations (or even applying inverses).  The resulting images do not
seem to match my generated transform at all.

I hope to find a way so that the following holds, where old_image is
the untransformed image, and new_image is the output of the
changeinformation filter:

   transform.transformpoint( old_image.indextophysical( p ) ) ~=
new_image.indextophysical( p )

Any tips on how to approach this would be most welcome!

Regards,
Jorik


More information about the Insight-users mailing list