[Insight-users] fail to change the Direction Cosine Matrix to identity

Xi LIANG liangxi1986317 at hotmail.com
Fri Feb 12 02:54:15 EST 2010


Dear all, 
I am trying to change an image direction cosine matrix to identity by using the following code, but it fails. I read in an input image and set its DCM to identity, then I write it to a new image and then print out its DCM again. However, the DCM in the new image is not identity matrix. I am not sure what was wrong in my code, and the following are the major part related to this.

// I first get the DCM from the fixedImageFixedImageType::DirectionType directionCosines = fixedImage->GetDirection();

   std::cout << "Input DCM is " << std::endl;  std::cout << directionCosines << std::endl;
//Terminal shows://1 0 0//0 -1 0//0 0 1
  directionCosines[0][0] = 1;  directionCosines[0][1] = 0;  directionCosines[0][2] = 0;  directionCosines[1][0] = 0;  directionCosines[1][1] = 1;  directionCosines[1][2] = 0;  directionCosines[2][0] = 0;  directionCosines[2][1] = 0;  directionCosines[2][2] = 1;
  std::cout << directionCosines << std::endl;
//Terminal shows://1 0 0//0 1 0//0 0 1

//Then I reset the direction to identity  fixedImageReader->GetOutput()->SetDirection(directionCosines);   std::cout << "New DCM is " << std::endl;  std::cout << fixedImageReader->GetOutput()->GetDirection() << std::endl;
//Terminal shows://1 0 0//0 1 0//0 0 1


//Then I write the new image with the identity DCM  caster->SetInput( fixedImageReader->GetOutput() );  writer->SetInput( caster->GetOutput()   );

//Then I read in the new image again to print its DCM  outputImageReader->SetFileName(  argv[2] );  OutputImageType::ConstPointer outputImage = outputImageReader->GetOutput();  outputImageReader->Update();  OutputImageType::DirectionType directionCosinesOutput = outputImage->GetDirection();   std::cout << "Output DCM is " << std::endl;  std::cout << directionCosinesOutput << std::endl;
//Terminal shows://1 0 0// 0 -1 0//0 0 1
--------------------------------
Xi Liang

梁茜
--------------------------------


 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100212/a0cdce13/attachment.htm>


More information about the Insight-users mailing list