CH 08

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Digital Image Processing

Image Segmentation

Chapter 08

Asst. Prof. Abdulle Hassan


Image Segmentation
Segmentation divides an image into its constituent
regions or objects.

Segmentation of images is a difficult task in image


processing. Still under research.

Segmentation allows to extract objects in images.


Segmentation is unsupervised learning.

Model based object extraction, e.g., template


matching, is supervised learning.
What it is useful for
After a successful segmenting the image, the contours of
objects can be extracted using edge detection and/or
border following techniques.

Shape of objects can be described.

Based on shape, texture, and color objects can be


identified.

Image segmentation techniques are extensively used in


similarity searches, e.g.:
http://elib.cs.berkeley.edu/photos/blobworld/
Segmentation Algorithms
Segmentation algorithms are based on one of two
basic properties of color, gray values, or texture:
discontinuity and similarity.

First category is to partition an image based on


abrupt changes in intensity, such as edges in an
image.

Second category are based on partitioning an


image into regions that are similar according to a
predefined criteria. Histogram thresholding
approach falls under this category.
Domain spaces

• Spatial domain (row-column (rc) space)

• Histogram spaces

• Color space

• Texture space

• Other complex feature space


Clustering in Color Space
1. Each image point is mapped to a point in a color
space, e.g.:

Color(i, j) = (R (i, j), G(i, j), B(i, j))

It is many to one mapping.

2. The points in the color space are grouped to clusters.

3. The clusters are then mapped back to regions in the


image.
Examples
Original pictures segmented pictures

Mnp: 30, percent 0.05, cluster number 4

Mnp : 20, percent 0.05, cluster number 7


Displaying objects in the
Segmented Image

The objects can be distinguished by


assigning an arbitrary pixel value or
average pixel value to the pixels
belonging to the same clusters.
Thus, one needs clustering algorithms
for image segmentation.

Homework 8:

Implement in Matlab and test on some example images the


clustering in the color space.
Use Euclidean distance in RGB color space.
You can use k-means, PAM, or some other clustering algorithm.
Links to k-means, PAM, data normalization

Test images: rose, plane, car, tiger, landscape


Segmentation by Thresholding
Suppose that the gray-level histogram
corresponds to an image f(x,y) composed of dark
objects on the light background, in such a way
that object and background pixels have gray levels
grouped into two dominant modes.

One obvious way to extract the objects from the


background is to select a threshold ‘T’ that
separates these modes.

Then any point (x,y) for which f(x,y) < T is called


an object point, otherwise, the point is called a
background point.
Gray Scale Image Example

Image of a Finger Print with light background


Histogram
Segmented Image

Image after Segmentation


In Matlab histograms for images can be constructed using the imhist
command.

I = imread('pout.tif');
figure, imshow(I);
figure, imhist(I) %look at the hist to get a threshold, e.g., 110
BW=roicolor(I, 110, 255); % makes a binary image
figure, imshow(BW) % all pixels in (110, 255) will be 1 and white
% the rest is 0 which is black
roicolor returns a region of interest selected as those pixels in I that match the values
in the gray level interval.
BW is a binary image with 1's where the values of I match the values of the interval.
Thresholding Bimodal
Histograms
Basic Global Thresholding:
1)Select an initial estimate for T

2)Segment the image using T. This will produce two groups of


pixels. G1 consisting of all pixels with gray level values >T and
G2 consisting of pixels with values <=T.

3)Compute the average gray level values mean1 and mean2 for
the pixels in regions G1 and G2.

4)Compute a new threshold value


T=(1/2)(mean1 +mean2)

5)Repeat steps 2 through 4 until difference in T in successive


iterations is smaller than a predefined parameter T0.
Gray Scale Image - bimodal

Image of rice with black background


Segmented Image

Image histogram of rice Image after segmentation


Basic Adaptive Thresholding:

Images having uneven illumination


makes it difficult to segment using
histogram, this approach is to divide the
original image into sub images and use
the thresholding process to each of the
sub images.
Multimodal Histogram
If there are three or more dominant modes in the
image histogram, the histogram has to be
partitioned by multiple thresholds.

Multilevel thresholding classifies a point (x,y) as


belonging to one object class
if T1 < (x,y) <= T2,
to the other object class
if f(x,y) > T2
and to the background
if f(x,y) <= T1.
Thresholding multimodal
histograms
A method based on
Discrete Curve Evolution
to find thresholds in the histogram.

The histogram is treated as a polyline and is simplified


until a few vertices remain.

Thresholds are determined by vertices that are local


minima.
Discrete Curve Evolution (DCE)

It yields a sequence: P=P0, ..., Pm

Pi+1 is obtained from Pi by deleting the vertices of Pi


that have minimal relevance measure

K(v, Pi) = |d(u,v)+d(v,w)-d(u,w)|

v v
> w
w u

u
Gray Scale Image - Multimodal

Original Image of lena


Multimodal Histogram

Histogram of lena
Segmented Image

Image after segmentation – we get a outline of her face, hat, s


Color Image - bimodal

Colour Image having a bimodal histogram


Histogram

Histograms for the three colour spaces


Segmented Image

Segmented image, skin color is shown


End

Course Completes
Projects presentation

Notice : DIP Projects 20%

presentation starts on: 25 June 015

You might also like