Image Segmentation in Color Space By Anisa Chaudhary
So what Is Image Segmentation? • Partitioning an image into its several constituents is called • “Segmentation”. • Segmentation is the fundamental step in analyzing and • Understanding Images.It may be defined as decomposing an • image into its constituent parts extracting the location and the • outline of Objects Of interests. Example:
And what is color Segmentation? • The Techniques for Image segmentation can be extended to • Colored Images.I • The • ages • The Common approaches for Color Segmentation are : • Pixel Based Segmentation • Thresholding with Pixel Value Average . • Clustering K-means Algorithm • Area Based Segmentation • Region Growing • Edge Based Segmentation • Physics Based Segmentation
What am I doing? My projects works with six example Images and four Segmentation algorithms which segments color images. I implemented these different segmentation algorithms on each of the six image and finally compared all the algorithms. The algorithms used in my project are: Watershed algorithm Kmeans clustering algorithm and Region growing Algorithm. Finally I have implemented the simple histogram thresholding as well. I have used GUI in Matlab to implement and compare the algorithms.
What about GUI? (Or Graphical User Interface) GUIDE , the Matlab Graphical User Interface development environment provides a set of tools such as pushbutton , axes ,Slides etc. The shown figure is a Layout Editor which is the control panel for all GUIDE tools. It enables you to Layout a GUI quickly and easily by Dragging components as axes, textbox from the component palette into the layout area. You can program the GUI with the M-file Editor and when you press RUN the functioning GUI appears outside the Layout Editor window
My Matlab Demo • My slides have two axe first one • displays the Original image and • And the second displays the • Segmented image. • You select an image by clicking on • the required image name in the list • box and the following figure is • loaded in the first axes. • Click on the “segment” pushbutton, • the original image gets segmented • and is displayed in the second box. • The “quit” pushbutton closes the • image
Watershed Algorithm(Algorithm 1) Watershed Segmentation gets its name from the manner in which the algorithm segment regions into Catchement basins The term watershed refers to a ridge that divides areas drained by different river systems. A catchment basin is the geographical area draining into a river or reservoir. The watershed transform requires that you think of an image as a surface If you imagine that bright areas are "high" and dark areas are "low," then it might look like the surface (left). With surfaces, it is natural to think in terms of catchment basins and watershed lines.
The key behind using the watershed transform for segmentation is this: Change your image into another image whose catchment basins are the objects you want to identify. • Steps in Watershed Algorithm: • Read in an Image and covert it in grayscale • Use the gradient magnitude as the segmentation function • Mark the foreground objects • Compute the Background markers • Compute the watershed transform of the segmentation function • Visualize the result. • p 2: Use the gradient magnitude as the segmentation function
But What If: 1. Read an image and convert it to gray scale 2. Use the gradient magnitude as the segmentation function Use the Sobel edge masks, “imfilter”, and some simple arithmetic to compute the gradient magnitude. The gradient is high at the borders of the objects and low (mostly) inside the objects. Can you segment the image by using the watershed transform directly on the gradient magnitude? No. Without additional preprocessing such as the marker computations below, using the watershed transform directly often results in "oversegmentation”.
Algorithm1 How my Watershed Algorithm proceeds on First image:
Another useful visualization technique is to display the label matrix as a color image in Watershed Algorithm . Label matrices, such as those produced by watershed and “bwlabel”, can be converted to truecolor images for visualization purposes by using “label2rgb” Example::
Clustering Algorithm (Algorithm 2) The main objective of clustering is to find similarities between experiments or genes and then group similar samples or genes together to assist in understanding relationships that might exist among them. Cluster analysis is based on a mathematical formulation of a measure of similarity. Some of the Clustering methods are as follows: • Agglomerative Hierarchical • Self Organizing maps • K-Mean • Jarvis-Patrick • ggloameHierarcal • elf Organizingaps
K-means Clustering Algorithm K-Means clustering generates a specific number of disjoint, flat (non-hierarchical) clusters. It is well suited to generating globular clusters .The K-Means method is numerical, unsupervised, non-deterministic and iterative • The K-Means Algorithm Process • The dataset is partitioned into K clusters and the data points are randomly assigned to the clusters resulting in clusters that have roughly the same number of data points. • For each data point: • Calculate the distance from the data point to each cluster. • If the data point is closest to its own cluster, leave it where it is. If the data point is not closest to its own cluster, move it into the closest cluster. • Repeat the above step until a complete pass through all the data points results in no data point moving from one cluster to another. At this point the clusters are stable and the clustering process ends. • The choice of initial partition can greatly affect the final clusters that result, in terms of inter-cluster and intracluster distances and cohesion.
Algorithm 2 Slides Algorithm 2 on all the images
Region Growing Algorithm (Algorithm 3) From Dr. Latecki Website
Histogram Thresholding (Algorithm 4) If we take the histogram of the colored images , it can be seen that the images would have multiomodal histogram and therefore the simple thresholding does not hold good for them . The histogram has to analyzed and by hit and trial method the threshold value has to be determined. Therefore a new method is used here which chooses the Threshold value to be the pixel average value.
Results???? • After trying the three Segmentation algorithms on six images , • I have the following results:: • In the K-means Algorithm • images were segmented neatly. • But It takes a minimum of 1:30 min for each image • because of the iterations procedure that it performs. • Watershed Algorithm is fastest of all the three segmentation • Algorithms . • Visualization techniques using label2rgb worked for only one image • And for the rest of the image gave one color blank images
Region Growing Algorithm is • Simpler • but it has the problem of leakage in its segmented image. • It takes more time than both the above algorithms • In the Histogram Thresholding Algorithm • It is Simpler • It is faster • Segmentation is good
Conclusions! K-means Algorithm worked the best for me on the given images when we compare how well the images were segmented. But if we compare the time taken by each algorithm , Watershed algorithm worked best for me. The watershed transform is often applied to the problem where there are separate touching objects in the image. Example: The worst algorithm in both time and segmentation is Region Growing Algorithm