主要内容

imclearborder

Suppress light structures connected to image border

描述

example

J= imclearborder(I)suppresses structures in imageIthat are lighter than their surroundings and that are connected to the image border. Use this function to clear the image border. For grayscale images,imclearbordertends to reduce the overall intensity level in addition to suppressing border structures. The output image,J, is grayscale or binary, depending on the input.

example

J= imclearborder(I,conn)specifies the pixel connectivity,conn

例子

全部收缩

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];

使用4个连接性在图像边界上清除像素。注意imclearborderdoes 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 =9×90 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 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 11 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 0 0 0 0 0 0 0 0 0 0

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

bwc2 = imclearborder(BW,8)
BWC2 =9×90 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 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 11 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 0 0 0 0 0 0 0 0 0 0

Input Arguments

全部收缩

灰度或二进制图像,指定为数字或逻辑数组。

例子:I = imread('pout.tif');

Data Types:single|double|int8|INT16|INT32|uint8|UINT16|uint32|logical

像素连接,指定为该表中的值之一。默认连接是8对于二维图像,以及26for 3-D images.

价值

Meaning

二维连接

4

如果它们的边缘接触,则连接像素。像素的邻域是水平或垂直方向上的相邻像素。

3 x-3像素社区,有四个像素连接到中心像素

Current pixel is shown in gray.

8

Pixels are connected if their edges or corners touch. The neighborhood of a pixel are the adjacent pixels in the horizontal, vertical, or diagonal direction.

3-by-3 pixel neighborhood with 8 pixels connected to the center pixel

Current pixel is shown in gray.

Three-Dimensional Connectivities

6

如果他们的脸触摸,则连接像素。像素的邻居是相邻的像素:

  • One of these directions: in, out, left, right, up, and down

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces of the center pixel

Current pixel is shown in gray.

18

Pixels are connected if their faces or edges touch. The neighborhood of a pixel are the adjacent pixels in:

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces and 12 pixels connected to the edges of the center pixel

Current pixel is center of cube.

26

如果像素的脸,边缘或角触摸,则连接像素。像素的邻居是相邻的像素:

  • One of these directions: in, out, left, right, up, and down

  • A combination of two directions, such as right-down or in-up

  • A combination of three directions, such as in-right-up or in-left-down

3-by-3-by-3 pixel neighborhood with 6 pixels connected to the faces, 12 pixels connected to the edges, and 8 pixels connected to the corners of the center pixel

Current pixel is center of cube.

For higher dimensions,imclearborderuses the default valueConndef(ndims(I),'maximal')

Connectivity can also be defined in a more general way for any dimension by specifying a 3-by-3-by- ... -by-3 matrix of0s and1s. The1- 价值元素定义相对于中心元素的邻里位置conn。注意connmust be symmetric about its center element. See指定自定义连接for more information.

Note

如果您指定非默认连接性,则输入图像边缘的像素可能不会被视为边框像素。例如,如果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.

Data Types:double|logical

Output Arguments

全部收缩

处理后的灰度或二进制图像,根据您指定的输入图像为数字或逻辑数组。

算法

imclearborderuses morphological reconstruction where:

  • Mask image is the input image.

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

参考

[1] Soille,P。,形态图像分析:原理和应用,施普林格,1999年,第164-165页。

Extended Capabilities

Version History

在R2006a之前引入

See Also