<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><br>> What file format are you using for storing the images ?<br style="text-indent: 0in !important; ">> <br style="text-indent: 0in !important; ">> That is, what is the extension of the filename that you<br style="text-indent: 0in !important; ">> are passing as the second command line argument to<br style="text-indent: 0in !important; ">> your program ?</div><div><br></div><div>I am using .hdr</div><div><br></div><div>Regards,</div><div><br>--------------------------------<br>Xi Liang<br><br>ÁºÜç<br>--------------------------------<br><br><br><br><br>> Date: Mon, 15 Feb 2010 18:04:09 -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; m.staring@lumc.nl; njuptlw@163.com<br>> <br>> Hi Xi,<br>> <br>> <br>> The problem seems to be in the writer / reader that<br>> is used for the writing and reading the changed image.<br>> <br>> <br>> What file format are you using for storing the images ?<br>> <br>> That is, what is the extension of the filename that you<br>> are passing as the second command line argument to<br>> your program ?<br>> <br>> <br>> Please let us know,<br>> <br>> <br>> Thanks<br>> <br>> <br>> Luis<br>> <br>> <br>> ------------------------------------------------------------------------------------------<br>> 2010/2/15 Xi LIANG <liangxi1986317@hotmail.com>:<br>> > Hi all,<br>> > I wrote 2 pieces of code to change the direction to identity. The idea of<br>> > the program is to read in the input image and only change its direction, and<br>> > then write the resulting image into output. Those code is attached with the<br>> > email.<br>> ><br>> > However, both of them cannot change the direction to identity and generate<br>> > the same unrelated directions. One method is<br>> > though itkChangeInformationImageFilter suggested by Luis, and the other is<br>> > using ResampleImageFilter suggested by another ITK user.<br>> ><br>> > By using those two methods, I got the same wired result. The direction of<br>> > the output image is different from input image direction and is not identity<br>> > direction neither. I am not sure why the direction in the filter is<br>> > identity, but it generates a totally unrelated direction in writer. The<br>> > followings are direction shows the directions in Input/filter/output<br>> > images.<br>> ><br>> > Input image DCM:<br>> > 1 0 0<br>> > 0 -1 0<br>> > 0 0 1<br>> > DCM got from the filter<br>> > 1 0 0<br>> > 0 1 0<br>> > 0 0 1<br>> > Output image DCM:<br>> > 1 0 0<br>> > 0 0 -1<br>> > 0 1 0<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<br>> >> 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<br>> >> > using<br>> >> > the following code, but it fails. I read in an input image and set its<br>> >> > 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<br>> >> > not<br>> >> > sure what was wrong in my code, and the following are the major part<br>> >> > related<br>> >> > to this.<br>> >> ><br>> >> > // I first get the DCM from the fixedImage<br>> >> > FixedImageType::DirectionType directionCosines =<br>> >> > 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<br>> >> > 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>> ><br>> > ________________________________<br>> > Hotmail: Powerful Free email with security by Microsoft. Get it now.<br></div>                                            <br /><hr />Hotmail: Trusted email with Microsoft¡¯s powerful SPAM protection. <a href='https://signup.live.com/signup.aspx?id=60969' target='_new'>Sign up now.</a></body>
</html>