Unit 3_ Feature Extraction
Unit 3_ Feature Extraction
Contents
● Point, Line and Edge Detection
● Color, Texture, Shape and Structure Features in Spatial and
Frequency Domains
● Corner Detection
● Hough Transform
Detection of Discontinuity
Types of Grey
Level
Discontinuities
W1 W2 W3 Z1 Z2 Z3
W4 W5 W6 Z4 Z5 Z6
W7 W8 W9 Z7 Z8 Z9
Mas Image
k
If |R| >= T, a point is detected where, T is a non negative integer.
-1 -1
Sample Mask for Point Detection -1
-1 8 -1
-1 -1 -1
Line Detection
● In this, four types of masks are used to get the responses i.e.,
R1,R2,R3,R4 for the directions vertical, horizontal, +45 degree and -
45 degree respectively.
-1 -1 -1 -1 2 -1 -1 -1 2 2 -1 -1
2 2 2 -1 2 -1 -1 2 -1 -1 2 -1
-1 -1 -1 -1 2 -1 2 -1 -1 -1 -1 2
Horizontal Vertical +45 -45
Edge Detection
● An edge is a set of connected pixels that lies on the boundary between
two regions which differ in grey value. Pixels on edge is known as edge
points.
● Edges provide an outline of the object.
● In physical plane edge corresponds to the discontinuities in depth,
surface orientation, change in material properties, light variations, etc.
● It locates sharp changes in the intensity function
● Edges are pixels where brightness changes abruptly
● An edge can be extracted by computing the derivative of the image
function
○ Magnitude of the derivative, indicates the strength or contrast of edge
○ Direction of derivative vector, indicates the edge orientation.
Edge Detection (Cont.)
● Example: A mug seen in the input image and once edges are
detected, one can find out the exact layout or boundary of the
object.
● The edges are detected based on the significant change in the
intensity between the objects in the image.
● To make it precise, the mug has a different intensity from the grey
background and it is the key idea for us to identify the edges. So, in
an image, if there are many objects, edges are the easiest way to
identify all of them.
Edge Detection (Cont.)
Edge Detection (Cont.)
Why to detect edges?
● One can understand the shape of the object in the image only when
the edges are detected. So, ideally to understand an object and its
shape, it becomes inevitable for someone to detect the edges.
● There are many technical issues and challenges mapped to the
segmentation, registration and object identification techniques.
Edges prove to be efficient with these above techniques at the
fundamental levels.
Edge Detection (Cont.)
Some of the commonly encountered edges in image processing
Ramp Spike
Step Edge Roof Edge
Edge Edge
Stages in Edge detection(Cont.)
● There are three steps followed in edge detection process. They are:
● Image Smoothening
● Edge Point Detection
● Edge Localization
Stages in Edge detection(Cont.)
● Image smoothening is all about removal of the noise from the
image. In addition, the removal or suppression of the noise should
be done in such a way that the quality of the image is not altered.
● Essentially, image smoothening is all about making the image noise
free.
Stages in Edge detection(Cont.)
● Edges are detected through identifying the sudden changes in the
intensity. Even noise is all about sudden change in the intensity.
Edge point detections is a process where the noise alone is carefully
removed or discarded retaining the edges appropriately
Stages in Edge detection(Cont.)
● The final step in the sequence is edge localization. Sometimes the
processes like thinning, linking etc. are to be carried out to locate
the edges appropriately. This process is called edge localization.
Edge Detection (Cont.)
Sobel Edge Detector
● The image is processed in the X and Y directions respectively.
● This would result in the formation of new image, which actually is
the sum of X and Y edges of the image.
● This approach works through calculation of the gradient of the image
intensity at every pixel within the image.
● Sobel filter has two kernels (3x3) matrix
● One of them corresponds to the X (horizontal) and Y (vertical)
direction.
● These two kernels shall be convoluted with the original image under
process and through which the edge points are calculated with ease.
Sobel Edge Detector (Cont.)
● The kernel values are fixed and cannot be altered.
● The Gaussian filter play a vital role in the entire process. The
fundamental idea is the center having more weight than the rest
● The general approach detecting the edges is with the first order or
second order derivatives as shown below:
Sobel Edge Detector (Cont.)
Sobel Edge Detector (Cont.)
● Convolute the Gx(Sobel X) and Gy(Sobel Y) over the input image
which shall enable to calculate the value for one pixel at a time.
● Then the shift happens and the move has to be made towards the
right i.e., the next column shift till the column end.
● Similar process is followed for the row shifting from top to bottom.
● The G will be compared against the threshold and with which one
can understand the taken point is edge or not.
Sobel Edge Detector (Cont.)
Input Gradient
Edge
Sobel Edge Detector (Cont.)
Advantages
● Simple and time efficient computation
● Very easy at searching for smooth edges
Disadvantages
● Diagonal direction points are not preserved always.
● Highly sensitive to noise
● Not accurate in edge detection
● Detect with thick and rough edges does not give appropriate
results.
Prewitt Edge Detector
● It is similar to Sobel edge detection but with a minor change.The
prewitt operator shall give the values which are symmetric around
the centre. But sobel operator gives weight to the point which is
lying closer to (x,y)
● The Prewitt x and y operator are presented below:
Prewitt Edge Detector (Cont.)
Input Gradient
Edge
Prewitt Edge Detector (Cont.)
Advantages
● Good performance on detecting vertical and horizontal edges
● Best operator to detect the orientation of image.
Disadvantages
● The magnitude of coefficient is fixed and cannot be changed.
● Diagonal direction points are not preserved always.
Canny edge detector
● Canny edge detection technique, not just is a plain edge detection
technique. It has an additional feature. It also suppresses the noise
while detecting the edges flawlessly.
● The G will be compared against the threshold and with which one can
understand the taken point is edge or not.
● The formula for finding the edge direction is Theta = inv tan (Gy/Gx)
Canny edge detector (Cont)
Step 4: Non Maximum Suppression: The gradient magnitude operators
discussed in the previous stages normally obtain thick edges. But final
image is expected to have thin edges.
Hence non maximum suppression shall enable to derive thin edges from
thicker ones through following steps:
● Edge direction is already known. The subsequent step is to relate the
identified edge direction to a DIRECTION that can be sketched in the
image. i.e., ideally it is a prediction of how the movement of edges
could happen.
● For reference 3x3 matrix is taken.
Canny edge detector (Cont)
Canny edge detector (Cont)
● The center cell is the region of interest for us.
● There can be only 4 possible directions for any pixel. They are
○ 0 degrees
○ 45 degrees
○ 90 degrees and
○ 135 degrees
● Hence it forces us to a situation where the edges has to be definitely
oriented to one of these four directions.
● This is a kind of approximation where if the orientation angle is
observed to be 5 degrees then it is taken as 0 degrees. Similarly if it is
43 degrees, it shall be made as 45 degrees.
● For easy understanding semicircle with color shading is drawn. It is
drawn 180 degree but actual scenario is for 360 degree.
Canny edge detector (Cont)
● Any edge come under yellow
range is set to 0 degree
● Any edge come under green
range is set to 45 degree
● Any edge coming under blue
range is set to 90 degree
● Any under red is set to 135
degree
Canny edge detector (Cont)
● After this process direction of the edges is mapped to any of the 4
directions mentioned above. The input image now shall be like the
one presented below where direction of the edges are appropriately
mapped.
Canny edge detector (Cont)
● The edge directions are all determined and now the non maximum
suppression is to be applied.
● As the name suggest, it is a process where suppression of the pixels
to zero which cannot be considered as an edge is carried out. This
shall enable the system to generate a thin line in the output image as
shown.
● This result are obtained before the thresholding and next stage is to
perform thresholding and smoothing.
Canny edge detector (Cont)
5. Thresholding
● Here two threshold value is set, one is high and another is low.
● Example high threshold value as 0.8. Any pixel with a value above 0.8
is to be seen as stronger edge.
● Another threshold lower can be 0.2. In that case, any pixel below this
value is not an edge at all and hence set them all to 0.
● The edge in between 0.2 to 0.8 are weak edge i.e., may or maynot be
edge. There needs to be a process which can determine which of the
weak edges are actual edges.
Canny edge detector (Cont)
6. Edge Tracking
● As discussed above it is important to know which of the weaker edges
are the actual edges.
● We can call the weak edges connected to the strong edges as
strong/actual edges and retain them and those which are not
connected to the stronger edges are to be removed.
7. The final cleansing
All the remaining weak edges can be removed and that is it. The process
is complete. Once this is done. The following output is obtained.
Canny edge detector (Cont)
Advantages
● It has good localization.
● It extract image features without altering the features.
● Less sensitive to noise
Disadvantages
● There is false zero crossing
● Complex computation and time consuming
Laplacian of Gaussian
● In edge detection we normally look for the peaks in the image,
sudden change in intensity and not about the color content. If there
is a sharper change in intensity, we declare it as an edge. But in this
there are challenges.
● Deciding some point as a peak or not is a tough call. We use
thresholding for this, above the threshold we call it as peak and
below ignore it.
Laplacian of Gaussian (Cont.)
● As shown in the figure left to the curve, where it is rising, the slope
is definitely positive. Coming to the right side, it is negative. Hence
there is a zero crossing. It reveals the edge location. The edge
detectors which take this as the fundamental concept behind are
called as Laplacian Edge detectors.
● The Laplacian edge detector uses only one kernel where it was two
with respect to Sobel edge detector. Laplacian edge detector is
capable and it calculates the second order derivative in a single go.
The following are the kernel used:
Laplacian of Gaussian (Cont.)
Laplacian of Gaussian (Cont.)
● Following is the 2-D Log function with Gaussian standard deviation
Laplacian of Gaussian (Cont.)
Advantages
● Easy to detect edges and their various orientations.
● There is fixed characteristics in all directions.
Disadvantages
● Very sensitive to noise
● The localization error may be severe at curved edges.
● It generates noisy responses that do not correspond to edges, so
called false edge.
Real world applications of Image Edge detection
● Medical imaging, study of anatomical structure
● Locate an object in satellite image
● Automatic traffic controlling system
● Face recognition and fingerprint recognition
Image Enhancement
● Image enhancement refers to the process of highlighting certain information of
an image, as well as weakening or removing any unnecessary information
according to specific needs. For example, eliminating noise, revealing blurred
details, and adjusting levels to highlight features of an image.
I’(x,y) = T[I(x,y)]
● where, I’(x,y) is the new intensity after adding 5 to I(x,y).
Spatial Domain (Cont.)
● The spatial domain enhancement is based on pixels in a small range
(neighbor). This means the transformed intensity is determined by
the gray values of those points within the neighborhood, and thus
the spatial domain enhancement is also called neighborhood
operation or neighborhood processing.
● A digital image can be viewed as a two-dimensional function f (x, y),
and the x-y plane indicates spatial position information, called the
spatial domain. The filtering operation based on the x-y space
neighborhood is called spatial domain filtering.
Frequency domain
What is Frequency domain?
● It means “analysis of the signals or functions” with respect to the
frequency instead of “time”.
Step 2: The spectrum available might not be an easier choice to operate with filters. Also it can
be visualize by humans. Hence, there needs further processing. Shifting to zero frequency
component to the center of the spectrum is the step to be carried out.
Step 3: Apply the corresponding filters like the low or high pass based on the requirement to
filter the frequencies.
Step 4: It is the time to decentralization. One should get the things back after the processing
through this decentralization process.
Step 5: One should apply the inverse Fast Fourier Transform which enables conversion of the
spectrum to grayscale image. This is output image.
Frequency domain (Cont.)
Frequency domain (Cont.)
Low pass filters: The purpose of low pass filter is all about getting the
image smoothened or blurred. The low frequency content will be
retained while attenuating the high frequency content.
Frequency domain (Cont.)
Ideal Low pass filter, which is commonly referred as ILPF is the most
used filter for image smoothening in the frequency domain. As
expected, the ILPF removes the high frequency content (noise) from the
image and retains the low frequency component.
Limitation