This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Ultimate erosion


BW2 = bwulterode(BW)
BW2 = bwulterode(BW,method,conn)


BW2 = bwulterode(BW) computes the ultimate erosion of the binary image BW. The ultimate erosion of BW consists of the regional maxima of the Euclidean distance transform of the complement of BW. The default connectivity for computing the regional maxima is 8 for two dimensions, 26 for three dimensions, and conndef(ndims(BW), 'maximal') for higher dimensions.

BW2 = bwulterode(BW,method,conn) specifies the distance transform method and the regional maxima connectivity. method can be one of the following values: 'euclidean', 'cityblock', 'chessboard', and 'quasi-euclidean'.

conn can have any of the following scalar values.



Two-dimensional connectivities


4-connected neighborhood


8-connected neighborhood

Three-dimensional connectivities


6-connected neighborhood


18-connected neighborhood


26-connected neighborhood

Connectivity can be defined in a more general way for any dimension by using for conn a 3-by-3-by... - by-3 matrix of 0's and 1's. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric about its center element.

Class Support

BW can be numeric or logical and it must be nonsparse. It can have any dimension. The return value BW2 is always a logical array.


collapse all

Read a binary image into the workspace and display it.

originalBW = imread('circles.png');

Perform the ultimate erosion of the image and display it.

ultimateErosion = bwulterode(originalBW);
figure, imshow(ultimateErosion)

Introduced before R2006a

Was this topic helpful?