Video length is 2:22

How to Segment Images Using Color Thresholding

Learn how to develop image processing algorithms that segment images based on their color. This video shows how to use the MATLAB® Color Thresholder app to create image masks and MATLAB functions that segment images based on their color components in multiple color spaces. The image maps and segmentation parameters can be reused for the development of image processing algorithms.

Published: 31 Oct 2019

In this video you will learn how to segment images using color thresholding. We will use the MATLAB Color Thresholder app included in Image Processing Toolbox to create image masks and processing algorithms that will segment images based on their color components.

You can find the Color Thresholder app under the image processing section of the MATLAB Apps menu.

Load the desired image into the app by selecting an image file, a MATLAB workspace variable or by capturing a snapshot using an available webcam. Images can be segmented using any of the four available color spaces, and a point cloud preview is provided showcasing the distribution of color components for each of the color spaces.

Once a color space is selected, you can create an image mask by using the polygon selection tool and identifying a region of interest on the image preview. To further adjust the individual color thresholds for the mask, interact with the color component sliders provided on the top right region of the app. Additionally, you can draw one or multiple polygons on the point cloud preview figure to further refine the segmentation of the image mask.

Different color spaces may provide better segmentation results, depending on the application and input images. Explore different segmentation color spaces by adding new color spaces to the app session and adjusting new point cloud regions and color component components, until you obtain the image mask desired.

Save the segmented image masks by exporting variables to your MATLAB workspace that contain either the binary mask or the masked input image. To mask input images with the settings derived using the app, you can export the current segmentation settings to a MATLAB function that will receive an RGB image as an input and output the binary and RGB image masks.

For more information on how to use the MATLAB Color Thresholder app, see the documentation link in the video description, and to further explore image processing and segmentation algorithms, make sure to navigate to the Image Processing Toolbox product page.