[Insight-users] Versor problem
Luis Ibanez
luis.ibanez at kitware.com
Wed Apr 11 12:58:16 EDT 2007
Hi Tony,
Your code looks fine.
There is just a redundant piece:
If you already did:
pointSet->SetPoints( input_mesh->GetPoints() );
then there is no need to add a for loop that copies
every point again:
while()
{
...
pointSet->SetPoint( pointId, p );// advance to next point
...
}
You can get rid of the while loop entirely.
Regards,
Luis
---------------------
tony hakki wrote:
> Dear Luis;
> I convert my STL data to itk pointset like that:first I read it with VTK
> ,then i converted vtk polydata to itk mesh and lastly i converted itk
> mesh to itk pointset with the following code?Is that code incorrect? Is
> there an easier way to convert vtkpolydata to itkpointset?
>
>
> const unsigned int Dimension = 3;
>
> typedef unsigned short PixelType;
>
> typedef itk::PointSet< float, Dimension > FixedPointSetType;
>
> typedef itk::Image< PixelType, Dimension > MovingImageType;
>
> typedef FixedPointSetType::PointsContainer PointsContainer;
>
> PointsContainer::Pointer pointsContainer = PointsContainer::New();
>
> pointsContainer = input_mesh->GetPoints();
>
> itk::PointSet<float, 3>::Pointer pointSet = itk::PointSet<float,3>::New();
>
> pointSet->SetPoints(pointsContainer);
>
> unsigned long pointId = 0;
>
> typedef FMeshType::PointsContainer::Iterator PointsIterator;
>
>
>
> PointsIterator pointIterator = input_mesh->GetPoints()->Begin();
>
> PointsIterator end = input_mesh->GetPoints()->End();
>
> while( pointIterator != end )
>
> {
>
> FMeshType::PointType p = pointIterator.Value(); // access the point
>
> std::cout << p << std::endl; // print the point
>
> pointSet->SetPoint( pointId, p );// advance to next point
>
> pointSet->SetPointData( pointId, pointSet->GetBufferedRegion() );
>
> ++pointIterator;
>
> ++pointId;
>
> }
>
>
>
> ----- Original Message ----
> From: Luis Ibanez <luis.ibanez at kitware.com>
> To: tony hakki <tony2007vtk at yahoo.com>
> Cc: insight-users at itk.org
> Sent: Sunday, April 8, 2007 12:01:48 AM
> Subject: Re: [Insight-users] Versor problem
>
> Hi Tony,
>
>
> 1) Are you using the TransformFileWriter class ?
>
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1TransformFileWriter.html
>
>
>
> 2) The code in your email is inconsistent.
>
> You are declaring a QuaternionRigidTransform in the code,
> but the print out indicates that what you have in the file
> is a VersorRigidTransform.
>
> The transform in the file *MUST* match the type
> of the transform that you declare in the code.
>
>
>
> 3) The fact that your point set is stored in an STL file
> is irrelevant for the purpose of the registration.
> As we suggested in a previous email, you should use VTK
> for reading the STL file, and then convert the points from
> a vtkPolyData into an itkPointSet.
>
>
>
> 4) The fact that your image is stored in a .raw file is
> also irrelevant for the purpose of the registration.
> What matter is whether you are able to read the image file
> into an itk Image.
>
>
>
> 5) Yes,
> You can do PointSet to Image registration in ITK.
>
>
>
> Regards,
>
>
> Luis
>
>
>
>
> ---------------------
> tony hakki wrote:
> > Dear Luis;
> >
> > I set the Center like the following code. I think it is correct to set
> > center. At the end of the registration I write the transform staffs to
> > the a txt folder. In this folder center is seen [0,0,0],as if I hadn't
> > set it. What might the problem?I apply finalparameters to the
> > TransformMeshfilter as a input like that
> >
> > transform->SetParameters( finalParameters );
> >
> > filter->SetTransform(transform );
> >
> > but The pointset goes far away from the image instead of the overlapping
> >
> > If you like to see my whole code I can add it.
> >
> >
> >
> >
> >
> > typedef itk::QuaternionRigidTransform< double > TransformType;
> >
> > TransformType::Pointer transform = TransformType::New();
> >
> > TransformType::InputPointType centerFixed;
> >
> > centerFixed[0] = 15 ;
> >
> > centerFixed[1] =-20;
> >
> > centerFixed[2] =0;
> >
> > transform->SetCenter(centerFixed);
> >
> >
> >
> > here is the Transform staff at the end of the registration : Also here
> > the transformation and the versor variables are too small according to
> > me?Is ITK capable to registrate STL Polydata(I convert it to ITK mesh
> > then to a pointset) and .raw extension 3D image?
> >
> >
> >
> > VersorRigid3DTransform (04D73558)
> > RTTI typeinfo: class itk::VersorRigid3DTransform<double>
> > Reference Count: 4
> > Modified Time: 1221
> > Debug: Off
> > Observers:
> > none
> > Matrix:
> > 0.999912 -0.00431884 0.0125821
> > 0.00426851 0.999983 0.00402404
> > -0.0125992 -0.00396998 0.999913
> > Offset: [1.00003, -0.73264, -1.39039]
> > Center: [0, 0, 0]
> > Translation: [1.00003, -0.73264, -1.39039]
> > Inverse:
> > 0.999912 0.00426851 -0.0125992
> > -0.00431884 0.999983 -0.00396998
> > 0.0125821 0.00402404 0.999913
> > Singular: 0
> > Versor: [ -0.00199855, 0.00629548, 0.00214689, 0.999976 ]
> >
> >
> > ----- Original Message ----
> > From: Luis Ibanez <luis.ibanez at kitware.com>
> > To: tony hakki <tony2007vtk at yahoo.com>
> > Cc: insight-users at itk.org
> > Sent: Friday, April 6, 2007 4:15:48 PM
> > Subject: Re: [Insight-users] Versor problem
> >
> > Hi Tony,
> >
> >
> > 1) The center of the Transform should be set to the Center of the
> > Fixed object. In your case, that will be the Fixed Point Set.
> >
> >
> >
> > 2) FORGET EULER ANGLES !!
> >
> >
> >
> > They are a *BAD* representation of 3D rotations
> >
> >
> > Versors ARE NOT EULER ANGLES
> > Versors are unit Quaternions
> >
> >
> > The methods SetRotationAroundX,Y,Z, *ARE NOT* cumulative.
> >
> > The rotation that you set with SetRotationAroundY is
> > overriding the rotation that you set around X previously.
> >
> > The correct way of setting a versor is via an Axis and an Angle.
> >
> > You should provide the three components (x,y,z) of the axis
> > of rotation, as a unit vector. And you should provide the
> > angle of rotation in radians. Note that the component of the
> > axis *ARE NOT* the Euler angles either.
> >
> >
> >
> > Please read the tutorial on Quaternions:
> >
> > http://www.itk.org/CourseWare/Training/QuaternionsI.pdf
> > http://www.itk.org/CourseWare/Training/QuaternionsII.pdf
> >
> > and the description of Versors in the Wikipedia:
> >
> > http://en.wikipedia.org/wiki/Versor
> >
> > The four components of a Quaternion correspond to:
> >
> >
> > q0 = Ax * sin( T / 2 )
> > q0 = Ay * sin( T / 2 )
> > q0 = Az * sin( T / 2 )
> > q0 = cos( T / 2 )
> >
> >
> > where (Ax,Ay,Az) are the components of the axis
> > of rotation and T is the angle of rotation.
> >
> >
> >
> > Regards,
> >
> >
> > Luis
> >
> >
> > ------------------------
> > tony hakki wrote:
> > > hello;
> > > I have 2 questions:
> > > 1- When we implement pointSetToImageRegistration Should we Set the
> > > center of transform like SetTransform(Center) ,if yes which data's
> > > center should it be,PointSet center or image center?
> > >
> > > 2- I use VersorRigid3DTransform,and I want to set Versor by my
> self and
> > > see the effect of Versor. But I set the versor type like the following
> > > then I get the transform parameters to confirm the versor variables it
> > > says that *versor[0, 0, -0.26745, 0.963572] Why do the versor
> > > variables not same what I set at the beginning?and What does the
> > > fourth one( 0.963572) indicate?*
> > > **
> > > **
> > >
> > > *TransformType::VersorType versor;*
> > >
> > > *versor.SetRotationAroundX( 0.276538 );*
> > >
> > > *versor.SetRotationAroundY( 1.595315);*
> > >
> > > *versor.SetRotationAroundZ( -0.5414906);*
> > >
> > > *transform->SetRotation( versor );*
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > Expecting? Get great news right away with email Auto-Check.
> > >
> >
> <http://us.rd.yahoo.com/evt=49982/*http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html>
> > > Try the Yahoo! Mail Beta.
> > >
> >
> <http://us.rd.yahoo.com/evt=49982/*http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html>
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > Insight-users mailing list
> > > Insight-users at itk.org
> > > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
> > ------------------------------------------------------------------------
> > The fish are biting.
> > Get more visitors
> >
> <http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50
> <http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50>>
>
> > on your site using Yahoo! Search Marketing. <
> >
> http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50
> <http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50>>
>
>
> ------------------------------------------------------------------------
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A
> <http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396546091>
> for great tips from Yahoo! Answers
> <http://answers.yahoo.com/dir/index;_ylc=X3oDMTFvbGNhMGE3BF9TAzM5NjU0NTEwOARfcwMzOTY1NDUxMDMEc2VjA21haWxfdGFnbGluZQRzbGsDbWFpbF90YWcx?link=ask&sid=396546091>
> users.
More information about the Insight-users
mailing list