[Insight-users] Problem with TransformPoint
Clemens M. Hentschke
cmh at isg.cs.uni-magdeburg.de
Thu Mar 1 08:39:40 EST 2012
Hi,
I want to transform points with the TransformPoint() method from one
coordinate system (moving image) to another coordinate system (fixed image).
So far, I checked the transformation works fine by applying it to the
image, the result image was as I expected correct.
As I am only interested in single pixels (and their respective
transformed coordinates), I only used the TransformPoint() method of
Similarity3DTransform insted of transforming the whole image.
I converted from pixel to physical coordinates on the moving image,
transformed this coordinates and converted the physical coordinates to
pixel coordinates on the fixed image.
However, the pixels from the moving image do not correspond to the fixed
image.
I use ITK 3.20 with Windows 7 and the MinGW compiler.
Has anyone an idea what the problem may could be?
Thanks in advance.
I attached a code snippet:
typedef TransformType::InputPointType CenterType;
typedef itk::Similarity3DTransform<double> TransformType;
TransformType::Pointer transform =TransformType::New();
CenterType center;
center[0] = 3.3874403492;
center[1] = -17.7840881162;
center[2] = 50.2830146457;
transform->SetCenter(center); // setting the center coordinates
manually
readerMoving->Update();
readerFixed->Update();
ImageType::Pointer mImage = readerMoving->GetOutput(); //the
moving image
ImageType::Pointer fImage = readerFixed->GetOutput(); //the fixed
image
TransformType::ParametersType
paramsInput(transform->GetNumberOfParameters());
paramsInput[0] = 0.244805;
paramsInput[1] = 0.009105;
paramsInput[2] = -0.056415;
paramsInput[3] = -7.963562;
paramsInput[4] = -29.462040;
paramsInput[5] = 61.358929;
paramsInput[6] = 0.981010;
transform->SetParameters(paramsInput); //setting the parameters
manually
ImageType::IndexType indexIn;
indexIn[0] = 162; //some sample pixel from the moving image
indexIn[1] = 218;
indexIn[2] = 81;
TransformType::InputPointType pt;
mImage->TransformIndexToPhysicalPoint(indexIn, pt);
TransformType::OutputPointType output =
transform->TransformPoint(pt);
ImageType::IndexType indexOut;
fImage->TransformPhysicalPointToIndex(output, indexOut);
for (int i=0; i<3; i++)
cout << indexOut[i] << endl; //the output coordinates are
obviously wrong, they do NOT match to the input (moving image) coordinates
More information about the Insight-users
mailing list