Image Segmentation using MATLAB Digital Images Processing Computer Vision python openCV machine learning deep learning

Image segmentation Using MATLAB
Digital Images Processing Using MATLAB

What is segmentation?


Image segmentation is the process of partitioning an image into a collection of connected sets of pixels. The goal of segmentation is to simplify change the representation of an image into something that is more meaningful and easier to analyses. Image segmentation is typically used to locate objects and boundaries like lines, curves in images. It is the process of assigning a label to every pixel in an image. 

Three main techniques to do.
Thresholding
Region based segmentation
Edge based segmentation


Thresholding


Thresholding is finding histogram of gray level intensity.


Types
Basic Global Thresholding
Multiple Threshold
Variable Thresholding
Otsu’s Technique
Basic Global Thresholding
Primarily Segment image use:

Calculate the average intensity m1 and m2 for the pixels

Calculate a fresh threshold:       

Until the variance between values of T is minor than a predefined parameter.


Otsu’s Technique
Based on a very simple idea: Find the threshold that minimizes the weighted within-class variance. 
This turns out to be the same as maximizing the between-class variance.
Operates directly on the gray level histogram.

Multiple Threshold
As Otsu’s technique, it takes extra area and k* 




Disadvantage:
It becomes too complex when amount of region more than two or three.  


Variable Thresholding
Image partitioning


It is work once the objects of interest and the background inhabit areas of sensibly similar size. If not, it will fail.
Variable thresholding based on local image properties
By moving average
It debated is based on computing a moving average along scan appearances of an image.



Region based segmentation

Region Segmentation is procedure of finding region, but not finding edge


Region Growing
Cheng-Jin Kuo`s method is used
Data Grouping (Clustering Technique)
Partitional clustering


Algorithm:
Select a random pixels
Usage 8-connected and threshold to decide
Repeat a and b until nearly points are classified.

Reproduction of region growing (90% pixels )
Threshold/second: 20/4.7 seconds.



Data Clustering
Using centroid to signify the huge amounts of clusters
Partitional clustering, we have to choose the number of clustering we want first before we begin the process.
Hierarchical clustering, we can alteration the number of cluster anytime throughout process if we need.
Hierarchical clustering
Algorithm of hierarchical accumulation (built)
Understand every solo data as a cluster Ci
Find out Ci, Cj for the distance is the shortest.
Repeat the steps until satisfies our request.
d(a,b) as the space between data a and b
Algorithm of hierarchical division (break up ):
 Diameter of cluster  




Partitional clustering
Choose the numbers of the cluster (k-means)




ADVANTAGES & DISADVANTAGES
Hierarchical algorithm
Advantages
Result is reliable
Idea is simple
Disadvantages
It is consuming, so is not suitable for a big database.

Partitional algorithms
Advantages
Numbers of cluster is fixed, so the concept is also simple.
Calculating speed is fast.
Disadvantages 
Determine the number of clusters.
Initial problem




Edge based segmentation

Edge-Based Segmentation
Edge-Based Segmentation is by mask to notice edge in image by convolution.






Basic Edge Detection
SRHLT - Short response Hilbert transform
Watersheds
The Marr Hildreth edge detector (LoG)
Basic Edge Detection                



Gradient
Gradient is to find edge strength and direction at site (x,y) of image.

The magnitude of vector, meant as M(x,y)

The direction of the gradient vector is assumed by the angle


Roberts 
Robert edge detection, the perpendicular and horizontal edges carry out separately and then place together for resulting edge detection. The Roberts edge detector uses the next masks to approximate digitally the first derivatives as differences between adjacent pixels.  



Prewitt operator
Prewitt operator edge detection masks are the one of the oldest and greatest understood methods of detecting edges in images The Prewitt edge detector uses the following mask to approximate digitally the first derivatives Gx and Gy.

Sobel operator
The sobel edge detector calculates the gradient by using the discrete differences between rows and columns of a 3X3 neighborhood. The sobel operator is based on convolving the image with a minor, divisible, and number valued filter.




Canny Edge Detection
Canny edge detection is a multistage algorithm to detect a extensive range of edges in images. This detector finds edges by observing for local maxima of the gradient off (x, y). The gradient is calculated using the derivative of a Gaussian filter. The technique uses two thresholds to detect strong and weak edges and includes the weak edges in the output only if they are connected to strong edges


The Marr-Hildreth edge detector (LoG)
This is second-order deviation, known as Laplacian.

Filter the input image with an n*n Gaussian low pass filter. 99.7% of the capacity under a 2-D Gaussian surface lies between around the mean.





Short response Hilbert Transform (SRHLT)
Hilbert transform










Short response Hilbert transform (SRHLT)





















Watersheds










Algorithm:



Markers
Outside markers:
Points along the watershed line along maximum points.
Interior markers: 
All points in connected component have the similar intensity.
Points in area form a connected component 
That is surrounded higher points.




MATLAB Source Code For Image Segmentation

Flow Chart 

%IMAGE SEGMENTATION
clc;
clear all;
close all;
%edge detection
a=imread('autumn.tif');
b=rgb2gray(a);
figure(1);
imshow(b);
title('original image');

%roberts operator
c=edge(b,'roberts');
figure(2);
imshow(c);
title('roberts image');

%sobel operator
d=edge(b,'sobel');
figure(3);
imshow(d);
title('sobel image');

%prewitt operator
e=edge(b,'prewitt');
figure(4);
imshow(e);
title('prewitt image');
%log operator
f=edge(b,'log');
figure(5);
imshow(f);
title('log image');

%canny operator
g=edge(b,'canny');
figure(6);
imshow(g);
title('canny image');

%point detection
h=[0,1,0;1,-4,1;0,1,0];
i=imfilter(b,h,'symmetric','conv');
figure(7);
imshow(i);
title('laplacian point filtered image');

%line detection
j=im2bw(b);
w=(1/3)*[1,0,-1;1,0,-1;1,0,-1];
k=imfilter(double(j),w);
k(k<1)=0;
figure(8);
imshow(k);
title('line detection image');


Output for Image Segmentation

Fig.1 Original Image

Fig.2. Gray Scale image



Fig.3. Robert image

Fig.4. Sobel Image



Fig.5. Prewitt Image




Fig.6. Log image

Fig.7. Canny Image



Fig.8. Laplacian Point Filtering Image

Fig.9. line detection Image


Application

Real-world applications of image segmentation are:
Machine vision
Deep Learning
Medical imaging, including volume rendered images from CT (Computed Tomography) and MRI (Magnetic Resonance Imaging).
Measure tissue volumes
Surgery planning
Intra-surgery navigation
Locate tumors and pathologies 
Virtual surgery simulation
Diagnosis, learning of anatomical structure 
Pedestrian recognition
Object recognition
Face detection
Face recognition
Recognition Tasks
Fingerprint recognition
Iris recognition
Traffic controller schemes
Brake light detection
Video investigation
Find objects in satellite images like roads, forests, crops.


Conclusion
Since edge detection is the first step in object boundary extraction and object recognition, it is significant to know the differences between different edge detection operators. from this section an attempt is made to review the edge detection methods which are based on discontinuity intensity levels. The relative presentation of various edge detection techniques is carried out with two images by using MATLAB. It have been experiential that that the Canny edge detector produces greater accuracy in detection of object edges with greater entropy, PSNR, MSE and  implementation time compared with Sobel, Roberts, Prewitt, Zero crossing and LOG.  

Comments

Popular posts from this blog

Spatial Intensity Resolution Project Using MATLAB with Source Code

Image Intensity Transformation Using MATLAB with Source Code

Histogram Equalization Project Using MATLAB with Source Code