0% found this document useful (0 votes)
7 views51 pages

Lecture 4

Uploaded by

Kamran Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views51 pages

Lecture 4

Uploaded by

Kamran Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Image Enhancement

Edge Detection

Digital Image Processing Lecture 4

Muhammad Usman Ghani Khan

Department of Computer Science & Engineering


UET, Lahore

Spring Semester

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Sharpening Spatial Filters

Goal: highlight or enhance details in images


Sharpening spatial filters seek to highlight fine detail
Remove blurring from images
Highlight edges
Procedure
Sharpening filters are based on spatial differentiation. (why?)
Some Applications
Photo enhancement
Medical image visualization
Industrial defect detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Spatial Differentiation

Differentiation measures the rate of change of a function


Let’s consider a simple 1 dimensional example

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Spatial Differentiation

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative

The formula for the 1st derivative of a function is as follows:


∂f
= f (x + 1) − f (x) (1)
∂x
It’s just the difference between subsequent values and measures the rate of change of
the function

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative

1 must be zero in flat segments(area of constant gray levels)


2 must be non-zero at the onset of a gray level step or ramp
3 must be non zero along ramps

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2nd Derivative

The formula for the 2nd derivative of a function is as follows:


∂f 2
= f (x + 1) + f (x − 1) − 2f (x) (2)
∂x 2
Simply takes into account the values both before and after the current value

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2nd Derivative

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2nd Derivative

1 must be zero in flat segments


2 must be non-zero at the onset and end of a gray level step
or ramp
3 must be non zero along ramps of constant slope

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st and 2nd Derivatives

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Using Second Derivatives For Image Enhancement

The 2nd derivative is more useful for image enhancement


than the 1st derivative
Stronger response to fine detail
Simpler implementation

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

The Laplacian
The Laplacian is defined as follows:

∂2f ∂2f
52 f = + (3)
∂2x ∂2y
where partial 1st Derivative in the x direction is defined as follows:

∂2f
= f (x + 1, y ) + f (x − 1, y ) − 2f (x, y ) (4)
∂2x

and in the y direction as follows:

∂2f
= f (x, y + 1) + f (x, y − 1) − 2f (x, y ) (5)
∂2y

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

The Laplacian

So, the Laplacian can be built as:

52 f = [f (x +1, y )+f (x −1, y )+f (x, y +1)+f (x, y −1)]−4f (x, y )


(6)
We can easily build a filter based on this
0 1 0
1 -4 1
0 1 0

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

The Laplacian – Different Filters

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

The Laplacian Example

Applying the Laplacian to an image we get a new image that


highlights edges and other discontinuities

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

But That Is Not Very Enhanced!

The result of a Laplacian filtering


is not an enhanced image
We have to do more work in
order to get our final image
Subtract the Laplacian result
from the original image to
generate our final sharpened
enhanced image
g(x, y ) = f (x, y ) − 52 f (7)

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

The Laplacian Example

In the final sharpened image edges and fine detail are much
more obvious

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Simplified Image Enhancement


The entire enhancement can be combined into a single filtering
operation

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Simplified Image Enhancement

This gives us a new filter which does the whole job for us in one
step

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Variants On The Simple Laplacian


There are lots of slightly different versions of the Laplacian that
can be used:

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Unsharp Mask & Highboost Filtering

Using sequence of linear spatial filters in order to get


Sharpening effect.
1 Blur
2 Subtract from original image
3 add resulting mask to original image

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Sharpening using Unsharp Masking

Subtract blurred version of image from the image itself to


produce sharp image

g(x, y ) = f (x, y ) − f (x, y ) (8)

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Sharpening using Highboost Filtering


Generalization of unsharp masking

g(x, y ) = Af (x, y ) − f (x, y ) (9)

As A increases, contribution of sharpening decreases

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Highboost Filtering

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative Filtering

Implementing 1st derivative filters is difficult in practice


For a function f (x, y ) the gradient of f at coordinates (x, y )
is given as the column vector:

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative Filtering

The magnitude of this vector is given by:

For practical reasons this can be simplified as:

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st Derivative Filtering


There is some debate as to how best to calculate these
gradients but we will use:

which is based on these coordinates

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Sobel Operators

Based on the previous equations we can derive the Sobel


Operators

To filter an image it is filtered using both operators the results of


which are added together

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Sobel Operators: Industrial Inspection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

1st and 2nd Derivative Comparison

Comparing the 1st and 2nd derivatives we can conclude the


following:
1 1st order derivatives generally produce thicker edges
2 2nd order derivatives have a stronger response to fine
detail e.g., thin lines
3 1st order derivatives have stronger response to grey level
step
4 2nd order derivatives produce a double response at step
changes in grey level

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Outline

1 Image Enhancement
Sharpening Spatial Filters
Spatial Differentiation
Laplacian
1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

2 Edge Detection

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Combining Spatial Enhancement Methods

Successful image enhancement


is typically not achieved using a
single operation
Rather we combine a range of
techniques in order to achieve a
final result
This example will focus on
enhancing the bone scan to the
right

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Combining Spatial Enhancement Methods

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Combining Spatial Enhancement Methods

Digital Image Processing - Lecture 4


Sharpening Spatial Filters
Spatial Differentiation
Image Enhancement Laplacian
Edge Detection 1st Derivative Filtering
Comparison of Derivative Filters
Combining Spatial Enhancement Methods

Combining Spatial Enhancement Methods

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Definition of Edges
Edges are significant local changes of intensity in an image.

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Importance of Edges

Goal: Identify sudden changes


(discontinuities) in an image
Intuitively, most semantic and
shape information from the
image can be encoded in the
edges
More compact than pixels
Ideal: artist’s line drawing (but
artist is also using object-level
knowledge)
g(x, y ) = f (x, y ) − 52 f (10)
Digital Image Processing - Lecture 4
Image Enhancement
Edge Detection

Origin of Edges

Edges are caused by a variety of factors

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Edge Descriptors

Edge direction: perpendicular to the direction of maximum intensity change (i.e.,


edge normal)
Edge strength: related to the local image contrast along the normal.
Edge position: the image position at which the edge is located.

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Modeling Intensity Changes - Edge Types

Step edge: the image intensity abruptly changes from one


value on one side of the discontinuity to a different value on the
opposite side.

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Modeling Intensity Changes - Edge Types

Ramp edge: a step edge where the intensity change is not


instantaneous but occur over a finite distance.

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Modeling Intensity Changes - Edge Types


Ridge edge: the image intensity abruptly changes value but
then returns to the starting value within some short distance
(i.e., usually generated by lines).

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Modeling Intensity Changes - Edge Types


Roof edge: a ridge edge where the intensity change is not
instantaneous but occur over a finite distance (i.e., usually
generated by the intersection of two surfaces).

Digital Image Processing - Lecture 4


Image Enhancement
Edge Detection

Main Steps in Edge Detection

1 Smoothing: suppress as much noise as possible, without


destroying true edges.
2 Enhancement: apply differentiation to enhance the quality
of edges (i.e.sharpening).
3 Thresholding: determine which edge pixels should be
discarded as noise and which should be retained (i.e.,
threshold edge magnitude).
4 Localization: determine the exact edge location.
Sub-pixel resolution might be required for some
applications to estimate the location of an edge to better
than the spacing between pixels

Digital Image Processing - Lecture 4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy