Active Contours – A Method for Image Segmentation in Computer Vision
This article was published as a part of the Data Science Blogathon
In simple terms, Computer vision means providing human-like vision to the computer. As human beings, it is very easy for us to recognize any object. We can easily recognize hills, trees, land, animals, etc. but computers do not have eyes nor brains, so it becomes difficult for them to recognize any image. The computer can only understand commands and mathematics. So, there are many techniques to make computers recognize various objects. Image Segmentation is one of the methods for object detection.
What is Image segmentation?
Image segmentation means partitioning the input image, by clustering pixel values of the image. It is mainly used for identifying various surfaces or living or nonliving objects from an image. For, Example if you have the following image as an input, then you can have tiger, green grass, blue water, and land as various surfaces in your output image.
[Figure 1: Image and segmented image ]
There are various image segmentation techniques like Active contours, split & merge, watershed, region splitting, region merging, graph-based segmentation, mean shift and model finding, and Normalized cut.
This article explains one of the most useful image segmentation techniques called Active Contours.
What are Active Contours?
Active contour is a segmentation method that uses energy forces and constraints to separate the pixels of interest from a picture for further processing and analysis.
Active contour is defined as an active model for the segmentation process. Contours are the boundaries that define the region of interest in an image. A contour is a collection of points that have been interpolated. The interpolation procedure might be linear, splines, or polynomial, depending on how the curve in the image is described.
Why Active Contours is needed?
The primary use of active contours in image processing is to define smooth shapes in images and to construct closed contours for regions. It is mainly used to identify uneven shapes in images.
Active contours are used in a variety of medical image segmentation applications. Various forms of active contour models are employed in a variety of medical applications, particularly for the separation of desired regions from a variety of medical images. A slice of a brain CT scan, for example, is examined for segmentation using active contour models.
How does Active Contour work?
Active contours are the technique of obtaining deformable models or structures in an image with constraints and forces for segmentation. Contour models define the object borders or other picture features to generate a parametric curve or contour.
The curvature of the models is determined using several contour techniques that employ external and internal forces. The energy function is always related to the image’s curve. External energy is described as the sum of forces caused by the picture that is specifically used to control the location of the contour onto the image, and internal energy, which is used to govern deformable changes.
The contour segmentation constraints for a certain image are determined by the needs. The desired shape is obtained by defining the energy function. A collection of points that locate a contour is used to describe contour deformation. This shape corresponds to the desired image contour, which was defined by minimizing the energy function.
Active Contour Segmentation Models
1. Snake Model
The snake model is a technique that has the ability to solve a broad range of segmentation problems. The model’s primary function is to identify and outline the target object for segmentation. It requires some prior knowledge of the target object’s shape, especially for complicated things. Active snake models, often known as snakes, are generally configured by the use of spline focused on minimizing energy, followed by various forces governing the image.
A simple snake model can be denoted by a set of n points, vi for i=0,….n-1, the internal elastic energy term EInternal and the external edge-based energy term Eexternal. The internal energy term’s aim is to regulate the snake’s deformations, while the exterior energy term’s function is to control the contour’s fitting onto the image. The external energy is typically a combination of forces caused by the picture Eimage and constraint forces imposed by the user Econ.
The applications of the active snake model are expanding rapidly, particularly in the many imaging domains. In the field of medical imaging, the snake model is used to segment one portion of an image that has unique characteristics when compared to other regions of the picture. Traditional snake model applications in medical imaging include optic disc and cup segmentation to identify glaucoma, cell image segmentation, vascular region segmentation, and several other regions segmentation for diagnosis and study of disorders or anomalies.
The conventional active snake model approach has various inefficiencies, such as noise sensitivity and erroneous contour detection in high-complexity objects, which are addressed in advanced contour methods.
2. Gradient Vector Flow Model
The gradient vector flow model is a more developed and well-defined version of the snake or active contour models. The traditional snake model has two limitations: inadequate contour convergence for concave borders and when the snake curve flow is commenced at a great distance from the minimum. As an extension, the gradient vector flow model uses the gradient vector flow field as an energy constraint to determine the contour flow.
In 2D, the GVF vector field FGVF minimizes the energy functional
where ‘μ’ is a controllable smoothing term.
The gradient vector flow model is an advanced version of the snake model that is used for various image processing applications, especially in medical image processing. The segmentation of regions with particular parameters in medical imaging is done with the help of active contour models. Because these models create a contour around the target object, it is separated from the image.
The main difficulty with utilizing GVF is that the smoothing term ‘μ’ causes the contour’s edges to round. Reducing the value of ‘μ’ minimizes rounding but increases the amount of smoothing.
3. Balloon Model
A snake model isn’t drawn to far-off edges. If no significant image forces apply to the snake model, its inner side will shrink. A snake that is larger than the minima contour will eventually shrink into it, whereas a snake that is smaller than the minima contour will not discover the minima and will instead continue to shrink. To address the constraints of the snake model, the balloon model was developed, in which an inflation factor is incorporated into the forces acting on the snake. The inflation force can overwhelm forces from weak edges, exacerbating the problem with first guess localization.
Inflation term into the forces acting on the snake is introduced in the balloon model.
where n(s) is the normal unitary vector of the curve at v(s) and k1 is the magnitude of the force.
The balloon concept is used to segment various medical pictures. The application’s primary purpose is to propose a novel technique for segmenting 2-D images and reconstructing 3-D meshes that ensures a watertight mesh.
The balloon model’s biggest problem is its slow processing, which makes it difficult to manage sharp edges and requires careful object placement. The balloon model is commonly used in analyzing picture contour extraction.
4. Geometric or geodesic active contour models
Geometric active contour (GAC) is a form of contour model that adjusts the smooth curve established in the Euclidean plan by moving the curve’s points perpendicular. The points move at a rate proportionate to the curvature of the image’s region. The geometric flow of the curve and the recognition of items in the image are used to characterize contours. Geometric flow encompasses both internal and external geometric measures in the region of interest. In the process of detecting items in an image, a geometric replacement for snakes is utilized. These contour models rely heavily on the level set functions that specify the image’s unique regions for segmentation.
For example, the gradient descent curve evolution equation of GAC is
where g(I) is a halting function, c is a Lagrange multiplier, K is the curvature, and vector N is the unit inward normal. This particular form of curve evolution equation is only dependent on the velocity in the normal direction. It, therefore, can be rewritten equivalently in an Eulerian form by inserting the level set function φ into it as follows
Geometric active contours are mostly used in medical image computing, particularly image-based segmentation. In this case, any imaging modality’s picture is examined for segmentation in order to research, process, and analyze the regions of interest. These regions include any aberration that forms in the interior regions or organs of the human body, such as blood clots, traumas, lesions, cell abnormalities, metabolic interruptions, biomolecule disruptions, and so on.
Mostly it has no such inefficiencies but they are difficult to implement as they are complex in nature.
Implementation of Snake model using Active Contours
The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.
Frequently Asked Questions
A. Active contour segmentation, also known as “snake” or “snakes,” is a computer vision technique used for object boundary detection in images. It involves creating an initial contour near the object’s boundary and iteratively adjusting its position to fit the edges of the object accurately. The contour evolves based on forces derived from image gradients, internal energy, and external constraints. Active contour segmentation is particularly useful in cases where traditional methods like thresholding or edge detection might fail, as it can handle complex object shapes and partial occlusions by adaptively adjusting the contour’s shape to the object’s edges.
A. Active contour segmentation can be employed in various computer vision applications, such as medical image analysis (e.g., organ segmentation in MRI scans), object tracking in videos, image editing (e.g., precise object isolation for photo manipulation), and industrial automation (e.g., defect detection on manufactured items). It excels in cases where accurate boundary delineation of objects with complex shapes and varying contrasts is necessary.