# Importing image from array and axis reorder

**URL:** https://discourse.itk.org/t/importing-image-from-array-and-axis-reorder/1192
**Category:** Beginner Questions
**Tags:** numpy, python
**Created:** [August 9, 2018, 9:59pm UTC](https://discourse.itk.org/t/importing-image-from-array-and-axis-reorder/1192 "2018-08-09T21:59:49Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [August 10, 2018, 2:00pm UTC](https://discourse.itk.org/t/importing-image-from-array-and-axis-reorder/1192/5 "2018-08-10T14:00:51Z")

</div>

ITK indices, by convention, are [i,j,k] while [NumPy indices are [k,j,i]](http://scikit-image.org/docs/dev/user_guide/numpy_images.html) by convention.

That is

```auto
itk_image.GetPixel([i,j,k])

```

is the same as

```auto
numpy_array_as_image[k,j,i]

```

With ITK 4.13.1, the `keepAxes` keyword argument to `GetArrayFromImage` can be used to reorder the array; in ITK 5, this will be `keep_axes` as [we become more PEP8 compliant / Pythonic](https://discourse.itk.org/t/pythonic-interface-to-itk-filters/1106) with the Python API. As noted in the documentation, the numpy operator here for `GetImageFromArray` to flip the image is `numpy.reshape`:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/efb7fcb84f8afa835bafce729a9faf4b4c4e2242/Modules/Bridge/NumPy/wrapping/PyBuffer.i.in#L8-L19>

> <https://github.com/InsightSoftwareConsortium/ITK/blob/efb7fcb84f8afa835bafce729a9faf4b4c4e2242/Modules/Bridge/NumPy/wrapping/PyBuffer.i.in#L123-L140>

However, it is **strongly recommended** not to do this, because images will be flipped in matplotlib, etc. and it has memory usage and performance downsides.

---

_[View the full topic](https://discourse.itk.org/t/importing-image-from-array-and-axis-reorder/1192)._
