DeleteBorderComponents[image]
replaces connected components adjacent to the border in a binary image image with background pixels.
replaces components adjacent to the border in a label matrix m with 0.


DeleteBorderComponents
DeleteBorderComponents[image]
replaces connected components adjacent to the border in a binary image image with background pixels.
replaces components adjacent to the border in a label matrix m with 0.
Details and Options

- DeleteBorderComponents works with arbitrary 2D and 3D images or label matrices.
- DeleteBorderComponents takes a CornerNeighbors option. The default setting is CornerNeighbors->True.
Examples
open all close allBasic Examples (2)
Options (1)
Applications (1)
Properties & Relations (2)
When deleting border components from a label matrix, components are not relabeled:
It is also possible to obtain the same effect by masking the border, then using GeodesicDilation:
Related Guides
Text
Wolfram Research (2010), DeleteBorderComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteBorderComponents.html (updated 2012).
CMS
Wolfram Language. 2010. "DeleteBorderComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/DeleteBorderComponents.html.
APA
Wolfram Language. (2010). DeleteBorderComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteBorderComponents.html
BibTeX
@misc{reference.wolfram_2025_deletebordercomponents, author="Wolfram Research", title="{DeleteBorderComponents}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/DeleteBorderComponents.html}", note=[Accessed: 14-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_deletebordercomponents, organization={Wolfram Research}, title={DeleteBorderComponents}, year={2012}, url={https://reference.wolfram.com/language/ref/DeleteBorderComponents.html}, note=[Accessed: 14-August-2025]}