0% found this document useful (0 votes)
49 views108 pages

CV Lecture 5

The document discusses image filtering techniques. It begins by introducing image blurring and sharpening as well as noise reduction and edge detection. It then covers the basics of spatial filtering, including different types of spatial filters like smoothing and sharpening filters. Specific smoothing filters discussed include mean/average filters and median filters. Sharpening filters mentioned are Laplacian and Sobel filters. The document provides examples of filtering operations and their effects.

Uploaded by

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

CV Lecture 5

The document discusses image filtering techniques. It begins by introducing image blurring and sharpening as well as noise reduction and edge detection. It then covers the basics of spatial filtering, including different types of spatial filters like smoothing and sharpening filters. Specific smoothing filters discussed include mean/average filters and median filters. Sharpening filters mentioned are Laplacian and Sobel filters. The document provides examples of filtering operations and their effects.

Uploaded by

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

Computer Vision

CSC-455
Muhammad Najam Dar
Today’s Lecture

 Image (Spatial) Filtering


 Image blurring and
Sharpening
 Noise Reduction and Edge
Detection
Image Filtering

Spatial Filtering
i. Basics of Spatial Filtering.
ii. Types of Spatial Filtering: Smoothing and Sharpening.
iii. Mask Operation near border: Pixel Replication and Zero
Padding.
iv. Types of Smoothing Filters: Linear Filters, Non-Linear (Order
Statistic) Filters
v. Linear Filters: Mean (Box, Average) Filtering
vi. Non-Linear (Order Statistic) Filtering: Median Filtering,
Min/Max Filtering.
vii. Sharpening Filters: Laplacian Filters, Sobel Filters.
What types of image filtering can we do?

Point Operation

point processing

Neighborhood Operation

“filtering”
Examples of point processing
Implement these in MATLAB?
original darken lower contrast non-linear lower contrast

invert lighten raise contrast non-linear raise contrast


Image filtering

• Replace each pixel by a linear combination of its neighbors (and


possibly itself).

• The combination is determined by the filter’s kernel.

• The same kernel is shifted to all pixel locations so that all pixels
use the same linear combination of their neighbors.
Spatial Filtering
Spatial Filtering
52
Spatial Filtering
Spatial Filtering
Spatial Filtering
Examples:
(a) Image of cell corrupted
by noise
(b) The result of averaging
(c) Image of Martian surface
corrupted by interference in
transmission
(d) The result of computer
processing
Spatial Filtering: Basics
 The output intensity value at (x,y) depends not
only on the input intensity value at (x,y) but
also on the specified number of neighboring
intensity values around (x,y)

 Spatial masks (also called window, filter, kernel,


template) are used and convolved over the entire
image for local enhancement (spatial filtering)

 The size of the masks determines the number of


neighboring pixels which influence the output value at
(x,y)

 The values (coefficients) of the mask determine


the nature and properties of enhancing technique
Spatial Filtering: Basics

Moving window
(kernel) scans the 3x3
neighborhood of every
pixel in the image

Original Image
Spatial Filtering: Basics
Spatial Filtering: Basics
Spatial Filtering: Basics
Spatial Filtering: Basics
Smoothing Spatial Filters

Simply average all of the pixels in a neighbourhood around


a central value

1/ 1/ 1/
9 9 9

Simple
1/ 1/ 1/
9 9 9 averaging
1/ 1/ 1/
filter
9 9 9
Applications of Smoothing Spatial Filters

For blurring/noise reduction

Blurring is usually used in preprocessing steps, e.g., to remove


small details from an image prior to object extraction, or to bridge
small gaps in lines or curves

Equivalent to Low-pass spatial filtering in frequency domain


because smaller (high frequency) details are removed based on
neighborhood averaging (averaging filters)
Smoothing Filter: Example

original 3x3 average


Smoothing Filter: Example

original 3x3 average


Smoothing Filter: Example

original 3x3 average


Smoothing Filter: Example

original 3x3 average


Original image Smooth by 3x3
Size: 500x500 box filter

Smooth by 5x5 Smooth by 9x9


box filter box filter

Smooth by
Smooth by
35x35 box filter
15x15 box filter

Notice how detail begins to disappear


Smoothing Spatial Filters

Consider the
output pixel is
positioned at
the center

Box Filter all Weighted Average give


coefficients are more (less) weight to near
equal (away from) the output
location
Smoothing Spatial Filters
Origin x 104 100 108
1/ 1/ 1/
9 9 9
99 106 98

95 90 85 * 1/
9
1/
9
1/
9

1/ 1/ 1/
9 9 9
104 100 108 Original Image Filter
1/ 9 1/9 1/9
Simple 3*3 99 106 98 3*3 Smoothing Pixels
1/ 1/ 1/
Neighbourhood 959 9
90 9
85 Filter
1/ 9 1/9 1/9

e = 1/9*106 +
1/ *104 +
9
1/ *100 +
9
y Image f (x, y) 1/ *108 +
9
1 /= 98.3333
9*99 + /9*98
1
The above is repeated for every pixel in the original image to generate the smoothed image
+
Example: the box filter

• also known as the 2D rect (not rekt) filter

• also known as the square mean filter

1 1 1
kernel 1 1 1
1 1 1
• replaces pixel with local average

• has smoothing (blurring) effect


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

note that we assume that


the kernel coordinates
are centered output filter image (signal)
Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
shift-invariant:
1 1 1 0 0 0 90 90 90 90 90 0 0 as the pixel
0 0 0 0 0 0 0 0 0 0 shifts, so does
0 0 0 0 0 0 0 0 0 0 the kernel
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40
1 1 1 0 0 0 90 90 90 90 90 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30
1 1 1 0 0 0 90 0 90 90 90 0 0
1 1 1 0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
0 0 90 0 0 0 0 0 0 0 10
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Let’s run the box filter
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
0 0 90 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


… and the result is
image output
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10

kernel 0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
1 1 1 0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
1 1 1 0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
0 0 90 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0
0 0 0 0 0 0 0 0 0 0

output filter image (signal)


Some more realistic examples
Some more realistic examples
Spatial Filtering: Image Border

Mask operation near the image border: Problem arises when


part of the mask is located outside the image plane

Discard the problem pixels (e.g.


512x512 input 510x510 output if Pixel replication: We
mask size is 3x3) normally use the gray
Zero padding: Expand the input levels of border pixels to
image by padding zeros fill up the expanded region
(512x512 original image, (for 3x3 mask). For larger
514x514 padded image,512x512 masks a border region
output) equal to half of the mask
Zero padding is not size is mirrored on the
recommended as it creates expanded region.
artificial lines or edges on
the border
Spatial Filtering: Image
border
Mask operation near the border: Pixel
replication
Order-Statistic Filtering

 Output is based on order of gray levels in the masked area


 Some simple neighbourhood operations include:
 Min: Set the pixel value to the minimum in the
neighbourhood
 Max: Set the pixel value to the maximum in the
neighbourhood
 Median: The median value of a set of numbers
is the
midpoint value in that set
Median Filter
• For an image, mask symmetric: 3x3, 5x5, etc.

Sorted: 0,0,1,1,1,2,2,2,4
Input Output

1 2 0 1
3 1
2 2 4 2
2
1 0 1 0
1 2 1
2 5 1 0
2
Median Filtering

Sort the values


Determine the median

Median = ? 20
 Particularly effective when
 The noise pattern consists of
strong
impulse noise ( salt-and-pepper)
Salt and Pepper
Noise
Median Filtering
Min/Max Filtering
Sharpening Filters
Sharpening Spatial
Filters
Previously we have looked at smoothing filters which remove
fine detail

Sharpening spatial filters seek to highlight fine detail


 Remove blurring from images
 Highlight edges

Sharpening filters are based on spatial differentiation


Edge Detection

edge
edge
How would you detect an edge?
What kinds of filter would you
use?
Edge detection
• Goal: map image from 2d array of pixels to a set of
curves or line segments or contours.
• Why?

Figure from J. Shotton et al., PAMI


2007

• Main idea: look for strong gradients, post-


process
What can cause an edge?

Depth discontinuity:
Reflectance change: object boundary
appearance
information,
texture

Cast shadows

Change in surface
orientation: shape
Contrast and invariance
Derivatives and edges
An edge is a place of rapid change in the image
intensity function.
intensity function
image (along horizontal scanline)

Source: L. Lazebnik
Edge Detection
Partial derivatives of an image

f (x, f (x, y)
y) x y

-1 1 -1 ?or 1
1 -1
Which shows changes with respect to x?
(showing flipped filters)
Difference filters

>> My = fspecial(‘sobel’);
>> outim = imfilter(double(im),
My);
>> imagesc(outim);
>> colormap gray;
Spatial
Differentiation
• Let’s consider a simple 1
dimensional example
Spatial
Differentiation

A B
1st
Derivative
The 1st derivative of a function is given by:

f
x  f (x 1)
 f (x)
Its just the difference between subsequent
values and measures the rate of change of
the function
1st Derivative
2nd Derivative

The 2nd derivative of a function is given by:

Simply takes into account the values both before and after the current value

2 f
 f (x 1)  f (x 1)  2 f
 x
2
(x)
2nd Derivative
Edge Detection
• First and second
derivative
for smooth noiseless edge
• The zero crossings of the
second derivative can be
used for locating edges in
an image.
Zero Crossings
zero crossing

f f’ f
’’

image Laplacian zero-crossing edge


operator map
x(m,n) g(m,n) I(m,n)

34
Examples

original image zero-crossings


Question: why is it so sensitive to noise (many false alarms)?
Answer: a sign flip from 0.01 to -0.01 is treated the same as from 100 to -100

35
Edge Detection
• First order derivatives produce thick edges while second
order
derivatives produce finer ones.
• Second order derivatives enhance sharp changes and fine
details more aggressively than first order derivatives see
the isolated point and the line in the same figure. This
can be a problem if the noise is present in the image
• Second derivative changes its sign as it transitions into
and out of a ramp or step edge. See the step edge. This
“double edge” effect can be used to locate edges.
• The sign of the second derivative is also used to
determine whether an edge is a transition from light to dark
(-ve value) or from dark to light (+ve value). See step edge
Computing 2nd Order Derivative
using Laplacian Filter
2nd Derivative for Image Enhancement

The 2nd derivative is more useful for image enhancement


than the 1st derivative - Stronger response to fine detail

We will come back to the 1st order derivative later on

The first sharpening filter we will look at is the Laplacian


Laplacian Filter

The Laplacian is defined as follows:


2 2
2 f  f
 f  2  2
x y
2 f
 f (x 1, y)  f (x 1, y)  2 f (x,
x 2
y)
2 f
 f (x, y 1)  f (x, y 1)  2 f (x,
y 2
y)
Laplacian Filter

So, the Laplacian can be given as follows:


2 f  [ f ( x  1, y )  f ( x  1, y )
 f ( x, y  1)  f
( x, y  1)]
 4 f ( x, y )
Can we implement it using a
0 1 0
filter/ mask?
1 -4 1

0 1 0
Laplacian Filter
Laplacian Filter

Applying the Laplacian to an image we get a


new image that highlights edges and other
discontinuities

Original Laplacian Laplacian Filtered Image


Image Filtered Image Scaled for Display
Laplacian Image Enhancement

The result of a Laplacian filtering is not an


enhanced image

To generate the final enhanced image

Laplacian
Filtered Image
Scaled for
f (x, y)   2 f , w 
5
Display
g(x, y)
 f0(x, y)   2 f , w 
5
0
Laplacian Image Enhancement

- =
Original Laplacian Sharpened
Image Filtered Image Image

In the final sharpened image edges and fine


detail are much more obvious
Laplacian Image Enhancement
Simplified Image Enhancement

• This gives us a new filter which does the


whole job for us in one step
0 -1 0

-1 5 -1

0 -1 0
Unsharp Masking
Computing 1st Order Derivative
using Sobel Filter
Gradient Operators
Some common gradient operators
 Roberts and Prewitt masks are the
simplest but not robust against noise
 Sobel edge detection masks are the
most common and give satisfactory
results in presence of noise
Gradient
Operators
The ‘Sobel’
filter 1 0 -1
2 0 -2
1 0 -1

a derivative filter
(with some smoothing)

Filter returns large


response on vertical or
horizontal lines?
The ‘Sobel’
filter 1 2 1
0 0 0
-1 -2 -1

a derivative filter
(with some smoothing)

Filter returns large


response on vertical or
horizontal lines?

Is the output always positive?


The ‘Sobel’
filter 1 2 1
0 0 0
-1 -2 -1

a derivative filter
(with some smoothing)

Responds to horizontal lines

Output can be positive or


negative
Output of which Sobel filter? Output of which Sobel
filter?

How do you visualize negative


derivatives/gradients?
Derivative in X direction Derivative in Y
direction
Visualize with scaled absolute
value
The ‘Sobel’
filter 1 0 -1
2 0 -2
1 0 -1

Where does this


filter come?
Decomposing the Sobel filter

What
1 0 -1 this?
1 0 -1
1
2 0 -2
1 0 -1
= 2 x-
derivative
1

Sobel
weighted
average and
scaling
Gradient
Operators
Sobel Operator

-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
Extract horizontal Extract vertical
edges edges
Emphasize more the current point
(y direction)

f  (z7  2z8  z9 )  (z1  2z2


 z3 )
 (z  2z  z )  (z  2z4
Emphasize3 more the
6 current
9 point (x
1
Pixel Arrangement
 z7 )
direction)
Sobel Operator:
Example
An image of a
contact lens
which is
enhanced in
order to make
defects more
obvious

Sobel filters are typically used for edge


detection
Laplace filter Sobel filter

What’s different between the two


results?
zero-crossing peak

Laplace Sobel

Zero crossings are more accurate at localizing edges


(but not very convenient)
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
FIGURE 3.43
(a)Image of
whole body
bone scan .
(b)Laplacian of
(a). (c) Sharpened
image obtained by
adding (a) and (b).
(d) Sobel gradient
of (a).
(e) Poorly exposed x-ray
image
(f) The result from
contrast and edge
enhancement
(g) Image blurred by
motion
(h) The result of de-
blurring
References
 Some Slide material has been taken from Dr M. Usman Akram Computer Vision
Lectures
 CSCI 1430: Introduction to Computer Vision by James Tompkin
 Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
 Pattern Recognition and Analysis Course – A.K. Jain, MSU
 Pattern Classification” by Duda et al., John Wiley & Sons.
 Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley,
2002
 Machine Vision: Automated Visual Inspection and Robot Vision”, David Vernon,
Prentice Hall, 1991
 www.eu.aibo.com/
 Advances in Human Computer Interaction, Shane Pinder, InTech, Austria, October
2008
 Computer Vision A modern Approach by Frosyth
 http://www.cs.cmu.edu/~16385/s18/

You might also like