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

Xi LIANG liangxi1986317 at hotmail.com
Mon Feb 15 04:03:58 EST 2010


Im not sure whether the files attached with the email could be uploaded to the mailist. I hereby post the code tohttp://www.mediafire.com/file/10zdhyz2zyz/setIdentityDirection3D.1.1.cxxhttp://www.mediafire.com/file/jymwteyilyd/setIdentityDirection3D.1.2.cxx

--------------------------------
Xi Liang

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




> Date: Fri, 12 Feb 2010 09:03:51 -0500
> Subject: Re: [Insight-users] fail to change the Direction Cosine Matrix to 	identity
> From: luis.ibanez at kitware.com
> To: liangxi1986317 at hotmail.com
> CC: insight-users at itk.org
> 
> Hi Xi,
> 
> You should not attempt to modify directly the information of an
> image that is generated as the output of a filter (or a reader).
> 
> 
> What you should do, is to use the
> 
>             itkChangeInformationImageFilter
> 
> 
> Connect this filter to the output of the reader and make sure
> that you call ChangeDirectionOn() in the filter before you
> call Update()
> 
> 
> BTW: changing the direction of a medical image can
> be a dangerous thing to do. You should make sure
> that you have a good justification for replacing the
> direction of the original image.
> 
> 
> 
>     Regards,
> 
> 
> 
>              Luis
> 
> 
> -------------------------------------------------------------------
> 2010/2/12 Xi LIANG <liangxi1986317 at hotmail.com>:
> > 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 fixedImage
> > FixedImageType::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
> >   fixedImage Reader->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() );
> > &nbsp ; 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. Sign up
> > now.
> > _____________________________________
> > 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
> >
> >
 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
https://signup.live.com/signup.aspx?id=60969
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100215/7b40d878/attachment.htm>


More information about the Insight-users mailing list