<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>> Date: Fri, 12 Feb 2010 09:03:51 -0500<br>> Subject: Re: [Insight-users] fail to change the Direction Cosine Matrix to         identity<br>> From: luis.ibanez@kitware.com<br>> To: liangxi1986317@hotmail.com<br>> CC: insight-users@itk.org<br>> <br>> Hi Xi,<br>> <br>> You should not attempt to modify directly the information of an<br>> image that is generated as the output of a filter (or a reader).<br>> <br>> <br>> What you should do, is to use the<br>> <br>> itkChangeInformationImageFilter<br>> <br>> <br>> Connect this filter to the output of the reader and make sure<br>> that you call ChangeDirectionOn() in the filter before you<br>> call Update()<br>> <br>> <br>> BTW: changing the direction of a medical image can<br>> be a dangerous thing to do. You should make sure<br>> that you have a good justification for replacing the<br>> direction of the original image.<br>> <br>> <br>> <br>> Regards,<br>> <br>> <br>> <br>> Luis<br>> <br>> <br>> -------------------------------------------------------------------<br>> 2010/2/12 Xi LIANG <liangxi1986317@hotmail.com>:<br>> > Dear all,<br>> > I am trying to change an image direction cosine matrix to identity by using<br>> > the following code, but it fails. I read in an input image and set its DCM<br>> > to identity, then I write it to a new image and then print out its DCM<br>> > again. However, the DCM in the new image is not identity matrix. I am not<br>> > sure what was wrong in my code, and the following are the major part related<br>> > to this.<br>> ><br>> > // I first get the DCM from the fixedImage<br>> > FixedImageType::DirectionType directionCosines = fixedImage->GetDirection();<br>> ><br>> > std::cout << "Input DCM is " << std::endl;<br>> > std::cout << directionCosines << std::endl;<br>> > //Terminal shows:<br>> > //1 0 0<br>> > //0 -1 0<br>> > //0 0 1<br>> > directionCosines[0][0] = 1;<br>> > directionCosines[0][1] = 0;<br>> > directionCosines[0][2] = 0;<br>> > directionCosines[1][0] = 0;<br>> > directionCosines[1][1] = 1;<br>> > directionCosines[1][2] = 0;<br>> > directionCosines[2][0] = 0;<br>> > directionCosines[2][1] = 0;<br>> > directionCosines[2][2] = 1;<br>> > std::cout << directionCosines << std::endl;<br>> > //Terminal shows:<br>> > //1 0 0<br>> > //0 1 0<br>> > //0 0 1<br>> ><br>> > //Then I reset the direction to identity<br>> > fixedImage Reader->GetOutput()->SetDirection(directionCosines);<br>> ><br>> > std::cout << "New DCM is " << std::endl;<br>> > std::cout << fixedImageReader->GetOutput()->GetDirection() << std::endl;<br>> > //Terminal shows:<br>> > //1 0 0<br>> > //0 1 0<br>> > //0 0 1<br>> ><br>> ><br>> > //Then I write the new image with the identity DCM<br>> > caster->SetInput( fixedImageReader->GetOutput() );<br>> > &nbsp ; writer->SetInput( caster->GetOutput() );<br>> ><br>> > //Then I read in the new image again to print its DCM<br>> > outputImageReader->SetFileName( argv[2] );<br>> > OutputImageType::ConstPointer outputImage =<br>> > outputImageReader->GetOutput();<br>> > outputImageReader->Update();<br>> > OutputImageType::DirectionType directionCosinesOutput =<br>> > outputImage->GetDirection();<br>> > std::cout << "Output DCM is " << std::endl;<br>> > std::cout << directionCosinesOutput << std::endl;<br>> > //Terminal shows:<br>> > //1 0 0<br>> > // 0 -1 0<br>> > //0 0 1<br>> > --------------------------------<br>> > Xi Liang<br>> ><br>> > ÁºÜç<br>> > --------------------------------<br>> ><br>> ><br>> ><br>> > ________________________________<br>> > Hotmail: Trusted email with Microsoft's powerful SPAM protection. Sign up<br>> > now.<br>> > _____________________________________<br>> > Powered by www.kitware.com<br>> ><br>> > Visit other Kitware open-source projects at<br>> > http://www.kitware.com/opensource/opensource.html<br>> ><br>> > Kitware offers ITK Training Courses, for more information visit:<br>> > http://www.kitware.com/products/protraining.html<br>> ><br>> > Please keep messages on-topic and check the ITK FAQ at:<br>> > http://www.itk.org/Wiki/ITK_FAQ<br>> ><br>> > Follow this link to subscribe/unsubscribe:<br>> > http://www.itk.org/mailman/listinfo/insight-users<br>> ><br>> ><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>