You are here : matlabImage Processingimclearborder

imclearborder() - Image Processing

IM2 = imclearborder(IM) suppresses
structures that are lighter than their surroundings and that are connected
to the image border. Use this function to clear the image border. IM can
be a grayscale or binary image. For grayscale images, imclearborder tends
to reduce the overall intensity level in addition to suppressing border
structures. The output image, IM2, is grayscale
or binary, depending on the input. The default connectivity is 8 for
two dimensions, 26 for three dimensions, and conndef(ndims(BW),'maximal') for
higher dimensions. exampleIM2 = imclearborder(IM,conn) specifies
the desired connectivity.Code Generation support:
Yes.MATLAB Function Block support:
Yes.


Syntax

IM2 = imclearborder(IM) exampleIM2 = imclearborder(IM,conn) example


Example

Impact of Connectivity on Clearing the BorderOpen This Example
Create a simple binary image.BW = [0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      1     0     0     1     1     1     0     0     0
      0     1     0     1     1     1     0     0     0
      0     0     0     1     1     1     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0];
Clear pixels on the border of the image using 4-connectivity. Note that imclearborder does not clear the pixel at (5,2) because, with 4-connectivity, it is not considered connected to the border pixel at (4,1).BWc1 = imclearborder(BW,4)

BWc1 =

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

Now clear pixels on the border of the image using 8-connectivity. imclearborder clears the pixel at (5,2) because, with 8-connectivity, it is considered connected to the border pixel (4,1).BWc2 = imclearborder(BW,8)

BWc2 =

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


Output / Return Value


Limitations


Alternatives / See Also


Reference