Image Enhancement (Spatial Filtering 2) Dr Samir H Abdul Dr Samir H Abdul-Jauwad Jauwad Dr. Samir H. Abdul Dr. Samir H. Abdul Jauwad Jauwad Electrical Engineering Department Electrical Engineering Department College of Engineering Sciences College of Engineering Sciences King Fahd University of Petroleum & Minerals King Fahd University of Petroleum & Minerals Dhahran Dhahran – Saudi Arabia Saudi Arabia [email protected][email protected]
33
Embed
Image Enhancement (Spatial Filtering 2)faculty.kfupm.edu.sa/ee/samara/EE663_Lecture_6.pdf · Image Enhancement (Spatial Filtering 2) Dr Samir H AbdulDr. Samir H. Abdul-Jauwad Electrical
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Image Enhancement (Spatial Filtering 2)
Dr Samir H AbdulDr Samir H Abdul--JauwadJauwadDr. Samir H. AbdulDr. Samir H. Abdul JauwadJauwadElectrical Engineering DepartmentElectrical Engineering DepartmentCollege of Engineering SciencesCollege of Engineering Sciences
King Fahd University of Petroleum & MineralsKing Fahd University of Petroleum & Mineralsg yg yDhahran Dhahran –– Saudi ArabiaSaudi [email protected]@kfupm.edu.sa
ContentsContents
In this lecture we will look at more spatial filtering In this lecture we will look at more spatial filtering techniques
Previously we have looked at smoothing filters which Previously we have looked at smoothing filters which remove fine detailSharpening spatial filters seek to highlight fine detailSharpening spatial filters seek to highlight fine detail
– Remove blurring from imagesHi hli ht d– Highlight edges
Sharpening filters are based on spatial differentiation
Spatial DifferentiationSpatial DifferentiationDifferentiation measures the rate of change of a functionLet’s consider a simple 1 dimensional example
Spatial DifferentiationSpatial Differentiation
A B
11stst DerivativeDerivative
The formula for the 1st derivative of a function is as The formula for the 1 derivative of a function is as follows:
)()1( xfxff
)()1( xfxfxf
It’s just the difference between subsequent values and measures the rate of change of the function
Using Second Derivatives For Image Using Second Derivatives For Image EnhancementEnhancementEnhancementEnhancement
The 2nd derivative is more useful for image genhancement than the 1st derivative
– Stronger response to fine detailg p– Simpler implementation– We will come back to the 1st order derivative later on
The first sharpening filter we will look at is the Laplacian– Isotropic– One of the simplest sharpening filters– We will look at a digital implementation
The LaplacianThe LaplacianThe Laplacian is defined as follows:
yf
xff 2
2
2
22
where the partial 1st order derivative in the x direction is defined as follows:
yx
),(2),1(),1(2
2
yxfyxfyxff
and in the y direction as follows:2x
2 f ),(2)1,()1,(2 yxfyxfyxfyf
The Laplacian (cont…)The Laplacian (cont…)So, the Laplacian can be given as follows:
),(4 yxfWe can easily build a filter based on this
0 1 00 1 0
1 -4 1
0 1 0
The Laplacian (cont…)The Laplacian (cont…)
Applying the Laplacian to an image we get a new image Applying the Laplacian to an image we get a new image that highlights edges and other discontinuities
But That Is Not Very Enhanced!But That Is Not Very Enhanced!The result of a Laplacian filtering is not an enhanced imageWe have to do more work in order to get our final imageSubtract the Laplacian result from the Subtract the Laplacian result from the original image to generate our final sharpened enhanced image
Variants On The Simple LaplacianVariants On The Simple Laplacian
There are lots of slightly different versions of the There are lots of slightly different versions of the Laplacian that can be used:
0 1 0 1 1 1
1 -4 1
0 1 0
1 -8 1
1 1 1
SimpleLaplacian
Variant ofLaplacian
0 1 0 1 1 1
-1 -1 -1
-1 9 -1
-1 -1 -1
Simple Convolution Tool In JavaSimple Convolution Tool In Java
A great tool for testing out different filtersA great tool for testing out different filters– From the book “Image Processing tools in Java”– Available from webCT later on today– Available from webCT later on today– To launch: java ConvolutionTool Moon.jpg
11stst Derivative FilteringDerivative FilteringImplementing 1st derivative filters is difficult in practiceFor a function f(x, y) the gradient of f at coordinates (x, y) is given as the column vector:
xf
Gxf
yfx
Gyf
11stst Derivative Filtering (cont…)Derivative Filtering (cont…)The magnitude of this vector is given by:
)f( magf
2122 GG yx GG
21
22
ff
yf
xf
For practical reasons this can be simplified as:GGf yx GGf
11stst Derivative Filtering (cont…)Derivative Filtering (cont…)There is some debate as to how best to calculate these gradients but we will use:
321987 22 zzzzzzf
which is based on these coordinates 741963 22 zzzzzz
which is based on these coordinates
z1 z2 z31 2 3
z4 z5 z6
z7 z8 z9
Sobel OperatorsSobel OperatorsBased on the previous equations we can derive the Sobel Operators
1 2 1 1 0 1-1 -2 -1
0 0 0
-1 0 1
-2 0 2
f f
1 2 1 -1 0 1
To filter an image it is filtered using both operators the results of which are added together
Sobel ExampleSobel Example
An image of a gcontact lens which
is enhanced in order to make
defects (at fourdefects (at four and five o’clock in the image) more
obvious
Sobel filters are typically used for edge detection
11stst & 2& 2ndnd DerivativesDerivatives
Comparing the 1st and 2nd derivatives we can conclude Comparing the 1 and 2 derivatives we can conclude the following:
– 1st order derivatives generally produce thicker edges1 order derivatives generally produce thicker edges– 2nd order derivatives have a stronger response to fine
detail e.g. thin linesdetail e.g. thin lines– 1st order derivatives have stronger response to grey level
stepp– 2nd order derivatives produce a double response at step
changes in grey levelg g y
SummarySummary
In this lecture we looked at:In this lecture we looked at:– Sharpening filters
Successful image enhancement is typically not achieved using a single operationRather we combine a range of techniques in order to achieve a final resultThis example will focus on This example will focus on enhancing the bone scan to the rightg t