Sie sind auf Seite 1von 6

im2bw

Convert image to binary image, based on threshold

Syntax
BW = im2bw(I, level)
BW = im2bw(X, map, level) BW = im2bw(RGB, level)

Description BW = im2bw(I, level) converts the grayscale image I to a binary image. The output image BW replaces all pixels in the input image with luminance greater than level with the value 1 (white) and replaces all other pixels with the value 0 (black). Specify level in the range [0,1]. This range is relative to the signal levels possible for the image's class. Therefore, a level value of 0.5 is midway between black and white, regardless of class. To compute the level argument, you can use the function graythresh. If you do not specify level, im2bwuses the value 0.5. BW = im2bw(X, map, level) converts the indexed image X with colormap map to a binary
image.

BW = im2bw(RGB, level) converts the truecolor image RGB to a binary image. If the input image is not a grayscale image, im2bw converts the input image to grayscale, and then
converts this grayscale image to binary by thresholding.

graythresh
Global image threshold using Otsu's method

Syntax
level = graythresh(I) [level EM] = graythresh(I)

Description
level = graythresh(I) computes a global threshold (level) that can be used to convert an intensity image to a binary image withim2bw. level is a normalized intensity value that lies in the range [0, 1].
The graythresh function uses Otsu's method, which chooses the threshold to minimize the intraclass variance of the black and white pixels. Multidimensional arrays are converted automatically to 2-D arrays using reshape. The graythresh function ignores any nonzero imaginary part of I.

[level EM] = graythresh(I) returns the effectiveness metric, EM, as the second output
argument. The effectiveness metric is a value in the range [0 1] that indicates the effectiveness of the thresholding of the input image. The lower bound is attainable only by images having a single gray level, and the upper bound is attainable only by two-valued images.

bwareaopen
Binary area open; remove small objects Syntax
BW2 = bwareaopen(BW,P) BW2 = bwareaopen(BW,P,CONN)

Description bwareaopen(BW,P) removes from a binary image all connected components (objects) that have fewer than P pixels, producing another binary image BW2. The default connectivity is 8 for two dimensions, 26 for three dimensions, and conndef(ndims(BW),'maximal') for higher dimensions.
BW2 =

bwareaopen(BW,P,CONN) specifies the desired connectivity. CONN may have any of the following scalar values.
BW2 =

Value Meaning Two-dimensional connectivities


4 8

4-connected neighborhood 8-connected neighborhood

Three-dimensional connectivities
6 18 26

6-connected neighborhood 18-connected neighborhood 26-connected neighborhood

Connectivity may 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.

medfilt2

2-D median filtering


Note: The syntax medfilt2(A,[M

N],(Mb Nb],...) has been removed.

Syntax
B = medfilt2(A, [m n])
B = medfilt2(A) B = medfilt2(A, 'indexed', ...) B = medfilt2(..., padopt)

Description
Median filtering is a nonlinear operation often used in image processing to reduce "salt and pepper" noise. A median filter is more effective than convolution when the goal is to simultaneously reduce noise and preserve edges.

B = medfilt2(A, [m n]) performs median filtering of the matrix A in two dimensions. Each output pixel contains the median value in the m-by-n neighborhood around the corresponding pixel in the input image. medfilt2 pads the image with 0s on the edges, so the median values for the points within [m n]/2 of the edges might appear distorted. B = medfilt2(A) performs median filtering of the matrix A using the default 3-by-3 neighborhood. B = medfilt2(A, 'indexed', ...) processes A as an indexed image, padding with 0s if the class of A is uint8, or 1s if the class of Ais double. B = medfilt2(..., padopt) controls how the matrix boundaries are padded. padopt may be 'zeros' (the default), 'symmetric', or'indexed'. If padopt is 'symmetric', A is symmetrically extended at the boundaries. If padopt is 'indexed', A is padded with ones if it is double; otherwise it is padded with zeros.

bwlabel
Label connected components in a binary image Syntax
L = bwlabel(BW,n) [L,num] = bwlabel(BW,n)

Description returns a matrix L, of the same size as BW, containing labels for the connected objects in BW. n can have a value of either 4 or 8, where 4 specifies 4-connected objects and 8 specifies 8-connected objects; if the argument is omitted, it defaults to 8.
L = bwlabel(BW,n)

The elements of L are integer values greater than or equal to 0. The pixels labeled 0 are the background. The pixels labeled 1 make up one object, the pixels labeled 2 make up a second object, and so on.

[L,num] = bwlabel(BW,n)

returns in num the number of connected objects found

in BW.

dge
Find edges in grayscale image
Note:

The syntax BW = edge(... ,K) has been removed. Use the BW = edge(... ,direction) syntax i The syntax edge(I,'marr-hildreth',...) has been removed. Use the edge(I,'log',...) synt instead.

Syntax
BW = edge(I)

BW = edge(I,'sobel') BW = edge(I,'sobel',thresh) BW = edge(I,'sobel',thresh,direction) [BW,thresh] = edge(I,'sobel',...) BW = edge(I,'prewitt') BW = edge(I,'prewitt',thresh) BW = edge(I,'prewitt',thresh,direction) [BW,thresh] = edge(I,'prewitt',...) BW = edge(I,'roberts') BW = edge(I,'roberts',thresh) [BW,thresh] = edge(I,'roberts',...) BW = edge(I,'log') BW = edge(I,'log',thresh) BW = edge(I,'log',thresh,sigma) [BW,threshold] = edge(I,'log',...) BW = edge(I,'zerocross',thresh,h) [BW,thresh] = edge(I,'zerocross',...) BW = edge(I,'canny') BW = edge(I,'canny',thresh) BW = edge(I,'canny',thresh,sigma) [BW,threshold] = edge(I,'canny',...) Description BW = edge(I) takes a grayscale or a binary image I as its input, and returns a binary image BW of the same size as I, with 1's where the function finds edges in I and 0's elsewhere.

By default, edge uses the Sobel method to detect edges but the following provides a complete list of all the

edge-finding methods supported by this function: The Sobel method finds edges using the Sobel approximation to the derivative. It returns edges at those points where the gradient of I is maximum. The Prewitt method finds edges using the Prewitt approximation to the derivative. It returns edges at those points where the gradient of Iis maximum. The Roberts method finds edges using the Roberts approximation to the derivative. It returns edges at those points where the gradient of I is maximum. The Laplacian of Gaussian method finds edges by looking for zero crossings after filtering I with a Laplacian of Gaussian filter. The zero-cross method finds edges by looking for zero crossings after filtering I with a filter you specify. The Canny method finds edges by looking for local maxima of the gradient of I. The gradient is calculated using the derivative of a Gaussian filter. The method uses two thresholds, to detect strong and weak edges, and includes the weak edges in the output only if they are connected to strong edges. This method is therefore less likely than the others to be fooled by noise, and more likely to detect true weak edges. The parameters you can supply differ depending on the method you specify. If you do not specify a method, edge uses the Sobel method.

Sobel Method

BW = edge(I,'sobel') specifies the Sobel method. BW = edge(I,'sobel',thresh) specifies the sensitivity threshold for the Sobel method. edge ignores all edges that are not stronger than thresh. If you do not specify thresh, or if thresh is empty ([]), edge chooses the value automatically. BW = edge(I,'sobel',thresh,direction) specifies the direction of detection for the Sobel method. direction is a string specifying whether to look for 'horizontal' or 'vertical' edges or 'both' (the default). BW = edge(I,'sobel',...,options) provides an optional string input. String 'nothinning' speeds up the operation of the algorithm by skipping the additional edge thinning stage. By default, or when 'thinning' string is specified, the algorithm applies edge thinning. [BW,thresh] = edge(I,'sobel',...) returns the threshold value.
Prewitt Method

BW = edge(I,'prewitt') specifies the Prewitt method. BW = edge(I,'prewitt',thresh) specifies the sensitivity threshold for the Prewitt method. edge ignores all edges that are not stronger than thresh. If you do not specify thresh, or if thresh is empty ([]), edge chooses the value automatically. BW = edge(I,'prewitt',thresh,direction) specifies the direction of detection for the Prewitt method. direction is a string specifying whether to look for 'horizontal' or 'vertical' edges or 'both' (default). [BW,thresh] = edge(I,'prewitt',...) returns the threshold value.
Roberts Method

BW = edge(I,'roberts') specifies the Roberts method. BW = edge(I,'roberts',thresh) specifies the sensitivity threshold for the Roberts method. edge ignores all edges that are not stronger than thresh. If you do not specify thresh, or if thresh is empty ([]), edge chooses the value automatically. BW = edge(I,'roberts',...,options) where options can be the text string 'thinning' or 'nothinning'. When you specify'thinning', or don't specify a value, the algorithm applies edge thinning. Specifying the 'nothinning' option can speed up the operation of
the algorithm by skipping the additional edge thinning stage. [BW,thresh] = edge(I,'roberts',...) returns the threshold value.

Laplacian of Gaussian Method

BW = edge(I,'log') specifies the Laplacian of Gaussian method. BW = edge(I,'log',thresh) specifies the sensitivity threshold for the Laplacian of Gaussian method. edge ignores all edges that are not stronger than thresh. If you do not specify thresh, or if thresh is empty ([]), edge chooses the value automatically. If you specify a threshold of 0, the
output image has closed contours, because it includes all the zero crossings in the input image. BW = edge(I,'log',thresh,sigma) specifies the Laplacian of Gaussian method, using sigma as the standard deviation of the LoG filter. The default sigma is 2; the size of the filter is nby-n, where n = ceil(sigma*3)*2+1. [BW,thresh] = edge(I,'log',...) returns the threshold value.

Zero-Cross Method

BW = edge(I,'zerocross',thresh,h) specifies the zero-cross method, using the filter h. thresh is the sensitivity threshold; if the argument is empty ([]), edge chooses the sensitivity
threshold automatically. If you specify a threshold of 0, the output image has closed contours, because it includes all the zero crossings in the input image. [BW,thresh] = edge(I,'zerocross',...) returns the threshold value.

Canny Method

BW = edge(I,'canny') specifies the Canny method. BW = edge(I,'canny',thresh) specifies sensitivity thresholds for the Canny method. thresh is a two-element vector in which the first element is the low threshold, and the second element is the high threshold. If you specify a scalar for thresh, this scalar value is used for the high threshold and 0.4*thresh is used for the low threshold. If you do not specify thresh, or if thresh is empty ([]), edge chooses low and high values automatically. The value for thresh is
relative to the highest value of the gradient magnitude of the image. BW = edge(I,'canny',thresh,sigma) specifies the Canny method, using sigma as the standard deviation of the Gaussian filter. The default sigma is sqrt(2); the size of the filter is chosen automatically, based on sigma. [BW,thresh] = edge(I,'canny',...) returns the threshold values as a two-element vector.

Das könnte Ihnen auch gefallen