Hello Frederic,<br><br>thanks for your suggestion.<br><br>although my code was working, I tried your suggestion. Unfortunately, it produces<br><br>error: no match for ‘operator*’ in ‘image.itk::SmartPointer<TObjectType>::operator-> [with TObjectType = itk::Image<float, 3u>]()->itk::ImageBase<VImageDimension>::GetDirection [with unsigned int VImageDimension = 3u] * RotationX’<br>
<br><br>Anyway, I forgot to mention to use:<br><br> float angleX, angleY, angleZ;<br> angleX = angleY = angleZ = 1 * (3.14/180);<br><br>(multiply by pi and divide by 180 degrees, because ITK internally works with radians instead of degrees)<br>
<br>Which leads me to the question: vnl has a pi constant, and I remember vaguely having seen it somewhere as vnl::PI or something.<br>Does anyone know how to convince vnl to hand me pi constant?<br><br>cheers, Michael<br>
<br><br><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 11:55 AM, Frederic Perez <span dir="ltr"><<a href="mailto:fredericpcx@gmail.com">fredericpcx@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello Michiel,<br><br>perhaps you could use a const Matrix object after all, since it looks to me that FinalRotation is first built with image->GetDirection() but this value is not actually used, and that the signature of itk::Image's is SetDirection(const DirectionType direction).<br>
<br>So here you are, my quickly written proposal (caution, I haven't compiled it):<br><br><div class="gmail_quote"><div class="im"> float angleX, angleY, angleZ;<br> angleX = angleY = angleZ = 5;<br><br> const double cx = vcl_cos(angleX);<br>
const double sx = vcl_sin(angleX);<div> <br> typedef itk::Matrix<double,3,3> Matrix;<br> Matrix RotationX;<br></div></div> <span style="background-color: rgb(255, 204, 204);">// Matrix FinalRotation = image->GetDirection(); -- Commented now <br>
</span><div class="im"><div><br> RotationX[0][0] = 1; RotationX[0][1] = 0; RotationX[0][2] = 0; <br> RotationX[1][0] = 0; RotationX[1][1] = cx; RotationX[1][2] = sx; <br>
RotationX[2][0] = 0; RotationX[2][1] = -sx; RotationX[2][2] = cx;<br><br></div></div> <span style="background-color: rgb(255, 255, 153);">const Matrix FinalRotation = direction*RotationX;</span><div class="im"><br><br>
std::cout << "image->GetDirection(): " << std::endl << image->GetDirection() << std::endl;<br>
std::cout << "RotationX: " << std::endl << RotationX << std::endl;<br> std::cout << "FinalRotation: " << std::endl << FinalRotation << std::endl;<br>
<br>
image->SetDirection(FinalRotation);<br><br> std::cout << "image->GetDirection(): " << std::endl << image->GetDirection() << std::endl;<br><br></div>Cheers,<br><br>Frederic<br>
</div>
<br><div style="display: inline;"></div>
</blockquote></div><br>