Opening
Details
- Morphological opening is typically used to break thin connections, remove small objects and smooth the boundaries.
- Opening is effectively erosion followed by dilation using a specific structuring element.
- Opening 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.
- Opening automatically pads structuring elements to have odd dimensions.
- Opening[image,r] is equivalent to Opening[image,BoxMatrix[r]].
Examples
open all close allBasic Examples (4)
Opening of a binary image using a disk-shaped structuring element:
Opening[[image], DiskMatrix[9]]Opening of a grayscale image using a disk-shaped structuring element:
Opening[[image], DiskMatrix[5]]Opening of a color photo with a diamond-shaped structuring element:
Opening[[image], DiamondMatrix[11]]Opening of a 3D image using a cubic structuring element:
Opening[[image], 5]Scope (9)
Data (6)
Use Opening to remove short sequences of 1s from a numeric vector:
Opening[{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, Opening[data, 10]}]Opening[(| | | | | | | |
| - | - | - | - | - | - | - |
| 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 |)]//MatrixFormOpening of a binary image with a disk-shaped structuring element:
Opening[[image], DiskMatrix[5]]Opening[[image], 6]Opening of a symbolic array of data:
Opening[{a, b, c}, 1]Kernel (3)
Applications (2)
Properties & Relations (3)
Even-length kernels get right-padded with zeros:
i = RandomImage[];Opening[i, (| | |
| - | - |
| 0 | 1 |
| 1 | 1 |)] == Opening[i, (| | | |
| - | - | - |
| 0 | 1 | 0 |
| 1 | 1 | 0 |
| 0 | 0 | 0 |)]For symmetric kernels, Opening corresponds to an Erosion followed by a Dilation:
i = RandomImage[];
ker = (| | | |
| - | - | - |
| 0 | 1 | 0 |
| 1 | 1 | 1 |
| 0 | 1 | 0 |);
Opening[i, ker] == Dilation[Erosion[i, ker], ker]For non-symmetric kernels, Opening corresponds to Erosion followed by a Dilation with a reflected structuring element:
i = RandomImage[];
ker = (| | | |
| - | - | - |
| 0 | 1 | 0 |
| 1 | 1 | 0 |
| 0 | 0 | 0 |);Opening[i, ker] == Dilation[Erosion[i, ker], Reverse[ker, {1, 2}]]Related Guides
Text
Wolfram Research (2008), Opening, Wolfram Language function, https://reference.wolfram.com/language/ref/Opening.html (updated 2012).
CMS
Wolfram Language. 2008. "Opening." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/Opening.html.
APA
Wolfram Language. (2008). Opening. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Opening.html
BibTeX
@misc{reference.wolfram_2026_opening, author="Wolfram Research", title="{Opening}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/Opening.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_opening, organization={Wolfram Research}, title={Opening}, year={2012}, url={https://reference.wolfram.com/language/ref/Opening.html}, note=[Accessed: 13-June-2026]}