[Insight-users] Problem with TransformPoint

Clemens M. Hentschke cmh at isg.cs.uni-magdeburg.de
Mon Mar 5 05:09:03 EST 2012


Thank you very much, your proposed approach worked!

Am 02.03.2012 15:03, schrieb brian avants:
> hi clemens
>
> the transform, when applied to resample a moving image to a fixed
> image,  calls transformpoint on each fixed point to get the
> corresponding moving point.
>
> you might want to try using the inverse of your transform when mapping
> from the moving space to the fixed space.  i.e. your code should be
> almost the same except that you use the inverse transform.
>
>
> brian
>
>
>
>
>
> On Thu, Mar 1, 2012 at 8:39 AM, Clemens M. Hentschke
> <cmh at isg.cs.uni-magdeburg.de>  wrote:
>> 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
>> _____________________________________
>> 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.html
>>
>> 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://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list