[Insight-users] question about FlipImageFilter and Euler3DTransform

kdsfinger at gmail.com kdsfinger at gmail.com
Sun Jan 7 19:14:16 EST 2007


hi,
I got a strange problem related with FlipImageFilter and/or
Euler3DTransform, let me explain in detail and please help me to fix
it.

Basically, I readin a 3D image called fixedImage and did some
Euler3DTransform to it. Then I update the fixedImage using a
resampler. I also output the fixedImage (call it "aaa.mha") and it
turned and shifted just as expected.

On the second step, I'll flip the updated fixedImage along y axis and
name it movingImage. I'll do a registration based on the fixedImage
and the movingImage. Before doing that, I need to put the movingImage
into the same coordinage as the fixedImage by setting the movingImage
origin to (0,0,0). Here comes the problem:

case 1:
        FlipAxesArrayType flipArray;
	flipArray[0] = 0;
	flipArray[1] = 1;
	flipArray[2] = 0;
	flipFilter->SetFlipAxes( flipArray );
	flipFilter->FlipAboutOriginOff();
	flipFilter->SetInput(fixedImage);
	flipFilter->Update();
	movingImage = flipFilter->GetOutput();
	std::cout<<"flipped moving origin "<<movingImage->GetOrigin()<<std::endl;
	itk::Point<double, 3> p;
	p[0] = 0;
	p[1] = 0;
	p[2] = 0;
	movingImage->SetOrigin(p);
	
	gravityCenterCalculator = ImageMomentsCalculatorType::New();
	gravityCenterCalculator->SetImage(movingImage);
	gravityCenterCalculator->Compute();
	std::cout<<"gravity center of moving image"<<std::endl;
	std::cout<<gravityCenterCalculator->GetCenterOfGravity()<<std::endl;
	gravityCenterCalculator->SetImage(fixedImage);
	gravityCenterCalculator->Compute();
	std::cout<<"gravity center of fixed image"<<std::endl;
	std::cout<<gravityCenterCalculator->GetCenterOfGravity()<<std::endl;
	
	eulerTransform = EulerTransformType::New();
	std::cout<<eulerTransform<<std::endl;
	resampler->SetTransform( eulerTransform );
	resampler->SetInput( movingImage );
	resampler->SetSize( movingImage->GetLargestPossibleRegion().GetSize() );
	resampler->SetOutputSpacing( movingImage->GetSpacing() );
	
	writer =  WriterType::New();
        writer->SetFileName("bbb.mha");
        writer->SetInput( resampler->GetOutput() );
        writer->Update();

I found both the gravity center of the movingImage and fixedImage are
in the possitive range which looks correct. However, the output image
"bbb.mha" is pure black indicating something wrong somewhere, but what
and where? The registration fail since the movingImage is pure 0.

case 2:
No code change for case 1 except add 3 lines of code at the beginning:
        imageReader->SetFileName("aaa.mha");
	imageReader->Update();
	fixedImage = imageReader->GetOutput();

Basically, I save the updated fixedImage to disk as "aaa.mha" via a
resampler, and then readin the "aaa.mha" as fixedImage. In case 1, the
fixedImage is directly got from the resampler.

The gravity center of both fixed and moving image are the same as in
case 1, but now I get the expected figure in "bbb.mha", and the
following registration are all fine.

Can someone explain what happens in the two cases that leads to the
different results? Thanks for comments.

zl2k


More information about the Insight-users mailing list