Closing
Details
- Morphological closing is typically used to smooth the boundaries or close the holes and gaps.
- Closing is effectively dilation followed by erosion using a specific structuring element.
- Closing works with arbitrary 2D and 3D images, operating separately on each channel, as well as data arrays of any rank.
- The structuring element ker is a matrix containing 0s and 1s.
- Closing automatically pads structuring elements to have odd dimensions.
- Closing[image,r] is equivalent to Closing[image,BoxMatrix[r]].
Examples
open all close allBasic Examples (3)
Closing of a binary image using a disk-shaped structuring element:
Closing[[image], DiskMatrix[4]]Closing of a grayscale image using a disk-shaped structuring element:
Closing[[image], DiskMatrix[5]]Closing of a hole in a 3D image:
Closing[[image], 6]Scope (10)
Data (7)
Close small gaps in a numeric vector:
Closing[{1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1}, {1, 1, 1}]data = QuantityMagnitude@Values[FinancialData["AT&T", {{2012, 7, 1}, {2013, 1, 1}, "Day"}]];ListLinePlot[{data, Closing[data, 10]}]Closing[(| | | | | | | |
| - | - | - | - | - | - | - |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |), (| | | |
| - | - | - |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 0 | 0 | 1 |)]//MatrixFormClosing of a binary image with a diamond-shaped structuring element:
Closing[[image], DiamondMatrix[11]]Closing[[image], 6]Closing of a color texture pattern with a square-shaped structuring element:
Closing[[image], 15]Closing of a symbolic array of data:
Closing[{a, b, c}, 1]Parameters (3)
Closing[[image], {{1, 1, 1, 1, 1, 1}}]Closing[[image], {{1}, {1}, {1}, {1}, {1}}]Close with radius
, equivalent to BoxMatrix[r]:
Closing[[image], 6]Applications (4)
Closing removes holes that are smaller than the structuring elements:
Closing[[image], DiskMatrix[5]]Remove holes from a color image:
Closing[[image], DiskMatrix[5]]Remove thin, dark features by morphological closing:
Closing[[image], 2]Use morphological closing to remove pepper noise from a color photo:
Closing[[image], 1]Related Guides
Text
Wolfram Research (2008), Closing, Wolfram Language function, https://reference.wolfram.com/language/ref/Closing.html (updated 2012).
CMS
Wolfram Language. 2008. "Closing." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Closing.html.
APA
Wolfram Language. (2008). Closing. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Closing.html
BibTeX
@misc{reference.wolfram_2026_closing, author="Wolfram Research", title="{Closing}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Closing.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_closing, organization={Wolfram Research}, title={Closing}, year={2012}, url={https://reference.wolfram.com/language/ref/Closing.html}, note=[Accessed: 12-June-2026]}