# Flip image data

**URL:** <https://discourse.slicer.org/t/flip-image-data/20249>\
**Category:** Development\
**Created:** [October 19, 2021, 7:28pm UTC](https://discourse.slicer.org/t/flip-image-data/20249 "2021-10-19T19:28:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [October 19, 2021, 7:28pm UTC](https://discourse.slicer.org/t/flip-image-data/20249/1 "2021-10-19T19:28:50Z")

</div>

Hi,

I is it possible to flip `vtkImageData` and wrap the result in `vtkMRMLScalarVolumeNode`?

For example I can see that VTK has [vtkImageFlip](https://vtk.org/doc/nightly/html/classvtkImageFlip.html) but for me it doesnt work:

```auto
  vtkNew<vtkImageData> imageData;
  imageData->SetDimensions(samples.size(), uXL.size(), uIL.size());
  imageData->AllocateScalars(VTK_FLOAT, 1);
  imageData->GetPointData()->SetScalars(TRACE);

  vtkNew<vtkImageFlip> imageFlip;
  imageFlip->SetInputData(imageData);
  imageFlip->SetFilteredAxis(1);
  imageFlip->Update();

  vtkNew<vtkMRMLScalarVolumeNode> volumeNode;
  volumeNode->SetName(nodeName.c_str());
  volumeNode->SetAndObserveImageData(imageData);

```

I think I do something wrong…

By the way simple rotation transform doesn’t solve my issue

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [October 19, 2021, 7:40pm UTC](https://discourse.slicer.org/t/flip-image-data/20249/2 "2021-10-19T19:40:03Z")

</div>

I’m sorry  
I just found a solution on internet.  
I should have been using:

```cpp
...
volumeNode->SetAndObserveImageData(imageFlip->GetOutput()); // `imageFlip->GetOutput()` returns `vtkImageData`

```
