Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
10/19/2016
1
© Mahesh Goyani
Digital Image Processing
Mahesh GoyaniAssistant Professor
Department of Computer Engineering,
Government Engineering College
Modasa - 383315.
E-Mail ID: [email protected]
Web Site: www.maheshgoyani.in
10/19/2016 1
LECTURE NOTES ON
FILTERING IN SPATIAL DOMAIN
© Mahesh Goyani10/19/2016 2
KEY STEPS OF DIGITAL IMAGE PROCESSING
Image Acquisition
Image Restoration
Morphological Processing
Segmentation
Representation & Description
Image Enhancement
Object Recognition
Problem Domain
Colour Image Processing
Image Compression
© Mahesh Goyani10/19/2016 3
DIGITAL IMAGE PROCESSING
Point Processing
>>imadjust
>>histeq
Spatial filtering
>>filter2
SpatialDomain
FrequencyDomain
Filtering
>>fft2/ifft2
>>fftshift
Enhancement Restoration
Inverse filtering
Wiener filtering
IMAGE ENHANCEMENT
© Mahesh Goyani10/19/2016 4
Basics of Filtering
© Mahesh Goyani10/19/2016 5
FUNDAMENTAL OF SPATIAL PROCESSING
Enhancement at any point in image depends only on gray level at that point.
These techniques are known as point processing.
Another approach in which to use a function of the values of f in predefined
neighborhood of (x,y) to determine the value of g at (x,y). In this approach filter
or mask (also known as kernel, window or template) is used.
Size of mask determine size of neighborhood and mask coefficient
determine the nature of process.
Enhancement techniques based on this approaches are known as mask
processing or filtering
© Mahesh Goyani10/19/2016 6
10/19/2016
2
MECHANICS OF SPATIAL FILTERING
mn
i
ii fw1
a
as
b
bt
tysxftswyxg ),(),(),(
© Mahesh Goyani10/19/2016 7
MECHANICS OF SPATIAL FILTERING
mn
i
ii fw1
a
as
b
bt
tysxftswyxg ),(),(),(
f(x-1,y-1) f(x-1,y) f(x-1,y+1)
f(x,y-1) f(x,y) f(x,y+1)
f(x+1,y-1) f(x+1,y) f(x+1,y+1)
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,-1) w(1,0) w(1,1)
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,-1) w(1,0) w(1,1)
)1,1()1,1(),1()0,1()1,1()1,1(
)1,()1,0(),()0,0()1,()1,0(
)1,1()1,1(),1()0,1()1,1()1,1(
yxfwyxfwyxfw
yxfwyxfwyxfw
yxfwyxfwyxfw),( yxg
© Mahesh Goyani10/19/2016 8
OPERATION STEP
1. Select a single pixel.
2. Determine the pixel’s neighborhood.
3. Apply a function to the values of the pixels in the neighborhood.
This function must return a scalar.
4. Find the pixel in the output image whose position corresponds
to that of the center pixel in the input image. Set this output
pixel to the value returned by the function.
5. Repeat steps 1 through 4 for each pixel in the input image
© Mahesh Goyani10/19/2016 9
NEIGHBORHOOD
Neighbourhood of a pixel p at position x, y is a set N(p) of pixels defined
relative to p.
Example 1:
N(p) = {(x,y): |x-xP|=1, |y-yP| = 1}
P
Q
© Mahesh Goyani10/19/2016 10
MORE EXAMPLES OF NEIGHBORHOOD
P
P
P
P
P
P
P
© Mahesh Goyani10/19/2016 11
WHAT IS FILTERING ?
Modify the pixels in an image based on some function of a local
neighborhood of the pixels
10 5 3
4 5 1
1 1 7
10
Some function(MAX)
© Mahesh Goyani10/19/2016 12
10/19/2016
3
CORRELATION VS. CONVOLUTION
© Mahesh Goyani10/19/2016 13
CORRELATION VS. CONVOLUTION
F
(0,0)
(N,N)
H4
1 2
3
Matlab:filter2
imfilter
© Mahesh Goyani10/19/2016 14
CORRELATION VS. CONVOLUTION
F
(0,0)
(N,N)
H4
1 2
3
H4
12
3
Matlab:conv2
© Mahesh Goyani10/19/2016 15
CORRELATION VS. CONVOLUTION
© Mahesh Goyani10/19/2016 16
FILTERING - EXAMPLE
1 -1 -1
1 2 -1
1 1 1
2 2 2 3
2 1 3 3
2 2 1 2
1 3 2 2Rotate
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 17
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32 5
3
2
1
2
2
1
3
2
32
21
22
32
1-2-1
24-1
111
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 18
10/19/2016
4
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32 45
3
2
1
2
2
1
3
2
32
21
22
32
3-1-2
24-2
111
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 19
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32 4 45
3
2
1
2
2
1
3
2
32
21
22
32
3-3-1
34-2
111
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 20
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32 4 4 -25
3
2
1
2
2
1
3
2
32
21
22
32
1-3-3
16-2
111
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 21
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32 4 4
9
-25
3
2
1
2
2
1
3
2
32
21
22
32
2-2-1
14-1
221
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 22
FILTERING - EXAMPLE
3
2
1
2
2
1
3
2
32
21
22
32
6
4 4
9
-25
3
2
1
2
2
1
3
2
32
21
22
32
1-2-2
32-2
222
1-1-1
12-1
111
© Mahesh Goyani10/19/2016 23
FILTERING - EXAMPLE
12
7
6
4
8
6
14
4
59
59
511
-25
© Mahesh Goyani10/19/2016 24
10/19/2016
5
TEMPLATE MATCHING
Input image
Template
Output
The brighter the value in the output, the better the match
© Mahesh Goyani10/19/2016 25
MASK ELEMENT SELECTION
For smoothing (Low pass filters), elements of mask must be
positive
For sharpening (High pass filters), elements of mask contains
both positive and negative wrights.
Normalize the mask element
© Mahesh Goyani10/19/2016 26
FILTER TYPES
Smoothing Filters
Low Pass (Linear) Filters
Box Filter
Weighted Averaging Filter
Order Statistics (Non Linear) Filters
Median Filter
Max Filter
Min Filter
Sharpening Filters
Laplacian
Unsharp Masking & high boost Filtering
Gradient
© Mahesh Goyani10/19/2016 27
Smoothing Filters
© Mahesh Goyani10/19/2016 28
LOW PASS (LINEAR) SPATIAL FILTERS
Used in preprocessing steps such as removal of small details from an image.
The response of linear spatial filtering is given by a sum of products of the
filter coefficients and the corresponding image pixels in the area spanned by the
filter mask.
Linear Filtering of an image f of size M X N with a filter mask of size m X n is
given by:
a=(m-1) /2 and b= (n-1)/2
a
as
b
bt
tysxftsw ),(),(
a
as
b
bt
tsw ),(
),( yxg
© Mahesh Goyani10/19/2016 29
LOW PASS (LINEAR) SPATIAL FILTERS
Low Pass Filters
Size of mask determines the degree of smoothing and loss of details
Box filter Weighted average (Tent )filter .
- To reduce blurring effect.
© Mahesh Goyani10/19/2016 30
10/19/2016
6
LOW PASS (LINEAR) SPATIAL FILTERS - EXAMPLE
Averaging filter with masks of sizes n=3
,5,9,15 and 35 respectively
Small detailed is removed using different size
mask
When mask size is larger than smaller object
is removed
Intensity of smaller objects blend with the
background and larger objects become blob like
and easy to detect.
© Mahesh Goyani10/19/2016 31
LOW PASS (LINEAR) SPATIAL FILTERS - EXAMPLE
Image Taken by Hubble Telescope
Filtered Image with15 X 15 Average Mask
Thresholded Image
© Mahesh Goyani10/19/2016 32
LINEAR FILTER – EXAMPLE
000
010
000
Original Identical image
* =
© Mahesh Goyani10/19/2016 33
LINEAR FILTER – EXAMPLE
000
100
000
Shifted leftBy 1 pixel
* =Original
© Mahesh Goyani10/19/2016 34
LINEAR FILTER – EXAMPLE
111
111
111
Blur (with a average filter)
* =Original
© Mahesh Goyani10/19/2016 35
LOW PASS (LINEAR) SPATIAL FILTERS
Advantages:
Reduced sharp transitions in gray levels
Remove noise.
Blur High frequency
Do averaging
Disadvantages:
Edges are blurred
© Mahesh Goyani10/19/2016 36
10/19/2016
7
GAUSSIAN SMOOTHING
Gaussian kernel :
Rotationally symmetric
Weights nearby pixels more than distant ones
This makes sense as ‘probabilistic’ inference
about the signal
A Gaussian gives a good model of a fuzzy blob
© Mahesh Goyani10/19/2016 37
GAUSSIAN SMOOTHING FILTER
Weights are samples from Gaussian Function
The value of σ determines the degree of smoothing.
© Mahesh Goyani10/19/2016 38
GAUSSIAN SMOOTHING FILTER
As σ increases, more samples must be obtained to represent the
Gaussian function accurately.
© Mahesh Goyani10/19/2016 39
GAUSSIAN SMOOTHING
What parameters matter here?
Variance of Gaussian Determines extent
of smoothing
σ = 5 with 3030 kernel
σ = 2 with 3030 kernel
© Mahesh Goyani10/19/2016 40
GAUSSIAN SMOOTHING IN MATLAB
>> hsize = 10;
>> sigma = 5;
>> h = fspecial(‘gaussian’ hsize, sigma);
>> outim = imfilter(im, h);
>> imshow(outim);
>> mesh(h);
>> imagesc(h);
outim
© Mahesh Goyani10/19/2016 41
SMOOTHING BY AVERAGING
depicts box filter: white = high value, black = low value
Original Filtered“Ringing” artifacts!
© Mahesh Goyani10/19/2016 42
10/19/2016
8
SMOOTHING WITH A GAUSSIAN
Original Filtered
© Mahesh Goyani10/19/2016 43
EFFICIENT IMPLEMENTATION
Both, the BOX filter and the Gaussian filter are separable:
First convolve each row with a 1D filter
Then convolve each column with a 1D filter
Remember:
Convolution is linear – associative and commutative
x y x y x yg g I g g I g g I
I
gx
I’gy
© Mahesh Goyani10/19/2016 44
FILTERING – BOUNDARY ISSUES
What is the size of the output?
MATLAB: filter2(g,f,shape)
shape = ‘full’: output size is sum of sizes of f and g
shape = ‘same’: output size is same as f
shape = ‘valid’: output size is difference of sizes of f and g
f
gg
gg
full
f
gg
gg
same
f
gg
gg
valid
© Mahesh Goyani10/19/2016 45
FILTERING – BOUNDARY ISSUES
How should the filter behave near the image boundary?
The filter window falls off the edge of the image
Need to extrapolate
Methods:
• Clip filter (black)
• Wrap around
• Copy edge
• Reflect across edge
imfilter(f,g,0)
imfilter(f,g,‘circular’)
imfilter(f,g,‘replicate’)
imfilter(f,g,‘symmetric’)
© Mahesh Goyani10/19/2016 46
FILTER SHAPES
Box Filter Tent Filter
Gaussian Filter
© Mahesh Goyani10/19/2016 47
ORDER STATISTIC (NON LINEAR) FILTER
Median Filter : Sort the values of pixels in question and its neighbors
Replace the value of centre pixel with median
Median of a set of values is such that half values in the set are less than or
equal to median and half are greater than or equal to median.
In 3X3 neighborhood the median is the 5th largest value
They provide good result in case of random (impulse) noise. Salt and paper
noise they give good result with less blurring
Forces points with distinct gray levels to be more like their neighbors
© Mahesh Goyani10/19/2016 48
10/19/2016
9
MEDIAN FILTER: HOW IT WORKS ?
A median filter is good for removing impulse, isolated noise
Degraded image
Salt noise
Pepper noise
Sorted array
Salt noisePepper noise
Median
Filter output
Normally, impulse noise has high magnitude and is isolated. When we sort pixels in
the moving window, noise pixels are usually at the ends of the array.
Therefore, it’s rare that the noise pixel will be a median value.
Movingwindow
© Mahesh Goyani10/19/2016 49
MEDIAN FILTER - EXAMPLE
© Mahesh Goyani10/19/2016 50
MEDIAN VS. AVERAGING FILTER - EXAMPLE
Image of Circuit board corrupted by salt and
pepper noise
Noise reduction with3 X 3 Averaging Filter
Noise reduction with3 X 3 Median Filter
© Mahesh Goyani10/19/2016 51
LOW PASS AND MEDIAN FILTER
Original image Averaging filter Median filter
Edge
Noise pulse
1 1 1
1 1 1
The low-pass filter can provide image smoothing and noise reduction, but
subdues and blurs sharp edges.
Median filters can provide noise filtering without blurring.
© Mahesh Goyani10/19/2016 52
LOW PASS AND MEDIAN FILTER
Low pass spatial filtering
Linear Filter
Neighborhood averaging
Can use different size of masks
Sum of the mask coefficients is 1
Drawbacks: blur edges and other sharp features
Median filtering
Nonlinear
The gray level of each pixel is replaced by the
median of its neighbors
Good at denoising pepper & Salt noise
© Mahesh Goyani10/19/2016 53
MAX AND MIN FILTER
Max filter: ),(max),(ˆ),(
tsgyxfxySts
It determines brightest point in image.
Useful in eliminating pepper noise.
It determines darkest point in image.
Useful for eliminating salt noise.
Min filter: ),(min),(ˆ),(
tsgyxfxySts
4
5
8
7
2
4
2
3
3
3
3
3
3 3 3 3
MIN
MAX
© Mahesh Goyani10/19/2016 54
10/19/2016
10
MAX AND MIN FILTERS - EXAMPLE
Image corrupted by pepper noise with prob. = 0.1
Image corrupted
by salt noise with prob. = 0.1
Image obtained
using a 3x3max filter
Image obtained
using a 3x3min filter
© Mahesh Goyani10/19/2016 55
ORDER STATISTICS FILTER
sort
f4 f3 f7 f6 f8 f2 f1 f9 f5
medianfilter
increasing order
maxfilter
minfilter
f1 f2 f3
f4 f5 f6
f7 f8 f9
© Mahesh Goyani10/19/2016 56
Sharpening Filters
© Mahesh Goyani10/19/2016 57
SHARPENING (HIGH PASS) SPATIAL FILTERS
Since averaging is analogous to integration.
Sharpening could be accomplished by spatial differentiation.
We are interested in the behavior of these derivatives in areas
of constant gray level, at the onset and end of discontinuities(step
and ramp discontinuities), and along gray-level ramps.
These types of discontinuities can be noise points, lines, and
edges.
© Mahesh Goyani10/19/2016 58
FUNDAMENTALS
Highlight fine details or enhance details that have been blurred.
Sharpening can be accomplished by spatial differentiation.
Strength of response of derivative operator is proportional to
degree of intensity discontinuity of the image at the point at which
operator is applied.
Image differentiation enhances edges and other discontinuity,
and deemphasize areas with slowly varying intensities.
© Mahesh Goyani10/19/2016 59
FOUNDATION
First order derivative
Must be zero in constant areas
Must be nonzero at the onset of a gray level step or ramp
Must be nonzero along ramps
Second order derivative
Must be zero in constant areas
Must be nonzero at the onset & end of a gray level step or ramp
Must be zero along ramps of constant slope.
© Mahesh Goyani10/19/2016 60
10/19/2016
11
SPATIAL DERIVATIVES
First-order derivative :
Second-order derivative :
)(2)1()1(2
2
xfxfxfx
f
)()1( xfxfx
f
© Mahesh Goyani10/19/2016 61
SHARPENING SPATIAL FILTERS – IN DEPTH
© Mahesh Goyani10/19/2016 62
SHARPENING SPATIAL FILTERS – IN DEPTH
© Mahesh Goyani10/19/2016 63
1ST ORDER DERIVATIVE
The 1st-order derivative is nonzero along the entire ramp
First order derivatives are use for edge extraction
First order derivatives have a stronger response to a gray level
step
First order derivatives produce thicker edges.
© Mahesh Goyani10/19/2016 64
2ND ORDER DERIVATIVE
2nd order derivative produces make thin edge
2nd-order derivative is nonzero only at the onset and end of the
ramp.
Second order derivative is useful to enhance fine detail
(including noise) much more than a first order derivative
Second order derivatives produce a double response at step
changes in gray level
Second order derivatives response is stronger to a line than to a
step and to a point than to a line
© Mahesh Goyani10/19/2016 65
LAPLACIAN
Extensively used in segmentation
Derivative of any order are linear operations, so the Laplacian
is a linear operator.
Laplacian are isotropic (rotation invariant) for rotation
increments of 90o and 45o.
The Laplacian is often applied to an image that has first been
smoothed with something approximating a Gaussian smoothing
filter in order to reduce its sensitivity to noise.
© Mahesh Goyani10/19/2016 66
10/19/2016
12
DISCRETE FORM OF DERIVATIVES
),(2),1(),1(2
2
yxfyxfyxfx
f
f(x+1,y)f(x,y)f(x-1,y)
f(x,y+1)
f(x,y)
f(x,y-1)
),(2)1,()1,(2
2
yxfyxfyxfy
f
© Mahesh Goyani10/19/2016 67
2D LAPLACIAN
The digital implementation of the 2-Dimensional Laplacian is
obtained by summing 2 components :
2
2
2
22
x
f
x
ff
),(4)1,()1,(),1(),1(2 yxfyxfyxfyxfyxff
1
1
-4 1
1
© Mahesh Goyani10/19/2016 68
2D LAPLACIAN
1
1
-4 1
1
0 0
0 0
0
0
-4 0
0
1 1
1 1
1
1
-8 1
1
1 1
1 1
© Mahesh Goyani10/19/2016 69
2D LAPLACIAN
-1
-1
4 -1
-1
0 0
0 0
0
0
4 0
0
-1 -1
-1 -1
-1
-1
8 -1
-1
-1 -1
-1 -1
90o Rotation Invariant
45o Rotation Invariant
© Mahesh Goyani10/19/2016 70
IMPLEMENTATION
-1 2 -1
2 -4 2
-1 2 -1
0 1 0
1 -4 1
0 1 0
1 1 1
1 -8 1
1 1 1
1 -2 1
-2 4 -2
1 -2 1
0 -1 0
-1 4 -1
0 -1 0
-1 -1 -1
-1 8 -1
-1 -1 -1
),(),(
),(),(),(
2
2
yxfyxf
yxfyxfyxg
If the center coefficient is negative
If the center coefficient is positive
Where f(x,y) is the original image
is Laplacian filtered image
g(x,y) is the sharpen image
),(2 yxf
© Mahesh Goyani10/19/2016 71
LAPLACIAN OPERATOR
Since the sum of all the weights is zero, the resulting signal will have a zero DC
value
Produce noisier result
It is used to highlights gray level discontinuities and deemphasizes regions
with slowly varying gray levels
Background features can be recovered while still preserving the sharpening
effect of the Laplacian operator by adding original and Laplacian images
Unsharp masking and high-boost filtering
© Mahesh Goyani10/19/2016 72
10/19/2016
13
SHARPENING USING LAPLACIAN
-1 4 -1 1
0
0
+ =
0 -1 0
0 -1 0 0
0
0
0
0
0
5
-1
-1
0
-1
0
0
-1
0
LAPLACIANOriginal Image Sharpened Image
© Mahesh Goyani10/19/2016 73
IMPLEMENTATION
-1 -1 -1
-1 8 -1
-1 -1 -1
Filtered = Conv(image,mask)
filtered = filtered - Min(filtered)
filtered = filtered * (255.0/Max(filtered))
sharpened = image + filtered
sharpened = sharpened - Min(sharpened )
sharpened = sharpened * (255.0/Max(sharpened ))
© Mahesh Goyani10/19/2016 74
LAPLACIAN OPERATOR
+
Edges detected by the Laplacian
can be used to sharpen the image !
© Mahesh Goyani10/19/2016 75
LAPLACIAN OPERATOR – IMAGE SHARPENING
),(),(
),(),(),(
2
2
yxfyxf
yxfyxfyxg
© Mahesh Goyani10/19/2016 76
LAPLACIAN OF GAUSSIAN (LOG)
Convolution is associative, we can convolve the Gaussian
smoothing filter with the Laplacian filter first of all, and then
convolve this hybrid filter with the image to achieve the required
result.
Advantages:
Fewer arithmetic operations.
The LoG mask can be precalculated in advance so only one
convolution needs to be performed at run-time on the image.
© Mahesh Goyani10/19/2016 77
DERIVATIVE OF GAUSSIAN
© Mahesh Goyani10/19/2016 78
10/19/2016
14
LAPLACIAN OF GAUSSIAN (LOG)
The 2D Laplacian of Gaussian (LoG) function
Matlab: fspecial(‘log’,…)
© Mahesh Goyani10/19/2016 79
LAPLACIAN OF GAUSSIAN (LOG)
Areas where the image has a constant intensity (i.e. where the intensity
gradient is zero), the LoG response will be zero.
LoG response will be positive on the darker side, and negative on the lighter
side.
This means that at a reasonably sharp edge between two regions of uniform
but different intensities, the LoG response will be:
Zero at a long distance from the edge.
Positive just to one side of the edge.
Negative just to the other side of the edge.
Zero at some point in between, on the edge itself.
© Mahesh Goyani10/19/2016 80
UNSHARP MASKING
Used in printing industries
STEPS:
Blur the original image
Subtracting a blurred image from its original (Difference is
called MASK)
Add this mask to original image
© Mahesh Goyani10/19/2016 81
UNSHARP MASKING & HIGH BOOST FILTERING
),(),(),( yxfyxfyxgmask
),(*),(),( yxgkyxfyxg mask
If k = 1; Unsharp masking
If k > 1; High boost filtering
If k < 1; Deemphasize contribution of
Unsharp masking
© Mahesh Goyani10/19/2016 82
UNSHARP MASKING & HIGH BOOST FILTERING
High-boosting filtering
Highpass = Original – Lowpass
High boost = Original – K*Lowpass = Original + K*Highpass
Visual effect : brighten while sharpening on the original image
Fsharp = a*F – Fblurred , a>=1
1),(),(),( AwhereyxfyxAfyxfhb
),(),(),()1(),( yxfyxfyxfAyxfhb
),(),()1(),( yxfyxfAyxf shb
© Mahesh Goyani10/19/2016 83
HIGH BOOST FILTERING
0 -1 0
-1 A+4 -1
0 -1 0
-1 -1 -1
-1 A+8 -1
-1 -1 -1
),(),(
),(),(
),(2
2
yxfyxAf
yxfyxAf
yxfhb
If the center coefficient is negative
If the center coefficient is positive
© Mahesh Goyani10/19/2016 84
10/19/2016
15
UNSHARP MASKING & HIGH BOOST FILTERING
Original Image
Gaussian Smoothing (size: 5 X 5, Sigma = 3)
Unsharp Mask
Sharpened image (k=1)
High boost filtering (K = 4.5)
© Mahesh Goyani10/19/2016 85
HIGH BOOST FILTERING
A = 0
A = 1 A = 1.7
1 1 1
1 8 1
1 1 1
© Mahesh Goyani10/19/2016 86
HIGH BOOST FILTERING
1 1 1
1 8 1
1 1 1
A high-pass filter A high-boost filter
1 1 1
1 9 1
1 1 1
Original Image
© Mahesh Goyani10/19/2016 87
UNSHARP MASKING & HIGH BOOST FILTERING
Input Image Lowpass Filter
Histogram Shrink
Subtract Images
Histogram Stretch
Sharpened Image
© Mahesh Goyani10/19/2016 88
UNSHARP MASKING & HIGH BOOST FILTERING
The subtraction has the visual effect of causing overshoot
and undershoot at the edges, which will emphasize the edges.
By scaling the low passed image with a histogram shrink,
we can control the amount of edge emphasis desired.
To get more sharpening effect, shrink the histogram less.
© Mahesh Goyani10/19/2016 89
1ST DERIVATIVE - GRADIENT
The gradient of the image, gives the direction of the largest
possible increase from light to dark and the rate of change in that
direction.
The result therefore shows how "abruptly" or "smoothly" the
image changes at that point, and therefore how likely it is that, it
represents an edge, as well as how that edge is likely to be oriented.
In practice, the magnitude (likelihood of an edge) calculation is
more reliable and easier to interpret than the direction calculation.
© Mahesh Goyani10/19/2016 90
10/19/2016
16
SHARPENING FILTERS BASED ON FIRST DERIVATIVES
Magnitude: provides information about edge strength.
Direction: perpendicular to the direction of the edge.
x
f
y
f
Direction (grad(f)) = tan-1
yxyx GGGGfmag 22)( Cheaper Approximation
Gradient =
y
fx
f
G
G
y
xf
© Mahesh Goyani10/19/2016 91
ENHANCEMENT USING 1ST DERIVATIVE - THE GRADIENT
Used to enhance prominent edges.
It has stronger response in area of gray level transitions (gray
level ramps and steps)
It always point the direction of maximum rate of change of f at
coordinates (x,y)
Magnitude give rate of increase of f(x,y) per unit distance in
the direction of Δf
© Mahesh Goyani10/19/2016 92
EDGE CAUSES
Depth discontinuity
Surface orientation discontinuity
Reflectance discontinuity (i.e., change in surface
material properties)
Illumination discontinuity (e.g., shadow)
© Mahesh Goyani10/19/2016 93
ROBERTS CROSS GRADIENT OPERATORS
X direction and y direction gradient can be found using
following mask
The primary disadvantage of the Roberts operator is its high
sensitivity to noise, because very few pixels are used to
approximate the gradient.
-1 0
0 1
0 -1
1 0
z1 z2 z3
z4 z5 z6
z7 z8 z9
Gx = (z9-z5) and Gy = (z8-z6)
2
68
2
59 )()( zzzzf
6859 zzzzf
© Mahesh Goyani10/19/2016 94
SOBEL OPERATORS
Mask of even size are awkward to apply.
Weight of value 2 is to achieve some smoothing by giving more
importance to the center point
Sum of all coefficients in masks sum to zero indicating that
they would give zero response of 0 in an area of constant gray
level
-1 -2 -1
0 0 0
1 2 1
-1 0 1
-2 0 2
-1 0 1
)2()2()2()2( 741963321987 zzzzzzzzzzzzf
© Mahesh Goyani10/19/2016 95
SOBEL OPERATOR - EXAMPLE
The Sobel filter extracts all of the edges in an image,
regardless of direction
It is implemented as the sum of two directional edge
enhancement operators
© Mahesh Goyani10/19/2016 96
10/19/2016
17
DIFFERENT TYPE OF KERNELS
1
111
1
-1 -1
Prewitt 1
-2
-1
-3
555
-3
-3 -3 -3
Kirsch
0
0
111
0
-1 -1 -1
Prewitt 2
0 0
121
0
-1 -2 -1
Sobel
0
-1 -1
11
0 0 0
- 2
2
Frei & Chen
© Mahesh Goyani10/19/2016 97
COMBINING SPATIAL ENHANCEMENT METHOD
Goal:
want to sharpen the original image and bring out
more skeletal detail.
problems: narrow dynamic range of gray level and
high noise content makes the image difficult to
enhance
Solution:
1. Laplacian to highlight fine detail
2. gradient to enhance prominent edges
3. gray-level transformation to increase the
dynamic range of gray levels
© Mahesh Goyani10/19/2016 98
COMBINING SPATIAL ENHANCEMENT METHOD
Laplacian filter of bone scan (a)
Sharpened version of bone scan achieved by subtracting (a) and (b) Sobel filter of bone
scan (a)
(a)
(b)
(c)
(d)
© Mahesh Goyani10/19/2016 99
COMBINING SPATIAL ENHANCEMENT METHOD
The product of (c) and (e) which will be used as a mask
Sharpened image which is sum of (a) and (f)
Result of applying a power-law trans. to (g)
(e)
(f)
(g)
(h)
Image (d) smoothed with a 5*5 averaging filter
© Mahesh Goyani10/19/2016 100
COMBINING SPATIAL ENHANCEMENT METHOD
Compare the original and final images
© Mahesh Goyani10/19/2016 101
THANKS…!!!
?
© Mahesh Goyani10/19/2016 102
10/19/2016
18
AUTHOR’S PROFILE
Mahesh Goyani has completed his graduation in Computer Engineering from SCET, VNSGU,
Surat in 2005 with distinction. He received his Master Degree in field of Computer
Engineering with 9.38 CPI (81.03 %) from BVM College, SPU, Anand in 2009. He has secured
1st rank twice in university during his master degree. His area of interest is Image
Processing, Computer Graphics, Computer Algorithms and Artificial Intelligence.
Publication: He has published many research papers in national and international journals and conferences. He
was invited as a SESSION CHAIR in International Conference on Engineering, Science and Information Technology,
Tirunelveli, Tamilnadu, Sept - 2011. He has published 11 books in filed of Computer Graphics and Computer
Algorithms for various universities.
He is the member of technical review committee of International Journal of Computer Science & Issues (IJCSE,
Mauritius), Electronics & Telecommunication Research Institute (ETRI, Korea), International journal of
Engineering & Technology (IJET, Singapore), International journal of Computer Science & Information Security
(IJCSIS, Pittsburg, USA). He has worked as a program committee member and reviewer in many International
Conferences. He is also a life time member of ISTE technical society.
Web Site: www.maheshgoyani.in
© Mahesh Goyani10/19/2016 103