<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Dear Luis,<div><br></div><div>Thank you very much for this. Finally I realize the format is a big issue for image processing, and this has been confusing me a lot. Could you please suggest a good reference for understanding and analysis on format and head file information, which could show the important parameters that would effect the result significant and how. </div><div><br></div><div>I will post some later if I manage to find any good reference.</div><div><br></div><div>Thank you and regards,<br><br>--------------------------------<br>Xi Liang<br><br>ÁºÜç<br>--------------------------------<br><br><br><br><br>> Date: Mon, 15 Feb 2010 18:08:32 -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>> That explains everything :-)<br>> <br>> <br>> Analyze can only manage some orientations<br>> (only three actually), and the Identity matrix is<br>> not one of them, so it seems to be defaulting<br>> to one of the directions that it actually supports.<br>> <br>> <br>> Please don't use the Analyze fileformat.<br>> <br>> <br>> You may want to use<br>> <br>> * MetaImage (extension ".mha") or<br>> * Nifti (extension ".nii" )<br>> <br>> <br>> Regards<br>> <br>> <br>> Luis<br>> <br>> <br>> <br>> ---------------------------------------------------------------------<br>> 2010/2/15 Xi LIANG <liangxi1986317@hotmail.com>:<br>> > Hi Luis,<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>> > I am using .hdr<br>> > Regards,<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<br>> >> 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>> >> ------------------------------------------------------------------------------------------<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<br>> >> > of<br>> >> > the program is to read in the input image and only change its direction,<br>> >> > and<br>> >> > then write the resulting image into output. Those code is attached with<br>> >> > the<br>> >> > email.<br>> >> ><br>> >> > However, both of them cannot change the direction to identity and<br>> >> > generate<br>> >> > the same unrelated directions. One method is<br>> >> > though itkChangeInformationImageFilter suggested by Luis, and the other<br>> >> > is<br>> >> > using ResampleImageFilter suggested by another ITK user.<br>> >> ><br>> >> > By using those two methods, I got the same wired result. The direction<br>> >> > of<br>> >> > the output image is different from input image direction and is not<br>> >> > 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<br>> >> >> 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<br>> >> >> > its<br>> >> >> > DCM<br>> >> >> > to identity, then I write it to a new image and then print out its<br>> >> >> > 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() <<<br>> >> >> > 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.<br>> >> >> > 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>> ><br>> > ________________________________<br>> > Hotmail: Trusted email with Microsoft¡¯s powerful SPAM protection. Sign up<br>> > 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>