Color Image Segmentation
this example as a Mathematica notebook. |
Processing allows you to manipulate color images as conveniently
and easily as monochrome images. Color images may be represented in three different
color formats and two different color interleaving methods, allowing you to select the
most appropriate format for any color processing application.
We use amplitude thresholding and masking to segment an example image according to
color features. In particular, we are interested in extracting the yellow beans from
the "bean" image.
This reads a color image.
Here are the histograms of the individual color channels.
This applies thresholding to the individual color channels. The threshold values were
chosen based on a visual inspection of the histograms.
We now find all the image regions that do not have yellow-colored pixels.
We use the ImageProcessing function Where.
We now use RegionProcessing to set all non-yellow pixels in the original
"bean" image to the background color. This is basically a masking operation, but it
may also be implemented as a matrix multiplication operation.
We "clean" the resulting color image with a compact morphological filter to reduce small,
isolated color patches.
Here we display the original and segmented images.