# BinaryReconstructionByErosion works on 2D but not 3D images

**URL:** <https://discourse.itk.org/t/binaryreconstructionbyerosion-works-on-2d-but-not-3d-images/2987>\
**Category:** Beginner Questions\
**Tags:** dicom, simpleitk, python\
**Created:** [April 22, 2020, 8:17am UTC](https://discourse.itk.org/t/binaryreconstructionbyerosion-works-on-2d-but-not-3d-images/2987 "2020-04-22T08:17:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [April 22, 2020, 1:19pm UTC](https://discourse.itk.org/t/binaryreconstructionbyerosion-works-on-2d-but-not-3d-images/2987/2 "2020-04-22T13:19:01Z")

</div>

The filter is working correctly.

The segmented thighs are open at either end, so the erosion of the mask image occurs from those open ends.

I don’t see a problem doing this operation on a series of 2d slices.

Here is some example code of doing slice-by-slice operations in python with SimpleITK:

> [@ResampleImageFilter 4D Images](https://discourse.itk.org/t/resampleimagefilter-4d-images/2172/4):
>
> Looks like a good solution to me. I have done similar things when working with 4D XYZC images. This approach is really asking for a reusable solution something like a python function decorator to operate slice\_by\_slice. Here is what I came up with: def slicing\_decorator(func): """ A function decorator which extracts image slices of N-1 dimensions and calls func on each slice. The resulting images are then concatenated together with JoinSeries. :param func: A function whi…

---

_[View the full topic](https://discourse.itk.org/t/binaryreconstructionbyerosion-works-on-2d-but-not-3d-images/2987)._
