Document directory
- Condition g1:
- Condition G2:
- Condition G3:
- Condition G3 ':
[Reprinted] Mathworks homepage Introduction
Http://www.mathworks.cn/cn/help/images/ref/bwmorph.html
Bwmorph
Morphological operations on Binary Images
Syntax
Bw2 = bwmorph (BW,Operation)
Bw2 = bwmorph (BW,Operation, N)
Description
Bw2 = bwmorph (BW,Operation)Applies a specific morphological operation to the Binary ImageBW.
Bw2 = bwmorph (BW,Operation, N)Applies the operationNTimes.
NCan beINF, In which case the operation is repeated until the image no longer changes.
OperationIs a string that can have one of the values listed below.
Operation |
Description |
'Bothat' |
Performs the morphological "bottom hat" operation, returning the image minus the morphological closing of the image (dilation followed by erosion ). |
'Branchpoints' |
Find branch points of skeleton. For example: 0 0 1 0 0 0 0 0 0 00 0 1 0 0 becomes 0 0 0 0 01 1 1 1 1 0 0 1 0 00 0 1 0 0 0 0 0 0 00 0 1 0 0 0 0 0 0 0 |
'Bridge' |
Bridges unconnected pixels, that is, sets 0-valued pixels1If they have two nonzero neighbors that are not connected. For example: 1 0 0 1 1 0 1 0 1 becomes 1 1 1 0 0 1 0 1 1 |
'Clean' |
Removes isolated pixels (individual 1 s that are surrounded by 0 s), such as the center pixel in this pattern. 0 0 0 0 1 0 0 0 0 |
'Close' |
Performs morphological closing (dilation followed by erosion ). |
'Diag' |
Uses diagonal fill to eliminate 8-connectivity of the background. For example: 0 1 0 0 1 0 1 0 0 becomes 1 1 0 0 0 0 0 0 0 |
'Delete' |
Performs dilation using the structuring elementOnes (3). |
'Endpoints' |
Finds end points of skeleton. For example: 1 0 0 0 1 0 0 00 1 0 0 becomes 0 0 0 00 0 1 0 0 0 1 00 0 0 0 0 0 0 0 |
'Erode' |
Performs erosion using the structuring elementOnes (3). |
'Fill' |
Fills isolated interior pixels (individual 0 s that are surrounded by 1 s), such as the center pixel in this pattern. 1 1 1 1 0 1 1 1 1 |
'Hbreak' |
Removes H-connected pixels. For example: 1 1 1 1 1 1 0 1 0 becomes 0 0 0 1 1 1 1 1 1 |
'Majority' |
Sets a pixel1If five or more pixels in its 3-by-3 neighborhood are 1 s; otherwise, it sets the pixel0. |
'Open' |
Performs morphological opening (erosion followed by dilation ). |
'Delete' |
Removes interior pixels. This option sets a pixel0If all its 4-connected neighbors are1, Thus leaving only the boundary pixels On. |
'Shrink' |
WithN = inf, Shrinks objects to points. it removes pixels so that objects without holes shrink to a point, and objects with holes shrink to a connected ring halfway between each hole and the outer boundary. this option preserves the Euler number. |
'Skel' |
WithN = inf, Removes pixels on the boundaries of objects but does not allow objects to break apart. The pixels remaining make up the image skeleton. This option preserves the Euler number. |
'Spur' |
Removes spur pixels. For example: 0 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 1 0 becomes 0 0 0 00 1 0 0 0 1 0 01 1 0 0 1 1 0 0 |
'Thicken' |
WithN = inf, Thickens objects by adding pixels to the exterior of objects until doing so wocould result in previusly unconnected objects being 8-connected. This option preserves the Euler number. |
'Thin' |
WithN = inf, Thins objects to lines. it removes pixels so that an object without holes shrinks to a minimally connected stroke, and an object with holes shrinks to a connected ring halfway between each hole and the outer boundary. this option preserves The Euler number. See Algorithms for more detail. |
'Tophat' |
Performs morphological "Top Hat" operation, returning the image minus the morphological opening of the image (erosion followed by dilation ). |
BwmorphSupports the generation of efficient, production-Quality C/C ++ code from MATLAB. The text string specifying the operation must be a constant and, for best results, specify an input image of classLogical. To see a complete list
Toolbox functions that support code generation, seesupported functions.
Class Support
The input imageBWCan be numeric or logical. It must be 2-D, real and nonsparse. The output imageBw2Is of class
Logical.
Examples
BW = imread('circles.png');imshow(BW);
BW2 = bwmorph(BW,'remove');figure, imshow(BW2)
BW3 = bwmorph(BW,'skel',Inf);figure, imshow(BW3)
More about
Algorithms
When used with'Thin'Option,BwmorphUses the following algorithm (references [3]):
Divide the image into two distinct subfields in a checkerboard pattern.
In the first subiteration, delete Pixel
PFrom the first subfield if and only if the conditions
G1,G2, andG3 are all satisfied.
In the second subiteration, delete Pixel
PFrom the second subfield if and only if the conditions
G1,G2, and are all satisfied.
Condition g1:
Where
X1,X2 ,...,X8 are the values of the eight neighborsP, Starting
With the East neighbor and numbered in counter-clockwise order.
Condition G2:
Where
Condition G3:
Condition G3 ':
The two subiterations together make up one iteration of the thinning algorithm. When the User specifies an infinite number of iterations (N = inf), The iterations are repeated until the image stops changing. The conditions are all tested usingApplylut
With precomputed Lookup tables.
References
[1] haralick, Robert M., and Linda G. Shapiro,Computer and robot vision, Vol. 1, Addison-Wesley, 1992.
[2] Kong, T. Yung and Azriel Rosenfeld,Topological algorithms for Digital Image Processing, Elsevier Science, inc., 1996.
[3] lam, L., Seong-whan Lee, and Ching Y. Suen, "thinning methodologies-a comprehensive survey ,"IEEE Transactions on Pattern Analysis and machine intelligence, Vol 14, No. 9, September 1992, page 879, bottom of first
Column through top of second column.
[4] Pratt, William K .,Digital Image Processing, John Wiley & Sons, inc., 1991.