<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<div>Dear all, </div><div><br></div><div>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.</div><div><br></div><div><br></div><div>// I first get the DCM from the fixedImage</div><div>FixedImageType::DirectionType directionCosines = fixedImage->GetDirection();</div><div><br></div><div><br></div><div> std::cout << "Input DCM is " << std::endl;</div><div> std::cout << directionCosines << std::endl;</div><div><br></div><div><div style="text-indent: 0in !important; ">//Terminal shows:</div><div style="text-indent: 0in !important; ">//1 0 0</div><div style="text-indent: 0in !important; ">//0 -1 0</div><div style="text-indent: 0in !important; ">//0 0 1</div></div><div><br></div><div> directionCosines[0][0] = 1;</div><div> directionCosines[0][1] = 0;</div><div> directionCosines[0][2] = 0;</div><div> directionCosines[1][0] = 0;</div><div> directionCosines[1][1] = 1;</div><div> directionCosines[1][2] = 0;</div><div> directionCosines[2][0] = 0;</div><div> directionCosines[2][1] = 0;</div><div> directionCosines[2][2] = 1;</div><div><br></div><div> std::cout << directionCosines << std::endl;</div><div><br></div><div><div style="text-indent: 0in !important; ">//Terminal shows:</div><div style="text-indent: 0in !important; ">//1 0 0</div><div style="text-indent: 0in !important; ">//0 1 0</div><div style="text-indent: 0in !important; ">//0 0 1</div></div><div><br></div><div><br></div><div>//Then I reset the direction to identity</div><div> fixedImageReader->GetOutput()->SetDirection(directionCosines);</div><div> </div><div> std::cout << "New DCM is " << std::endl;</div><div> std::cout << fixedImageReader->GetOutput()->GetDirection() << std::endl;</div><div><br></div><div><div style="text-indent: 0in !important; ">//Terminal shows:</div><div style="text-indent: 0in !important; ">//1 0 0</div><div style="text-indent: 0in !important; ">//0 1 0</div><div style="text-indent: 0in !important; ">//0 0 1</div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; ">//Then I write the new image with the identity DCM</div><div style="text-indent: 0in !important; "><div style="text-indent: 0in !important; "> caster->SetInput( fixedImageReader->GetOutput() );</div><div style="text-indent: 0in !important; "> writer->SetInput( caster->GetOutput() );</div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; ">//Then I read in the new image again to print its DCM</div><div style="text-indent: 0in !important; "><div style="text-indent: 0in !important; "> outputImageReader->SetFileName( argv[2] );</div><div style="text-indent: 0in !important; "> OutputImageType::ConstPointer outputImage = outputImageReader->GetOutput();</div><div style="text-indent: 0in !important; "> outputImageReader->Update();</div><div style="text-indent: 0in !important; "> OutputImageType::DirectionType directionCosinesOutput = outputImage->GetDirection();</div><div style="text-indent: 0in !important; "> std::cout << "Output DCM is " << std::endl;</div><div style="text-indent: 0in !important; "> std::cout << directionCosinesOutput << std::endl;</div><div style="text-indent: 0in !important; "><br></div><div style="text-indent: 0in !important; ">//Terminal shows:</div><div style="text-indent: 0in !important; ">//1 0 0</div><div style="text-indent: 0in !important; ">// 0 -1 0</div><div style="text-indent: 0in !important; ">//0 0 1</div></div></div></div><br>--------------------------------<br>Xi Liang<br><br>ÁºÜç<br>--------------------------------<br><br><br>                                            <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>