Function Reference
— Function File: BW2 = erode (BW1,SE)
— Function File: BW2 = erode (BW1,SE,alg)
— Function File: BW2 = erode (BW1,SE,...,n)

Perform an erosion morphological operation on a binary image.

BW2 = erosion(BW1, SE) returns a binary image with the result of an erosion operation on BW1 using neighbour mask SE.

For each point in BW1, erode searchs its neighbours (which are defined by setting to 1 their in SE). If all neighbours are on (1), then pixel is set to 1. If any is off (0) then it is set to 0.

Center of SE is calculated using floor((size(SE)+1)/2).

Pixels outside the image are considered to be 0.

BW2 = erode(BW1, SE, alg) returns the result of a erosion operation using algorithm alg. Only 'spatial' is implemented at the moment.

BW2 = erosion(BW1, SE, ..., n) returns the result of n erosion operations on BW1.

See also: dilate

Demonstration 1

The following code

 erode(ones(5,5),ones(3,3))
 % creates a zeros border around ones.

Produces the following output

ans =

   0   0   0   0   0
   0   1   1   1   0
   0   1   1   1   0
   0   1   1   1   0
   0   0   0   0   0