[Insight-users] Similarity3Dtransform
zhixi
liZhixi at cc.nih.gov
Tue Nov 13 17:52:26 EST 2007
Hello,
I am attempting to rescale a CT image in its physical space while keeping
the same number of voxels. My image is 512 x 512 x 220 voxels (spacing:
0.584 x 0.584 x 1.0)
the image is all blank (intensity 0) with the exception of an organ of
interest, with center of gravity at (275.545, 207.088, -60.5004) mm CT
scanner coordinates, set at intensity of 100.
I wish to rescale the image so that the organ is 1.2 times its current
physical size, without changing the voxel spacing or image dimensions of 512
x512x 220.
my strategy is to use the similarity3dtransform but I'm having some trouble
understanding how the setScale parameter works, as well as how to set the
center of scaling.
I notice that when I input a value of say: 1.2 for the scalar, the organ
actually becomes smaller in the resampled image, whereas if I input 0.8, the
organ is enlarged.
Ideally, after scaling my image, the organ would be 1.2 times larger in
volume but its center of gravity would be located in the same position as
before. Is this possible? Or will I have to manually reposition the organ
after the transform?
my main questions:
1. how is the scale parameter used in the similarity3dtransform? my
assumption is that the parameter^3 = the factor by which the image changes
in size, but I don't think this is accurate.
where the scaling matrix is:
p 0 0
0 p 0
0 0 p
2. how do I set the center of my transform? ideally, I would like to
transform my image from the center of gravity of my organ, which I could
find and input.
here is my code:
typedef itk::Image< float, 3 > ImageType_3D;
ImageType_3D::Pointer ITKim_3D1 = ImageType_3D::New();
ImageType_3D::Pointer ITKim_3D2 = ImageType_3D::New();
Copy_CISImage_to_ITKImage(img3Din1, ITKim_3D1);
Copy_CISImage_to_ITKImage(img3Din2, ITKim_3D2);
typedef itk::NearestNeighborInterpolateImageFunction<ImageType_3D, double >
InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
typedef itk::Similarity3DTransform<double>TransformType;
TransformType::Pointer transform = TransformType::New();
typedef itk::ImageRegistrationMethod< ImageType_3D, ImageType_3D >
RegistrationType;
Here is where I input the scale parameter:
float scale;
std::cout<<"Enter an value for the scale factor\n";
std::cin>>scale;
transform->SetScale(scale);
TransformType::InputPointType rotationCenter;
const ImageType_3D::SpacingType&
spacing = ITKim_3D1->GetSpacing();
std::cout<<"spacing ="<<std::ends;
std::cout<<spacing<<std::endl;
const ImageType_3D::PointType&
origin = ITKim_3D1->GetOrigin();
std::cout<<"origin ="<<std::ends;
std::cout<<origin<<std::endl;
ImageType_3D::SizeType size =
ITKim_3D1->GetLargestPossibleRegion().GetSize();
std::cout<<"size ="<<std::ends;
std::cout<<size<<std::endl;
This is my botched attempt to set an image origin at the center of gravity
of my organ (measured in ct coordinates mm), CentM is gained via a previous
function in my code, (275.545, 207.088, -60.5004).
rotationCenter[0] = centM.x;
rotationCenter[1] = centM.y;
rotationCenter[2] = centM.z;
std::cout<<"rotationCenter ="<<rotationCenter<<std::ends;
transform->SetCenter( rotationCenter );
typedef itk::ResampleImageFilter< ImageType_3D, ImageType_3D >
ResampleFilterType;
TransformType::Pointer finalTransform = TransformType::New();
finalTransform->SetParameters( transform->GetParameters() );
ResampleFilterType::Pointer resample = ResampleFilterType::New();
resample->SetTransform( finalTransform );
resample->SetInput( ITKim_3D1);
resample->SetSize( ITKim_3D1->GetLargestPossibleRegion().GetSize() );
resample->SetOutputOrigin( ITKim_3D1->GetOrigin() );
resample->SetOutputSpacing( ITKim_3D1->GetSpacing() );
resample->SetDefaultPixelValue( 0 );
resample->SetInterpolator( interpolator );
resample->Update();
Copy_ITKImage_to_CISImage(resample->GetOutput(), img3Dout );
// Write_Analyze_File("scaled.hdr",*img3Dout);
std::cout<<"scaled image origin ="<<std::ends;
std::cout<<resample->GetOutput()->GetOrigin()<<std::endl;
std::cout<<"scaled image spacing ="<<std::ends;
std::cout<<resample->GetOutput()->GetSpacing()<<std::endl;
std::cout<<"scaled image size ="<<std::ends;
std::cout<<resample->GetOutput()->GetLargestPossibleRegion().GetSize()<<std::endl;
}
Any help is deeply appreciated
Thank you!
Zhixi Li
--
View this message in context: http://www.nabble.com/Similarity3Dtransform-tf4801091.html#a13736442
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list