Re: reslice using an arbitrary orientation
Esmeralda Ruiz <[email protected]> Tue, 26 Mar 2019 00:27:29 +0100
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <CA+fPws3T6T04RvUdTabyED9zjobpWHGpWkY5icZ883rBDVFgxg@mail.gmail.com> |
--===============0057625667==
Content-Type: multipart/alternative; boundary="000000000000e0416b0584f38c52"
--000000000000e0416b0584f38c52
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Dear all
i update the question i wrote wrong the perpendicular making changes
double perpendicular[3] =3D { vt[0],0,vt[1] };
but i see that even i compute the perpendicular what it gives it is not
what i want. What i want is the slice that intersects in this orientation
not to create a new coordinate using this orientation. Any idea?
thanks
El lun., 25 mar. 2019 a las 20:08, zandarina (<[email protected]>)
escribi=C3=B3:
> Dear all
>
> I want to reslice a 3d volume computing the perpendicular
> between two points x and y. I compute the
> perpendicular berween point 1, point2 in x and y (z is the same for all
> points as the
> poins are obtained of one slice)
>
> And then i compute the perpendicular of x and y
> And i compute the rotation. And i get a blank image. I would like to
> cut the slice cutting through the perpendicular of those two points.
>
> I attach the code. Is there something wrong
>
> Any help?
>
> Thanks in advance
>
>
> double vt[3];
> vt[0] =3D pts2[0] - pts1[0];
> vt[1] =3D pts2[1] - pts1[1];
> vt[2] =3D pts2[2] - pts1[2]; // it will be 0 as z is the same in =
all
> points
> double perpendicular[3] =3D { -vt[1],vt[0],0 };
>
> double startPoint[3], endPoint[3];
> startPoint[0] =3D tar_cen[0];
> startPoint[1] =3D tar_cen[1];
> startPoint[2] =3D tar_cen[2];
> endPoint[0] =3D startPoint[0] + perpendicular[0];
> endPoint[1] =3D startPoint[1] + perpendicular[1];
> endPoint[2] =3D startPoint[2] + perpendicular[2];
>
> // Compute a basis
> double normalizedX[3];
> double normalizedY[3];
> double normalizedZ[3];
>
> // The X axis is a vector from start to end
> vtkMath::Subtract(endPoint, startPoint, normalizedX);
> //double length =3D vtkMath::Norm(normalizedX);
> vtkMath::Normalize(normalizedX);
>
> // The Z axis is an arbitrary vector cross X
> double arbitrary[3];
> arbitrary[0] =3D vtkMath::Random(-10, 10);
> arbitrary[1] =3D vtkMath::Random(-10, 10);
> arbitrary[2] =3D vtkMath::Random(-10, 10);
> vtkMath::Cross(normalizedX, arbitrary, normalizedZ);
> vtkMath::Normalize(normalizedZ);
>
> // The Y axis is Z cross X
> vtkMath::Cross(normalizedZ, normalizedX, normalizedY);
> vtkSmartPointer<vtkMatrix4x4> matrix =3D
> vtkSmartPointer<vtkMatrix4x4>::New();
>
> // Create the direction cosine matrix
> matrix->Identity();
> for (unsigned int i =3D 0; i < 3; i++)
> {
> matrix->SetElement(i, 0, normalizedX[i]);
> matrix->SetElement(i, 1, normalizedY[i]);
> matrix->SetElement(i, 2, normalizedZ[i]);
> }
>
> // Apply the transforms
> vtkSmartPointer<vtkTransform> transform =3D
> vtkSmartPointer<vtkTransform>::New();
> transform->Translate(startPoint);
> transform->Concatenate(matrix);
>
>
>
>
> reslice->SetResliceTransform(transform);
>
>
> //Step 3: done
> reslice->Update();
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=3Dvtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>
--000000000000e0416b0584f38c52
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Dear all <br></div><div><br></div><div>i update the q=
uestion i wrote wrong the perpendicular making changes</div><div>=20
=C2=A0 double perpendicular[3] =3D { vt[0],0,vt[1] };</div><div><br></div><=
div>but i see that even i compute the perpendicular what it gives it is not=
what i want. What i want is the slice that intersects in this orientation =
not to create a new coordinate using this orientation. Any idea? <br></div>=
<div><br></div><div>thanks<br></div></div><br><div class=3D"gmail_quote"><d=
iv dir=3D"ltr" class=3D"gmail_attr">El lun., 25 mar. 2019 a las 20:08, zand=
arina (<<a href=3D"mailto:[email protected]">esmeralda.ruiz@alma=
3d.com</a>>) escribi=C3=B3:<br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
ding-left:1ex">Dear all<br>
<br>
I want to reslice a 3d volume computing the perpendicular<br>
between two points x and y. I compute the<br>
perpendicular berween point 1, point2 in x and y (z is the same for all<br>
points as the <br>
poins are obtained of one slice)<br>
<br>
And then i compute the perpendicular of x and y<br>
And i compute the rotation. And i get a blank image. I would like to<br>
cut the slice cutting through the perpendicular of those two points.<br>
<br>
I attach the code. Is there something wrong<br>
<br>
Any help?<br>
<br>
Thanks in advance<br>
<br>
<br>
=C2=A0 double vt[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vt[0] =3D pts2[0] - pts1[0];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vt[1] =3D pts2[1] - pts1[1];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vt[2] =3D pts2[2] - pts1[2]; // it will be 0 as=
z is the same in all<br>
points<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double perpendicular[3] =3D { -vt[1],vt[0],0 };=
<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double startPoint[3], endPoint[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 startPoint[0] =3D tar_cen[0];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 startPoint[1] =3D tar_cen[1];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 startPoint[2] =3D tar_cen[2];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endPoint[0] =3D startPoint[0] + perpendicular[0=
];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endPoint[1] =3D startPoint[1] + perpendicular[1=
];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 endPoint[2] =3D startPoint[2] + perpendicular[2=
];<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Compute a basis<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double normalizedX[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double normalizedY[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double normalizedZ[3];<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // The X axis is a vector from start to end<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkMath::Subtract(endPoint, startPoint, normali=
zedX);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 //double length =3D vtkMath::Norm(normalizedX);=
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkMath::Normalize(normalizedX);<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // The Z axis is an arbitrary vector cross X<br=
>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 double arbitrary[3];<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 arbitrary[0] =3D vtkMath::Random(-10, 10);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 arbitrary[1] =3D vtkMath::Random(-10, 10);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 arbitrary[2] =3D vtkMath::Random(-10, 10);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkMath::Cross(normalizedX, arbitrary, normaliz=
edZ);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkMath::Normalize(normalizedZ);<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // The Y axis is Z cross X<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkMath::Cross(normalizedZ, normalizedX, normal=
izedY);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkSmartPointer<vtkMatrix4x4> matrix =3D<=
br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkSmartPointer<vtkMatrix4x4&g=
t;::New();<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Create the direction cosine matrix<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 matrix->Identity();<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for (unsigned int i =3D 0; i < 3; i++)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 matrix->SetElement(i, 0, norma=
lizedX[i]);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 matrix->SetElement(i, 1, norma=
lizedY[i]);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 matrix->SetElement(i, 2, norma=
lizedZ[i]);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Apply the transforms<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkSmartPointer<vtkTransform> transform =
=3D<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vtkSmartPointer<vtkTransform&g=
t;::New();<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 transform->Translate(startPoint);<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 transform->Concatenate(matrix);<br>
<br>
<br>
<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 reslice->SetResliceTransform(transform);<br>
<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 //Step 3: done<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 reslice->Update();<br>
<br>
<br>
<br>
--<br>
Sent from: <a href=3D"http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.h=
tml" rel=3D"noreferrer" target=3D"_blank">http://vtk.1045678.n5.nabble.com/=
VTK-Users-f1224199.html</a><br>
_______________________________________________<br>
Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer" target=3D"=
_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href=3D"http://www.kitware.c=
om/opensource/opensource.html" rel=3D"noreferrer" target=3D"_blank">http://=
www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href=3D"http://w=
ww.vtk.org/Wiki/VTK_FAQ" rel=3D"noreferrer" target=3D"_blank">http://www.vt=
k.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href=3D"http://markmail.org/search/?q=3Dvtk=
users" rel=3D"noreferrer" target=3D"_blank">http://markmail.org/search/?q=
=3Dvtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href=3D"https://vtk.org/mailman/listinfo/vtkusers" rel=3D"noreferrer" ta=
rget=3D"_blank">https://vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div>
--000000000000e0416b0584f38c52--
--===============0057625667==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
--===============0057625667==--