<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi Luis,<div><br></div><div>The reason why want to change the direction is that I used MRIcro to draw some mask from a MRI image. However, the mask file has different DCM from the MRI image. Therefore I want to make sure they all have identity DCM.</div><div><br></div><div>Regards,<br><br>--------------------------------<br>Xi Liang<br><br>ÁºÜç<br>--------------------------------<br><br><br><br><br>&gt; Date: Fri, 12 Feb 2010 09:03:51 -0500<br>&gt; Subject: Re: [Insight-users] fail to change the Direction Cosine Matrix to         identity<br>&gt; From: luis.ibanez@kitware.com<br>&gt; To: liangxi1986317@hotmail.com<br>&gt; CC: insight-users@itk.org<br>&gt; <br>&gt; Hi Xi,<br>&gt; <br>&gt; You should not attempt to modify directly the information of an<br>&gt; image that is generated as the output of a filter (or a reader).<br>&gt; <br>&gt; <br>&gt; What you should do, is to use the<br>&gt; <br>&gt;             itkChangeInformationImageFilter<br>&gt; <br>&gt; <br>&gt; Connect this filter to the output of the reader and make sure<br>&gt; that you call ChangeDirectionOn() in the filter before you<br>&gt; call Update()<br>&gt; <br>&gt; <br>&gt; BTW: changing the direction of a medical image can<br>&gt; be a dangerous thing to do. You should make sure<br>&gt; that you have a good justification for replacing the<br>&gt; direction of the original image.<br>&gt; <br>&gt; <br>&gt; <br>&gt;     Regards,<br>&gt; <br>&gt; <br>&gt; <br>&gt;              Luis<br>&gt; <br>&gt; <br>&gt; -------------------------------------------------------------------<br>&gt; 2010/2/12 Xi LIANG &lt;liangxi1986317@hotmail.com&gt;:<br>&gt; &gt; Dear all,<br>&gt; &gt; I am trying to change an image direction cosine matrix to identity by using<br>&gt; &gt; the following code, but it fails. I read in an input image and set its DCM<br>&gt; &gt; to identity, then I write it to a new image and then print out its DCM<br>&gt; &gt; again. However, the DCM in the new image is not identity matrix. I am not<br>&gt; &gt; sure what was wrong in my code, and the following are the major part related<br>&gt; &gt; to this.<br>&gt; &gt;<br>&gt; &gt; // I first get the DCM from the fixedImage<br>&gt; &gt; FixedImageType::DirectionType directionCosines = fixedImage-&gt;GetDirection();<br>&gt; &gt;<br>&gt; &gt;    std::cout &lt;&lt; "Input DCM is " &lt;&lt; std::endl;<br>&gt; &gt;   std::cout &lt;&lt; directionCosines &lt;&lt; std::endl;<br>&gt; &gt; //Terminal shows:<br>&gt; &gt; //1 0 0<br>&gt; &gt; //0 -1 0<br>&gt; &gt; //0 0 1<br>&gt; &gt;   directionCosines[0][0] = 1;<br>&gt; &gt;   directionCosines[0][1] = 0;<br>&gt; &gt;   directionCosines[0][2] = 0;<br>&gt; &gt;   directionCosines[1][0] = 0;<br>&gt; &gt;   directionCosines[1][1] = 1;<br>&gt; &gt;   directionCosines[1][2] = 0;<br>&gt; &gt;   directionCosines[2][0] = 0;<br>&gt; &gt;   directionCosines[2][1] = 0;<br>&gt; &gt;   directionCosines[2][2] = 1;<br>&gt; &gt;   std::cout &lt;&lt; directionCosines &lt;&lt; std::endl;<br>&gt; &gt; //Terminal shows:<br>&gt; &gt; //1 0 0<br>&gt; &gt; //0 1 0<br>&gt; &gt; //0 0 1<br>&gt; &gt;<br>&gt; &gt; //Then I reset the direction to identity<br>&gt; &gt;   fixedImage Reader-&gt;GetOutput()-&gt;SetDirection(directionCosines);<br>&gt; &gt;<br>&gt; &gt;   std::cout &lt;&lt; "New DCM is " &lt;&lt; std::endl;<br>&gt; &gt;   std::cout &lt;&lt; fixedImageReader-&gt;GetOutput()-&gt;GetDirection() &lt;&lt; std::endl;<br>&gt; &gt; //Terminal shows:<br>&gt; &gt; //1 0 0<br>&gt; &gt; //0 1 0<br>&gt; &gt; //0 0 1<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; //Then I write the new image with the identity DCM<br>&gt; &gt;   caster-&gt;SetInput( fixedImageReader-&gt;GetOutput() );<br>&gt; &gt; &amp;nbsp ; writer-&gt;SetInput( caster-&gt;GetOutput()   );<br>&gt; &gt;<br>&gt; &gt; //Then I read in the new image again to print its DCM<br>&gt; &gt;   outputImageReader-&gt;SetFileName(  argv[2] );<br>&gt; &gt;   OutputImageType::ConstPointer outputImage =<br>&gt; &gt; outputImageReader-&gt;GetOutput();<br>&gt; &gt;   outputImageReader-&gt;Update();<br>&gt; &gt;   OutputImageType::DirectionType directionCosinesOutput =<br>&gt; &gt; outputImage-&gt;GetDirection();<br>&gt; &gt;    std::cout &lt;&lt; "Output DCM is " &lt;&lt; std::endl;<br>&gt; &gt;   std::cout &lt;&lt; directionCosinesOutput &lt;&lt; std::endl;<br>&gt; &gt; //Terminal shows:<br>&gt; &gt; //1 0 0<br>&gt; &gt; // 0 -1 0<br>&gt; &gt; //0 0 1<br>&gt; &gt; --------------------------------<br>&gt; &gt; Xi Liang<br>&gt; &gt;<br>&gt; &gt; ÁºÜç<br>&gt; &gt; --------------------------------<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; ________________________________<br>&gt; &gt; Hotmail: Trusted email with Microsoft's powerful SPAM protection. Sign up<br>&gt; &gt; now.<br>&gt; &gt; _____________________________________<br>&gt; &gt; Powered by www.kitware.com<br>&gt; &gt;<br>&gt; &gt; Visit other Kitware open-source projects at<br>&gt; &gt; http://www.kitware.com/opensource/opensource.html<br>&gt; &gt;<br>&gt; &gt; Kitware offers ITK Training Courses, for more information visit:<br>&gt; &gt; http://www.kitware.com/products/protraining.html<br>&gt; &gt;<br>&gt; &gt; Please keep messages on-topic and check the ITK FAQ at:<br>&gt; &gt; http://www.itk.org/Wiki/ITK_FAQ<br>&gt; &gt;<br>&gt; &gt; Follow this link to subscribe/unsubscribe:<br>&gt; &gt; http://www.itk.org/mailman/listinfo/insight-users<br>&gt; &gt;<br>&gt; &gt;<br></div>                                               <br /><hr />Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. <a href='https://signup.live.com/signup.aspx?id=60969' target='_new'>Sign up now.</a></body>
</html>