You are here : matlabImage Processinggrayconnected

grayconnected() - Image Processing

BW = grayconnected(I,row,column) finds
connected regions of similar intensity in the grayscale image I.
You specify the intensity value to use as a starting point, the seed
pixel, by row and column indices.
By default, grayconnected includes connected pixels
with values in the range [seedpixel–32,seedpixel+32] for
integer-valued images and within the range [seedpixel-0.1,seedpixel+0.1] for
floating point images. grayconnected returns a
binary mask image, BW, where all of the foreground
pixels are 8-connected to the seed pixel at (row, column)
by pixels of similar intensity.exampleBW = grayconnected(I,row,column,tolerance) finds
connected regions of similar intensity in a grayscale image, where tolerance specifies
the range of intensity values to include in the mask, as in [(seedpixel-tolerance),(seedpixel+tolerance)]. Code Generation support:
Yes.MATLAB Function Block support:
Yes.


Syntax

BW = grayconnected(I,row,column) exampleBW = grayconnected(I,row,column,tolerance) example


Example

Create Binary Mask from Connected PixelsOpen This Example
Create small sample image.I = uint8([20 22 24 23 25 20 100
           21 10 12 13 12 30 6
           22 11 13 12 13 25 5
           23 13 13 13 13 20 5
           24 13 13 12 12 13 5
           25 26  5 28 29 50 6]);
Create mask image, specifying the seed location by row and column and the tolerance. Since the seed location specifies the pixel with the value 23 and the tolerance is 3 , the range of grayscale values is [20,26].seedrow = 4
seedcol = 1
tol = 3
BW = grayconnected(I,seedrow,seedcol,tol)

seedrow =

     4


seedcol =

     1


tol =

     3


BW =

     1     1     1     1     1     1     0
     1     0     0     0     0     0     0
     1     0     0     0     0     0     0
     1     0     0     0     0     0     0
     1     0     0     0     0     0     0
     1     1     0     0     0     0     0


Output / Return Value


Limitations


Alternatives / See Also


Reference