bweuler

Euler number of binary image

Description

example

eul = bweuler(BW,conn) returns the Euler number for the binary image BW. The Euler number is the total number of objects in the image minus the total number of holes in those objects. conn specifies the connectivity. Objects are connected sets of on pixels, that is, pixels having a value of 1.

Examples

collapse all

Read binary image into workspace, and display it.

BW = imread('circles.png');
imshow(BW)

Calculate the Euler number. In this example, all the circles touch so they create one object. The object contains four "holes", which are the black areas created by the touching circles. Thus the Euler number is 1 minus 4, or -3.

bweuler(BW)
ans = -3

Input Arguments

collapse all

Binary image, specified as a 2-D, real, nonsparse, numeric or logical matrix. For numeric input, any nonzero pixels are considered to be on.

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

Connectivity, specified as the values 4, for 4-connected objects, or 8, for 8-connected objects.

Example: BW = imread('text.png'); L = bweuler(BW,4);

Data Types: double

Output Arguments

collapse all

Euler number, returned as a numeric scalar.

Data Types: double

Algorithms

bweuler computes the Euler number by considering patterns of convexity and concavity in local 2-by-2 neighborhoods. See [2] for a discussion of the algorithm used.

References

[1] Horn, Berthold P. K., Robot Vision, New York, McGraw-Hill, 1986, pp. 73-77.

[2] Pratt, William K., Digital Image Processing, New York, John Wiley & Sons, Inc., 1991, p. 633.

Extended Capabilities

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

See Also

|

Introduced before R2006a