[Insight-users] SetDirection in itkImage
Alex Taylor
Alex.Taylor at mathworks.com
Fri Jan 18 13:27:28 EST 2013
I have a question about the SetDirection member function of the itkImageBase class. I am attempting to pass image data that is stored in a column major convention to ITK, which is row major. I start with a given definition of X and Y in the column major environment with X pointing in the direction of increasing column indices and Y pointing in the direction of increasing row indices. I want to keep the same coordinate system convention relative to my image data when I construct my images in ITK.
To accomplish this, I believe I want to swap the X and Y direction definitions on my itkImage object as follows:
typename imageType::DirectionType direction = image->GetDirection();
direction[0][0] = 0;
direction[0][1] = 1;
direction[1][0] = 1;
direction[1][1] = 0;
image->SetDirection(direction);
My question is regarding the SetSpacing and SetOrigin methods of the ITKImage object. The documentation for each member function reads:
SETORIGIN
Set the origin of the image. The origin is the geometric coordinates of the image origin (pixel [0,0]). It is stored internally as double but may be set from float.
SETSPACING
Set the spacing (size of a pixel) of the image. The spacing is the geometric distance between image samples along each dimension. It is stored internally as double, but may be set from float. These methods also pre-compute the Index<http://www.itk.org/Doxygen/html/classitk_1_1Index.html> to Physical point transforms of the image.
After I set direction, I call SetOrigin and SetSpacing. Do SetOrigin and SetSpacing expect the origin and spacing in [X Y] order, or are they in the order [SpacingAlongRows, SpacingAlongColumns], [RowOrigin ColumnOrigin]?
typename imageType::DirectionType direction = image->GetDirection();
direction[0][0] = 0;
direction[0][1] = 1;
direction[1][0] = 1;
direction[1][1] = 0;
image->SetDirection(direction);
// Set the origin and inter pixel spacing.
image->SetOrigin(origin);
image->SetSpacing(spacing);
I'm seeing some strange behavior in which the numerics of my registration result are changing as a result of redefining which direction is considered X and which direction is considered Y, with all of the other inputs to registration changed to be consistent with the new X Y definition. I'm wondering whether I'm calling SetOrigin/SetSpacing correctly.
Thanks,
Alex Taylor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130118/f92b784d/attachment.htm>
More information about the Insight-users
mailing list