# How to perform morphological closing in VTK

**URL:** https://discourse.vtk.org/t/how-to-perform-morphological-closing-in-vtk/1438
**Category:** Support
**Created:** [July 29, 2019, 2:33pm UTC](https://discourse.vtk.org/t/how-to-perform-morphological-closing-in-vtk/1438 "2019-07-29T14:33:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![msmerps](https://discourse.vtk.org/user_avatar/discourse.vtk.org/msmerps/32/1559_2.png) [@msmerps](https://discourse.vtk.org/u/msmerps)
#### Post date: [July 29, 2019, 2:33pm UTC](https://discourse.vtk.org/t/how-to-perform-morphological-closing-in-vtk/1438/1 "2019-07-29T14:33:47Z")

</div>

Hi all,  
I am attempting to perform morphological closing on a binary 3D volume (all voxels have values of 0 or 1). It looks like I can use the method vtkImageOpenClose3D for this:

[https://vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageOpenClose3D](https://vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageOpenClose3D)

However, I don’t understand exactly what I should set the values of OpenValue and CloseValue to:

openClose-\>SetOpenValue(0);  
openClose-\>SetCloseValue(1);

In addition, this blog post ([https://lorensen.github.io/VTKExamples/site/Cxx/ImageProcessing/MorphologyComparison/](https://lorensen.github.io/VTKExamples/site/Cxx/ImageProcessing/MorphologyComparison/)) uses vtkImageDilateErode3D for morphological closing instead of vtkImageOpenClose3D. Is vtkImageOpenClose3D equivalent to running vtkImageDilateErode3D twice (i.e., once for dilation and once for erosion)?  
thank you very much,  
-Merps
