Read and display a grayscale image.
Segment the sky in the image by using the flood-fill technique. Select a pixel in the sky to be the seed location. This example uses the pixel with (row, column) coordinate (50, 50). Call the grayconnected
function, specifying the image to be segmented and this seed location.
Display the segmented region in color over the original image by using the labeloverlay
function. The segmented region includes sky pixels that are 8-connected to the seed pixel. The region does not include pixels of similar intensity that are disconnected, such as the sky visible between the legs of the tripod.
Segment the jacket of the cameraman by using the flood-fill. Select a pixel in the jacket to be the seed location. This example specifies the seed pixel with (row, column) coordinate (110, 65). Call the grayconnected
function, specifying the image to be segmented and this seed location.
Display the segmented image in color over the original image. The segmented region includes all pixels that are 8-connected to the seed pixel. The tripod and the hair of the cameraman have similar intensity to the jacket, so they are included in the segmented region.