# Extract 2D image from 3D image

**URL:** https://discourse.itk.org/t/extract-2d-image-from-3d-image/909
**Category:** Beginner Questions
**Created:** [May 8, 2018, 1:56pm UTC](https://discourse.itk.org/t/extract-2d-image-from-3d-image/909 "2018-05-08T13:56:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mabou](https://discourse.itk.org/letter_avatar_proxy/v4/letter/m/bbce88/32.png) [@mabou](https://discourse.itk.org/u/mabou)
#### Post date: [May 8, 2018, 1:56pm UTC](https://discourse.itk.org/t/extract-2d-image-from-3d-image/909/1 "2018-05-08T13:56:23Z")

</div>

Hello everyone,

I have used the code in [https://itk.org/ITKExamples/src/Filtering/ImageGrid/ProcessA2DSliceOfA3DImage/Documentation.html](https://itk.org/ITKExamples/src/Filtering/ImageGrid/ProcessA2DSliceOfA3DImage/Documentation.html) to extract 2D image from 3D image (mainly NIFTI image).

I had this exception after running the code:

> _Description: itk::ERROR: BMPImageIO(0x29afc80): BMPImageIO cannot write images with a dimension != 2_

And when I debugged the code, I found that medianImage-\>GetBufferedRegion() returns the follow:

> ```
> Dimension: 3
> Index: [0, 0, 80]
> Size: [230, 230, 1]
> 
> ```

Which means that the buffered region has dimensions 3 instead of 2. May someone help me to understand what is the problem here? Why it has dimensions 3? Or what I should do to get one 2D image?  
Thank you!

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 8, 2018, 2:57pm UTC](https://discourse.itk.org/t/extract-2d-image-from-3d-image/909/2 "2018-05-08T14:57:20Z")

</div>

You want the [extract image filter](https://itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html) then.
