<br>thank you, that works indeed.<br><br>cheers, Michael<br><br><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 3:31 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.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;">Hi Michiel,<br>
<br>
You don't need to get that direction matrix as a reference.<br>
<br>
If you get it as a copy, things should go smoothly and<br>
the compiler should be happy.<br>
<br>
<br>
Instead of:<br>
<div class="im"><br>
const ImageType::DirectionType & direction = image->GetDirection();<br>
<br>
</div>you need to do:<br>
<div class="im"><br>
ImageType::DirectionType direction = image->GetDirection();<br>
<br>
</div>then you modify "direction", to apply your rotation,<br>
and when you are done,<br>
you set it back to the image by calling:<br>
<br>
image->SetDirection( direction );<br>
<br>
<br>
<br>
Regards,<br>
<br>
<br>
Luis<br>
<br>
-------------------------------------------------------------------------------<br>
On Tue, Mar 30, 2010 at 6:14 AM, michiel mentink<br>
<div><div></div><div class="h5"><<a href="mailto:michael.mentink@st-hughs.ox.ac.uk">michael.mentink@st-hughs.ox.ac.uk</a>> wrote:<br>
> Dear Luis,<br>
><br>
> thank you for your reply, now I understand what is meant!<br>
><br>
> Direction is from an image:<br>
><br>
> const ImageType::DirectionType & direction = image->GetDirection();<br>
><br>
> I'm trying to rotate the image by just changing the direction matrix of the<br>
> image.<br>
><br>
> Unfortunately, when I just leave out 'const' from that line, the compiler<br>
> complains<br>
> that it's not the same type as expected.<br>
><br>
> Maybe I should just create a new matrix, copy the value of<br>
> image->GetDirection()<br>
> into it, apply the rotation, and use image->SetDirection()?<br>
><br>
> cheers, Michael<br>
><br>
><br>
> On Mon, Mar 29, 2010 at 11:04 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>><br>
> wrote:<br>
>><br>
>> Hi Michiel,<br>
>><br>
>><br>
>> It is excellent that you are diving into the code<br>
>> looking for deeper understanding !<br>
>><br>
>><br>
>> The message that you get indicates that you are<br>
>> attempting to change the value of a variable that<br>
>> has been declared "const" previously.<br>
>><br>
>> The "const" declaration is a promise made to the<br>
>> compiler, stating that you will not change the value<br>
>> of that variable.<br>
>><br>
>> When the compiler catch you breaking that promise,<br>
>> it get angry at you and gives you the error message:<br>
>><br>
>> "error: passing ‘const X to Z discards qualifiers"<br>
>><br>
>><br>
>> Where the "qualifier" refers to the "const" property<br>
>> of that variable.<br>
>><br>
>><br>
>> The error message indicates that you are calling<br>
>> the operator=() method on a const matrix (as left<br>
>> argument of the = ).<br>
>><br>
>><br>
>> You did so, with an expression such as:<br>
>><br>
>><br>
>> const MatrixType myConstMatrixThatWillNeverChange;<br>
>><br>
>> myConstMatrixThatWillNeverChange = anotherMatrix;<br>
>><br>
>><br>
>> This may also happens implicitly if the matrix<br>
>> happens to be a member variable of a class,<br>
>> and you attempt to do such assignment inside<br>
>> a "const" method of the class.<br>
>><br>
>><br>
>> If you share with use the exact declaration of your<br>
>> "direction" matrix we could tell you more about how<br>
>> to get around the problem.<br>
>><br>
>><br>
>> Regards,<br>
>><br>
>><br>
>> Luis<br>
>><br>
>><br>
>><br>
>> --------------------------------------------------------------------------<br>
>> On Mon, Mar 29, 2010 at 12:01 PM, michiel mentink<br>
>> <<a href="mailto:michael.mentink@st-hughs.ox.ac.uk">michael.mentink@st-hughs.ox.ac.uk</a>> wrote:<br>
>> ><br>
>> > In an autodidactic effort, I'm trying to rotate an image by 'hand', by<br>
>> > multiplying the 'direction' matrix of an image by a rotation matrix.<br>
>> ><br>
>> > To do that, I'm copying bits out of itkEuler3DTransform.txx<br>
>> > In that file, a RotationX matrix is defined:<br>
>> ><br>
>> > Matrix<TScalarType,3,3> RotationX<br>
>> ><br>
>> > However, when I try doing that, I'm getting the following error:<br>
>> ><br>
>> > error: passing ‘const itk::Matrix<double, 3u, 3u>’ as ‘this’ argument of<br>
>> > ‘const itk::Matrix<T, NRows, NColumns>& itk::Matrix<T, NRows,<br>
>> > NColumns>::operator=(const itk::Matrix<T, NRows, NColumns>&) [with T =<br>
>> > double, unsigned int NRows = 3u, unsigned int NColumns = 3u]’ discards<br>
>> > qualifiers<br>
>> ><br>
>> > 1) What does this mean?<br>
>> > 2) How do I get my beloved Matrix?<br>
>> ><br>
>> > #include <itkMatrix.h><br>
>> > #include <vnl/vnl_matrix.h><br>
>> ><br>
>> > typedef itk::Matrix<double,3,3> Matrix;<br>
>> ><br>
>> > Matrix RotationX;<br>
>> > // ImageType::DirectionType RotationX;<br>
>> ><br>
>> > // vnl_matrix_fixed<double,3,3> RotationX;<br>
>> ><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>
>> > direction = direction*RotationX;<br>
>> ><br>
>> > cheers,<br>
>> ><br>
>> > Michael<br>
>> ><br>
>> ><br>
>> ><br>
>> ><br>
>> > _____________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Kitware offers ITK Training Courses, for more information visit:<br>
>> > <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the ITK FAQ at:<br>
>> > <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br>