# how to get the image postion

**URL:** https://discourse.vtk.org/t/how-to-get-the-image-postion/1535
**Category:** Support
**Created:** [August 9, 2019, 2:34am UTC](https://discourse.vtk.org/t/how-to-get-the-image-postion/1535 "2019-08-09T02:34:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pingdan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pingdan](https://discourse.vtk.org/u/pingdan)
#### Post date: [August 9, 2019, 2:34am UTC](https://discourse.vtk.org/t/how-to-get-the-image-postion/1535/1 "2019-08-09T02:34:35Z")

</div>

![test](https://discourse.vtk.org/uploads/default/original/1X/fa35cfe038448ecb773bb08587451597e7cc23c3.png)  
as the graph.I show a picture in a renderer, and I know the renderer size and the picture size.when I press left button down, I can get a point position in the renderer. I want to judge if the point locate on picture. how can I get the picture position on renderer?

---

<div class="post-metadata">

### Author: ![Edoardo\_Pasca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/edoardo_pasca/32/742_2.png) [@Edoardo\_Pasca](https://discourse.vtk.org/u/Edoardo_Pasca)
#### Post date: [August 9, 2019, 11:42am UTC](https://discourse.vtk.org/t/how-to-get-the-image-postion/1535/2 "2019-08-09T11:42:05Z")

</div>

You need to use vtkCoordinate

That’s how I got it working on my 3D viewer

> <https://github.com/vais-ral/CILViewer/blob/master/Wrappers/Python/ccpi/viewer/CILViewer2D.py#L742>

```
viewerposition = interactor.GetEventPosition()
vc = vtk.vtkCoordinate()
vc.SetCoordinateSystemToViewport()
vc.SetValue(viewerposition[0:2] + (0.0,))

# pick position in World Coordinates
pickPosition = list(vc.GetComputedWorldValue(renderer))

```

Then I work out the location on the image by the origin and spacing. Notice that I set to 0 the third coordinate that I’m passing to vc as the viewerposition is in viewer coordinates (so 2D).

Hope this helps

Edo

---

<div class="post-metadata">

### Author: ![pingdan](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pingdan](https://discourse.vtk.org/u/pingdan)
#### Post date: [August 13, 2019, 8:12am UTC](https://discourse.vtk.org/t/how-to-get-the-image-postion/1535/3 "2019-08-13T08:12:39Z")

</div>

hi, Edo

thank you very much. I have solved my question according to your code.
