Title: IMAGE SEGMENTATION
1TOPIC 12 IMAGE SEGMENTATION MORPHOLOGY
2SEGMENTATION
Image segmentation is approached from three
different perspectives .Region detection
each pixel is assigned to a particular object or
region. .Boundary detection one attempts to
detect the boundaries that exist between
regions. .Edge detection one seeks to identify
edge pixels and then link them together to form
a connected boundary.
3THRESHOLDING
4Neighbourhood operations
5Gradient Approximation
Mask -1 0 1
6Rate of change of gradient approximation
Mask 1 2 1
7Programming the neighbourhood operation
function MakeEdge(s) To make a Gaussian edge
for K 1500 X(K) K end Y
128ones(1,500) denominator 2ss for K
250500 Y(K) 64(1exp(-(X(K)-250)2/denomin
ator)) end hold on plot(X,Y) Now try two
masks Sobel mask Mask -1 0 1 Laplacian
mask Mask -1 2 -1
Z(1) 0 Z(500) 0 maxval 0 for K
2(500-1) Z(K) Y(K-1)Mask(1)
Y(K)Mask(2) Y(K1)Mask(3) if (abs(Z(K))
gt maxval) maxval abs(Z(K)) end
end Z (128/maxval)Z plot(X,Z,'-r')
8Plotting the function with -1 0 1
9Plotting the function with 1 -2 1
10Convolution and Correlation
11St. Peters church, Roker
12The Roberts Edge Detector
13The Roberts Edge Detector
14The Prewitt Edge Detector
The Sobel Edge Detector
Both these detectors are easy to implement in
hardware and are fast which makes them
particularly attractive for real time applications
15The Prewitt Edge Detector
16The Sobel Edge Detector
17The Laplacian Edge Detector
This is very unstable in the presence of
noise. The solution is to use it in conjunction
with a Gaussian Filter function to remove the
high frequency noise. The combined function is
known as LOG or Laplacian of Gaussian. Because
of its shape it is often known as the mexican hat
function
18The Mexican hat function
19The mask for the Laplacian of Gaussian Edge
Detector
0 0 -1 0 0
0 -1 -2 -1 0
-1 -2 16 -2 -1
0 -1 -2 -1 0
0 0 -1 0 0
20The LOG edge detector
21PROPERTIES OF THE LAPLACIAN OPERATOR
- If the area around the pixel has a constant grey
level - then application of the kernel results in a grey
level - value of 0
- The average grey level is 0
- Negative values are possible. In practice this
can be - avoided by defining zero to be the grey value
128 - The kernel is not direction sensitive in the
sense of - preferentially selecting either vertical or
horizontal - edges.
22ALTERNATIVE FORM OF THE LAPLACIAN
23The Canny edge detector
This one of the most sophisticated edge detectors
and is generally very successful. It has the
ability to suppress Gaussian noise and to contour
follow weak edges linked to the stronger edges
detected. This makes it possible to more reliably
detect weak edges. One drawback of the Canny
detector is that the processing time is
considerably longer than for the others. It is
also not possible to represent it as a simple
mask
24The Canny Edge Detector
- The Canny edge detector is an example of an
optimal edge detector in that it claims to
optimise the edge detecting process. Its
operation is however quite complex. - It works as a multi stage process
- The image is smoothed with a Gaussian
convolution. - A simple 2D operator (similar to the Roberts) is
applied to highlight regions with a high
gradient. - Edges give rise to ridges in the gradient image
the algorithm then tracks along these ridges
marking a trail 1 pixel wide on the top of the
ridge. - Two parameters control the process (a) which is
the lowest point on a ridge that tracking begins
and (b) blta is the point at which tracking ceases
when the height of the ridge falls below this
value.
25The Canny edge detector
26Programming edge detection in MatLab
function ChurchEdge To test the various edge
detectors A imread('church1.jpg') tic BW
edge(A,'prewitt') t toc imshow(BW)
Many of the variants of the edge function have
parameters associated with them. For example
edge(A,sobel,thresh,direction) where thresh
is threshold below which edges are not detected
and direction is horizontal, vertical or
both.
27Edge detection in MATLAB
function UsingEdge To edge detect a butterfly A
imread('moth9.gif') BW,thresh
edge(A,'sobel',0.04) imshow(BW) thresh
Thresh0.04
Thresh0.06
28A simple low pass filter
The 3 x 3 mask below will simply replace the
central pixel with the average of nine pixels.
The effect of this is to suppress high frequency
noise but it also blurs the image. The filter
can, of course, be any size N x N
1 1 1
1 1 1
1 1 1
29Example of low pass filtering
11 x 11
5 x 5
30Using the filter2 function
function UsingMask Using a mask A
imread('church1.jpg') imshow(A) smooth the
image mask3 1 1 11 1 11 1 1 mask7
ones(7) multiplier3 1/(2559) multiplier7
1/(25549) mask3 multiplier3.mask3 mask7
multiplier7.mask7 mask mask7 BW
filter2(mask,A) imshow(BW)
31Sharpening an image
A version of the Laplacian mask can be used to
sharpen an image
function filtersharpen To sharpen an image A
imread('filter7.jpg') A rgb2gray(A) imshow(A)
SE ones(3) SE SE.-1 SE(2,2) 12 SE
SE./(2554) BW filter2(SE,A) imshow(BW)
-1 -1 -1
-1 12 -1
-1 -1 -1
32Sharpening an image
Sharpened
Blurred
33Describe some of the hardware and software
techniques used to create and interact with
virtual reality environments.
15 marks Excluding computer games describe
how these techniques are applied to one
application of virtual reality.
10 marks
34A MORPHOLOGICAL TRANSFORMATION
A morphological transformation is one where a
structuring element (usually 3x3 but could be
larger) is passed over the binary image and a
logical operation performed (e.g. AND, OR, NOT,
XOR in simple cases) on a pixel by pixel basis.
The structuring element is also binary in form
35BASIC EROSION
This is the process of eliminating all boundary
points from an element. In other words if a
pixel with a value 1 has an immediate neighbour
with a value 0 the pixel value is set to 0. Note
the pixel values are not continuously updated
during the transformation otherwise the result
would be a blank image !
36EROSION APPLICATION
37FORMAL DEFINITION OF EROSION
38DILATION
Dilation is the inverse of erosion where any
pixel adjacent to a pixel of value 1 is changed
to 1
39Thinning Erosion can be programmed as a two step
process so that objects are not broken up. In
the first step candidate pixels are marked for
deletion but not deleted. In the second pass
pixels are eliminated only if they would not
destroy the connectivity of the object. Thinning
reduces objects to a single pixel wide line
highlighting line topology
40THINNING
41Opening The process of erosion followed by
dilation is known as opening. It has the effect
of eliminating small objects, smoothing the
boundaries of large objects without
significantly changing their area. In other words
a good combination for cleaning up a segmented
image.
42Closing The process of dilation followed
erosion is known as closing. It has the effect
of filling small and thin holes and smoothing
boundaries without changing the area of larger
objects.
43Shrinking If erosion is implemented in such a
way that single pixel objects are left intact
the process is known as shrinking. It is a
useful way of counting the size distribution of
objects in the scene by successive shrinking
followed by counting the change in the number of
single pixel objects in the image.
44Skeletonisation This process is very similar to
thinning and can also be achieved by a two pass
process. The essential difference is that
skeletonisation retains the full dimension of
the object.
45ANALYSIS PIPELINE
46UNDERSTANDING A PRINTED CIRCUIT BOARD
47Using convolution for filtering
48Convolution and Correlation
Convolution
Finds its principal application in high and low
pass filtering
Correlation
Finds its principal application in template
matching
49Example of using filter2
function UsingMask Edge detection using a mask A
imread('moth9.gif') smooth the image mask
1 1 11 1 11 1 1 multiplier 1/(2559) mask
multiplier.mask BW filter2(mask,A) imshow(
BW)
The mask
50An improved filtering mask to remove noise
51(No Transcript)
52THE SOBEL OPERATOR
The Sobel operator is one of those most commonly
used and has received special attention because
it can be performed in real time (lt 1/30 sec.
Per image) which makes it attractive for
military tracking applications.