[Insight-users] itkMatrix error: discards qualifiers??
michiel mentink
michael.mentink at st-hughs.ox.ac.uk
Tue Mar 30 07:10:59 EDT 2010
Hello Frederic,
thanks for your suggestion.
although my code was working, I tried your suggestion. Unfortunately, it
produces
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’
Anyway, I forgot to mention to use:
float angleX, angleY, angleZ;
angleX = angleY = angleZ = 1 * (3.14/180);
(multiply by pi and divide by 180 degrees, because ITK internally works with
radians instead of degrees)
Which leads me to the question: vnl has a pi constant, and I remember
vaguely having seen it somewhere as vnl::PI or something.
Does anyone know how to convince vnl to hand me pi constant?
cheers, Michael
On Tue, Mar 30, 2010 at 11:55 AM, Frederic Perez <fredericpcx at gmail.com>wrote:
> Hello Michiel,
>
> 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).
>
> So here you are, my quickly written proposal (caution, I haven't compiled
> it):
>
> float angleX, angleY, angleZ;
> angleX = angleY = angleZ = 5;
>
> const double cx = vcl_cos(angleX);
> const double sx = vcl_sin(angleX);
>
> typedef itk::Matrix<double,3,3> Matrix;
> Matrix RotationX;
> // Matrix FinalRotation = image->GetDirection(); -- Commented now
>
> RotationX[0][0] = 1; RotationX[0][1] = 0; RotationX[0][2] = 0;
> RotationX[1][0] = 0; RotationX[1][1] = cx; RotationX[1][2] = sx;
> RotationX[2][0] = 0; RotationX[2][1] = -sx; RotationX[2][2] = cx;
>
> const Matrix FinalRotation = direction*RotationX;
>
>
> std::cout << "image->GetDirection(): " << std::endl <<
> image->GetDirection() << std::endl;
> std::cout << "RotationX: " << std::endl << RotationX << std::endl;
> std::cout << "FinalRotation: " << std::endl << FinalRotation <<
> std::endl;
>
> image->SetDirection(FinalRotation);
>
> std::cout << "image->GetDirection(): " << std::endl <<
> image->GetDirection() << std::endl;
>
> Cheers,
>
> Frederic
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100330/587c2ad3/attachment.htm>
More information about the Insight-users
mailing list