# How do I get the intersection point of an MRI image and a straight line in space?

**URL:** https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487
**Category:** Support
**Tags:** code
**Created:** [October 15, 2023, 4:38am UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487 "2023-10-15T04:38:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Dylan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dylan/32/7822_2.png) [@Dylan](https://discourse.vtk.org/u/Dylan)
#### Post date: [October 15, 2023, 4:38am UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/1 "2023-10-15T04:38:28Z")

</div>

I used vtkImageReslice to cut a series of MRI images(dicom format), and I got the cut reslice result as an vtkImageData in 3D space. There was another straight line in the 3D space.

How could I get the intersection point of the reslice result(MRI image) and the straight line?

I think I should first adjust the position and orientation of the slice result data set to the pose I want, but I don’t know how to adjust the pose of the imageData data set.

or should I convert vtkImageData to other format,then do the next step?

any advices would be helpful,thansk!

---

<div class="post-metadata">

### Author: ![somso2e](https://discourse.vtk.org/user_avatar/discourse.vtk.org/somso2e/32/7322_2.png) [@somso2e](https://discourse.vtk.org/u/somso2e)
#### Post date: [October 18, 2023, 6:59am UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/2 "2023-10-18T06:59:34Z")

</div>

I’m not exactly sure what you mean by “I got the cut reslice”. If you mean a single 2D slice of the MRI image in a certain orientation, you can use a point on that slice and its orientation to set the origin and the normal of a vtkPlane respectively, and then use the `IntersectWithLine` method to find the intersection point.

There is even a static method for this so you don’t even need to instantiate vtkPlane  
See [VTK: vtkPlane Class Reference](https://vtk.org/doc/nightly/html/classvtkPlane.html#ae1cc9d59214182fb2351f8613447ec36)

---

<div class="post-metadata">

### Author: ![Dylan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dylan/32/7822_2.png) [@Dylan](https://discourse.vtk.org/u/Dylan)
#### Post date: [October 18, 2023, 1:23pm UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/3 "2023-10-18T13:23:16Z")

</div>

hi, somso, thanks for your reply.

yeah ,I got a single 2D slice of MRI image.  
anther info is that the line and the 2D MRI image are in the same plane. So I think it’s not the right way to use vtkPlane’s `IntersectWithLine` method.

I have anther idea: should I get the edge contour line of the 2D MRI image and then use some Locators to get the instersection point?

would that way be workable?

thanks.

---

<div class="post-metadata">

### Author: ![Dylan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dylan/32/7822_2.png) [@Dylan](https://discourse.vtk.org/u/Dylan)
#### Post date: [October 18, 2023, 1:25pm UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/5 "2023-10-18T13:25:09Z")

</div>

Add info : the line and the 2D MRI image are in the same plane

---

<div class="post-metadata">

### Author: ![somso2e](https://discourse.vtk.org/user_avatar/discourse.vtk.org/somso2e/32/7322_2.png) [@somso2e](https://discourse.vtk.org/u/somso2e)
#### Post date: [October 19, 2023, 12:13pm UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/6 "2023-10-19T12:13:03Z")

</div>

May I ask what you are trying to achieve with this? I might be a better help if I know what’s the purpose of this.  
Are you trying to extract the voxels which the line intersects with or do you just want the indices of the voxels or something else?

---

<div class="post-metadata">

### Author: ![Dylan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dylan/32/7822_2.png) [@Dylan](https://discourse.vtk.org/u/Dylan)
#### Post date: [October 19, 2023, 12:16pm UTC](https://discourse.vtk.org/t/how-do-i-get-the-intersection-point-of-an-mri-image-and-a-straight-line-in-space/12487/7 "2023-10-19T12:16:21Z")

</div>

I try to get the isntersection point 's position.  
and get the distance between isntersection point and another point
