# When I load the tiff file, the image is displayed upside down.

**URL:** https://discourse.vtk.org/t/when-i-load-the-tiff-file-the-image-is-displayed-upside-down/4763
**Category:** Support
**Created:** [December 2, 2020, 2:25am UTC](https://discourse.vtk.org/t/when-i-load-the-tiff-file-the-image-is-displayed-upside-down/4763 "2020-12-02T02:25:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [December 2, 2020, 2:25am UTC](https://discourse.vtk.org/t/when-i-load-the-tiff-file-the-image-is-displayed-upside-down/4763/1 "2020-12-02T02:25:09Z")

</div>

I have tested to draw an image by using vtkImageReader2 and vtkImageViewer2.  
Strangely, a bitmap file works well but tiff has a problem  
When I load the tiff file, the image is displayed upside down.

Original Image:  
[original.tif](https://discourse.vtk.org/uploads/short-url/hTlEKBSKHNqPdCnktP2xPt9DQQi.tif) (358.8 KB)  
VTK:

 ![vtk](https://discourse.vtk.org/uploads/default/original/2X/6/6042f6c76e853b40688f490553f2c5cb7574f07c.png)

Could I need any setting for the tiff file?

Could you please advise for me?

Thank you 🙂

My code is:  
int main(int argc, char\* argv[])  
{  
std::string path = “original.tif”;  
// Read the image  
vtkSmartPointer readerFactory =  
vtkSmartPointer::New();  
vtkSmartPointer reader;  
reader.TakeReference(readerFactory-\>CreateImageReader2(path.c\_str()));  
reader-\>SetFileName(path.c\_str());  
reader-\>Update();

```
// Visualize
vtkSmartPointer<vtkImageViewer2> imageViewer =
	vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputConnection(reader->GetOutputPort());
imageViewer->GetRenderWindow()->SetSize(500, 500);
imageViewer->GetRenderer()->ResetCamera();

// Set up an interactor that does not respond to mouse events
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
	vtkSmartPointer<vtkRenderWindowInteractor>::New();
imageViewer->GetRenderWindow()->SetInteractor(renderWindowInteractor);
//renderWindowInteractor->SetInteractorStyle(0);
imageViewer->Render();

// Start the event loop
renderWindowInteractor->Initialize();
renderWindowInteractor->Start();

return EXIT_SUCCESS;

```

}

---

<div class="post-metadata">

### Author: ![Joachim\_P](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joachim_p/32/3272_2.png) [@Joachim\_P](https://discourse.vtk.org/u/Joachim_P)
#### Post date: [December 4, 2020, 12:13am UTC](https://discourse.vtk.org/t/when-i-load-the-tiff-file-the-image-is-displayed-upside-down/4763/2 "2020-12-04T00:13:51Z")

</div>

Hi,

You might want to add a `vtkImageFlip` filter to your pipeline (between the reader and the viewer of course) - with a call to `SetFilteredAxis(1);`.

Take a look to [https://vtk.org/Wiki/VTK/Examples/Cxx/Images/Flip](https://vtk.org/Wiki/VTK/Examples/Cxx/Images/Flip) for an example.

Hope this helps,  
Joachim

---

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [December 4, 2020, 2:30am UTC](https://discourse.vtk.org/t/when-i-load-the-tiff-file-the-image-is-displayed-upside-down/4763/3 "2020-12-04T02:30:46Z")

</div>

Hi Joachim.

Thank you for your advise.

I modified the code that if the loaded image file’s extension is TIF, it should be applied to Flip Y.

And It works well.

Thank you 🙂

Best regards,  
William Kim
