Image segmentation is a commonly used technique in digital image processing and analysis to partition an image into multiple parts or regions, often based on the characteristics of the pixels in the image. Image segmentation could involve separating foreground from background or clustering regions of pixels based on similarities in color or shape. For example, a common application of image segmentation in medical imaging is to detect and label pixels in an image or voxels of a 3D volume that represent a tumor in a patient’s brain or other organs.
Why Image Segmentation Is Important
Several algorithms and techniques for image segmentation have been developed to effectively solve segmentation problems using domain-specific knowledge. These applications include medical imaging, autonomous driving, video surveillance, and machine vision.
Medical Imaging
Segmentation and analysis have important applications for clinical diagnosis, treatment planning, and medical research. Use segmentation to label and analyze organs, tumors, cells, implants, or other regions of interest. For example, you can use radiomics to classify a tumor as cancerous or benign, and then measure tumor growth in follow-up scans. Alternatively, you can track the position and morphology of cells in segmented microscopy images, or analyze bone density in a pharmaceutical trial. Segmentation masks can also be used to generate 3D anatomical models for applications such as 3D printing and finite element analysis, which are useful for patient-specific surgical planning.
Autonomous Driving
When designing perception for autonomous vehicles, such as self-driving cars, semantic segmentation is often applied to enable the system to identify and locate vehicles and other objects on the road.
How Image Segmentation Works
The first step in image segmentation involves converting an image into a collection of regions of pixels that are represented by a mask or a labeled image. By dividing an image into segments, you can select and then process only the important segments of the image instead of processing the entire image.
A common technique is to look for abrupt discontinuities in pixel values, which typically indicate edges that define a region.
Another common approach is to detect similarities in the regions of an image. Some techniques that follow this approach are region growing, clustering, and thresholding.
Image Segmentation with MATLAB
With MATLAB®, you can:
- Use apps to interactively explore different segmentation techniques
- Simplify image analysis workflows using built-in image segmentation algorithms
- Perform deep learning for image segmentation
Using Apps to Interactively Threshold Images
Image Segmenter App
Using the interactive Image Segmenter app, you can iteratively try several methods to segment an image to achieve the desired result. For example, you can use the app to segment and further refine the images of a car.
Color Thresholder App
The Color Thresholder app lets you apply thresholding to color images by manipulating the color of the images interactively, based on different color spaces. For example, with the Color Thresholder app you can create a binary mask using point cloud controls for a color image.
Using the Color Thresholder app to apply color segmentation to separate the birds in the foreground from the background.
Using a Variety of Image Segmentation Techniques
With functions in MATLAB and Image Processing Toolbox™, you can experiment and build expertise in different image segmentation techniques, including thresholding, clustering, graph-based segmentation, and region growing, as well as deep learning techniques, such as with the Segment Anything Model.
Thresholding
To create a binary image, you can use the imbinarize
function to perform thresholding on a 2D or 3D grayscale image. To produce a binary image from an RGB color image, use the rgb2gray
function to first convert it to a grayscale image.
Clustering
This technique lets you create a segmented labeled image using a specific clustering algorithm. Using K-means clustering–based segmentation, imsegkmeans
segments an image into clusters within a color space.
Graph-Based Segmentation
Graph-based segmentation techniques like lazy snapping enable you to segment an image into foreground and background regions. MATLAB lets you perform this segmentation on your image either programmatically (lazysnapping
) or interactively using the Image Segmenter app.
Region Growing
Region growing is a simple region-based (also classified as a pixel-based) image segmentation method. A popularly used algorithm is activecontour
, which examines neighboring pixels of initial seed points and determines iteratively whether the pixel neighbors should be added to the region. You can also perform this segmentation on images using the Image Segmenter app.
Using the Image Segmenter app to perform region growing.
Deep Learning for Image Segmentation
Using convolutional neural networks (CNNs), a deep learning technique called semantic segmentation lets you associate every pixel of an image with a class label. Applications for semantic segmentation include autonomous driving, industrial inspection, robotics, medical imaging, and satellite image analysis. See the Semantic Segmentation Using Deep Learning example to learn more.
You can design and train semantic segmentation networks with a collection of images and their corresponding labeled images, and then use the trained network to label new images. To label the training images, you can use the Image Labeler, Video Labeler, or Ground Truth Labeler apps.
Resources
Expand your knowledge through documentation, examples, videos, and more.
Related Topics
Explore similar topic areas commonly used with MATLAB and Simulink products.
30-Day Free Trial
Get startedSeleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)