# How to get the position of image in the vtkimageviewer2

**URL:** https://discourse.vtk.org/t/how-to-get-the-position-of-image-in-the-vtkimageviewer2/3291
**Category:** Support
**Created:** [May 13, 2020, 12:56am UTC](https://discourse.vtk.org/t/how-to-get-the-position-of-image-in-the-vtkimageviewer2/3291 "2020-05-13T00:56:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Amnesie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amnesie/32/1673_2.png) [@Amnesie](https://discourse.vtk.org/u/Amnesie)
#### Post date: [May 13, 2020, 12:56am UTC](https://discourse.vtk.org/t/how-to-get-the-position-of-image-in-the-vtkimageviewer2/3291/1 "2020-05-13T00:56:31Z")

</div>

Hello everyone,

I have a new problem with vtk when i try to get the position of image in the vtkimageviewer2 if i clicked left button.  
I set a dicomseries as Input to vtkimageviewer2 ,it works fine  
Here is my Code,I only show the input part nothing special

> using ITKTOVTKFilterType = itk::ImageToVTKImageFilter;  
> ITKTOVTKFilterType::Pointer VTKFilter = ITKTOVTKFilterType::New();  
> VTKFilter-\>SetInput(reader-\>GetOutput());  
> VTKFilter-\>Update();  
> vtkSmartPointer imageflip = vtkSmartPointer::New();  
> imageflip-\>SetInputData(VTKFilter-\>GetOutput());  
> imageflip-\>SetFilteredAxes(1);//Y  
> imageflip-\>Update();  
> vtkSmartPointer imageViewer = vtkSmartPointer::New();  
> imageViewer-\>SetInputConnection(imageflip-\>GetOutputPort());

And i wrote a interactor and a VtkInteractorStyleImage class to observe my mouse event.also i just show the important part so that You won’t need to read much code.

```
class myVtkInteractorStyleImage : public vtkInteractorStyleImage
{
public:
	static myVtkInteractorStyleImage* New();
	vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);

protected:
	vtkImageViewer2* _ImageViewer;
	double origin[3];
public:
	void SetImageViewer(vtkImageViewer2* imageViewer) {
		_ImageViewer = imageViewer;
	}
virtual void OnLeftButtonDown() {
		//origin[0]= _ImageViewer->GetRenderer()->GetActors()->GetLastActor()->GetOrigin()[0];
		origin[1] = _ImageViewer->GetInput()->GetOrigin()[1];
		origin[2] = _ImageViewer->GetInput()->GetOrigin()[2];
		std::cout << "Renderer Size:" << origin[0] << "," << origin[1] << std::endl;
		vtkInteractorStyleImage::OnLeftButtonDown();
	}

```

As i wrote in my code i tried to use like `imageViewer->GetInput()->GetOrigin()` but it always return the same value even if i moved the image in render with middle button.  
Also i tried to GetActors() because i think the image in render should be a actor.  
Then the Programm crash, Here is also a question :  
**What role does the image play in render? not a Actor?**  
And **How can i get the position of image in the vtkimageviewer2**  
Any help on this is highly appreciated.

Thanks,

 ![微信截图_20200513025231](https://discourse.vtk.org/uploads/default/original/2X/2/23c1115fa2cfa9a0bd95e0266db438019351d099.jpeg)
