Documentation

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.

imclearborder

Suppress light structures connected to image border

Syntax

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

Description

example

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.

example

IM2 = imclearborder(IM,conn) specifies the desired connectivity.

Examples

collapse all

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

Input Arguments

collapse all

Grayscale or binary image, specified as a real, nonsparse, numeric or logical array.

Example: I = imread('pout.tif'); I2 = imclearborder(I);

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

Connectivity, specified as one of the values in this table.

Value

Meaning

Two-dimensional connectivities

4

4-connected neighborhood

8

8-connected neighborhood

Three-dimensional connectivities

6

6-connected neighborhood

18

18-connected neighborhood

26

26-connected neighborhood

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

Note

A pixel on the edge of the input image might not be considered to be a border pixel if you specify a nondefault connectivity. For example, if conn = [0 0 0; 1 1 1; 0 0 0], elements on the first and last row are not considered to be border pixels because, according to that connectivity definition, they are not connected to the region outside the image.

Example: I2 = imclearborder(I,4);

Data Types: double | logical

Output Arguments

collapse all

Grayscale or binary image, returned as a real, nonsparse, numeric or logical array, depending on the input image you specify.

Algorithms

imclearborder uses morphological reconstruction where:

  • Mask image is the input image.

  • Marker image is zero everywhere except along the border, where it equals the mask image.

References

[1] Soille, P., Morphological Image Analysis: Principles and Applications, Springer, 1999, pp. 164-165.

Extended Capabilities

See Also

Introduced before R2006a

Was this topic helpful?