Detailed instructions for use are in the User's Guide.
[. . . ] Image Processing ToolboxTM 7 User's Guide
How to Contact The MathWorks
Web Newsgroup www. mathworks. com/contact_TS. html Technical Support
www. mathworks. com comp. soft-sys. matlab suggest@mathworks. com bugs@mathworks. com doc@mathworks. com service@mathworks. com info@mathworks. com
Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information
508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site. Image Processing ToolboxTM User's Guide © COPYRIGHT 19932010 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. [. . . ] bwconncomp replaces the use of bwlabel and bwlabeln. It uses significantly less memory and is sometimes faster than the older functions. Input Dimension 2-D N-D N-D Output Form Double-precision label matrix Double-precision label matrix
CC struct
Function
bwlabel bwlabeln bwconncomp
Memory Use High High Low
Connectivity 4 or 8 Any Any
To extract features from a binary image using regionprops with default connectivity, just pass BW directly into regionprops, i. e. ,
regionprops(BW).
To compute a label matrix having a more memory-efficient data type (e. g. , uint8 versus double), use the labelmatrix function on the output of bwconncomp:
C = bwconncomp(BW); L = labelmatrix(CC); CC = bwconncomp(BW, conn); S = regionprops(CC);
Class Support Example
BW can be numeric or logical, and it must be real and nonsparse. L is of class double.
Calculate the centroids of the 3-D objects.
BW = cat(3, [1 1 0; 0 0 0; 1 0 0], . . .
17-54
bwlabeln
[0 1 0; 0 0 0; 0 1 0], . . . [0 1 1; 0 0 0; 0 0 1]) bwlabeln(BW) ans(:, :, 1) = 1 0 2 1 0 0 0 0 0
ans(:, :, 2) = 0 0 0 1 0 2 0 0 0
ans(:, :, 3) = 0 0 0 1 0 0 1 0 2
Algorithm
bwlabeln uses the following general procedure:
1 Scan all image pixels, assigning preliminary labels to nonzero pixels
and recording label equivalences in a union-find table.
2 Resolve the equivalence classes using the union-find algorithm [1]. 3 Relabel the pixels based on the resolved equivalence classes.
See Also
bwconncomp, bwlabel, labelmatrix, label2rgb, regionprops
17-55
bwlabeln
Reference
[1] Sedgewick, Robert, Algorithms in C, 3rd Ed. , Addison-Wesley, 1998, pp. 11-20.
17-56
bwmorph
Purpose Syntax Description
Morphological operations on binary images
BW2 = bwmorph(BW, operation) BW2 = bwmorph(BW, operation, n) BW2 = bwmorph(BW, operation) applies a specific morphological operation to the binary image BW. BW2 = bwmorph(BW, operation, n) applies the operation n times. n can be Inf, in which case the operation is repeated until the image
no longer changes.
operation is a string that can have one of the values listed below.
Operation
'bothat'
Description 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 'bridge' 0 0 1 0 0 1 1 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
becomes
Bridges unconnected pixels, that is, sets 0-valued pixels to 1 if they have two nonzero neighbors that are not connected. For example:
1 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 1 1
becomes
17-57
bwmorph
Operation
'clean'
Description Removes isolated pixels (individual 1s that are surrounded by 0s), such as the center pixel in this pattern.
0 0 0 0 1 0 0 0 0
'close' 'diag'
Performs morphological closing (dilation followed by erosion). Uses diagonal fill to eliminate 8-connectivity of the background. For example:
0 1 0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0
becomes
'dilate' 'endpoints'
Performs dilation using the structuring element
ones(3).
Finds end points of skeleton. For example:
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
becomes
'erode'
Performs erosion using the structuring element
ones(3).
17-58
bwmorph
Operation
'fill'
Description Fills isolated interior pixels (individual 0s that are surrounded by 1s), 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 0 1 1 1 1 1 0 1 1 0 1 1 0 1 1 0 1
becomes
'majority'
Sets a pixel to 1 if five or more pixels in its 3-by-3 neighborhood are 1s; otherwise, it sets the pixel to 0. Performs morphological opening (erosion followed by dilation). This option sets a pixel to 0 if all its 4-connected neighbors are 1, thus leaving only the boundary pixels on. With n = 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. With n = 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.
'open' 'remove'
'shrink'
'skel'
17-59
bwmorph
Operation
'spur'
Description Removes spur pixels. [. . . ] Value (X, Y, or Z)
0. 0 1. 0 1. 0 + (32767/32768)
uint16 Value
0 32768 65535
Class Support Examples
xyz is a uint16 or double array that must be real and nonsparse. xyzd is of class double.
Convert uint16-encoded XYZ values to double.
xyz2double(uint16([100 32768 65535])) ans = 0. 0031 1. 0000 2. 0000
See Also
applycform, lab2double, lab2uint16, lab2uint8, makecform, whitepoint, xyz2uint16
For a full list of the toolbox color space conversion functions, see "Color Space Conversions" on page 16-22.
17-687
xyz2uint16
Purpose Syntax Description
Convert XYZ color values to uint16
xyz16 = xyz2uint16(xyz) xyz16 = xyz2uint16(xyz) converts an M-by-3 or M-by-N-by-3 array of XYZ color values to uint16. xyz16 has the same size as xyz.
The Image Processing Toolbox software follows the convention that double-precision XYZ arrays contain 1931 CIE XYZ values. XYZ arrays that are uint16 follow the convention in the ICC profile specification (ICC. 1:2001-4, www. color. org) for representing XYZ values as unsigned 16-bit integers. [. . . ]