image enhancement in the spatial domain_sa
TRANSCRIPT
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
1/48
IMAGE ENHANCEMENT IN THESPATIAL DOMAIN
Digital Image Processing, Chapter 3 Gonzalez Woods
Digital Image Processing In Life-Science
Sefi addadi 21-3-2012
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
2/48
WHAT DID WE LEARN LAST TIME?
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
3/48
WHAT WILL BE TODAY?Image enhancement in the spatial domain
Gray level transformation
Negative, Log and power law
Histogram processing
Equalization
Matching
Local enhancement
Spatial filtering
Smoothing filters (mean, Gaussian, median)
Sharpening filters
Edge detection Filter combinations
Background correction
Acquisition (a priori) correction
Retrospective (a posteriori) correction
Rolling ball background correction
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
4/48
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
The principal objective of enhancement
Process an image so that the result is more suitable than the
originalimage for a specific application.
Spatial domain refers to the image planeitself, and approaches in
this category are based on direct manipulation of pixels in an
image.
There is no general theory of image enhancement.
When an image is processed for visual interpretation, the viewer is
the ultimate judge of how well a particular method works.
Gonzalez Woods Chapter 3
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
5/48
Image g(x, y)
x
y
Target
MATHEMATICAL REPRESENTATION
g(x, y) = T{f(x, y) }General expression
Origin
x
y Image f (x, y)
(x, y)Neighbourhood
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
6/48
GRAY LEVEL TRANSFORMATIONS
Among the simplest of all
image enhancement
techniques.
Generally denoted by
rvalues before
transformation
sValues after transformation
Tthe performed
transformation s = T(r)
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
7/48
POWER- LAW TRANSFORMATIONS
S= cr where c and
are positive constants
Power-law curves with
fractional values ofmap a narrow range of
dark input values into a
wider range of output
values. The opposite being true
for highs.
Many devices used for image capture, printing, and display
respond according to a power lawGamma correction
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
8/48
HISTOGRAM PROCESSING
Histogram in digital images is defined as a discreet
function h(rk) = nk
Where rk is the gray level of k andnk is the number of pixels of that value
Histogram normalization
Performed by dividing each value by the total number of pixels in theimage.
p(rk) = nk / n
p(rk) gives an estimate of the probability of occurrence of gray levelrk.
The sum of all components of a normalized histogram is equal to 1.
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
9/48
High contrast image
Low contrast image
Bright image
Dark image
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
10/48
Histogram Equalization
p(rk) = nk / n
histogram equalization
Each pixel with level
rk is mapped into a
corresponding pixel
with level sk in the
output image.
histogram linearization
Automated process
does not require
additional input
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
11/48
HISTOGRAM MATCHING
The method used to generate a processed image thathas a specified histogram shape.
In contrast to the aim of histogram where we perform
automatic uniform histogram.
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
12/48
HISTOGRAM MATCHING
1. Obtain the histogram of the given
image.
2. Precompute a mapped level sk for each
level rk.
3. Obtain the transformation function Gfrom the given pz(z)
4. Precompute zk for each value of sk
using the iterative scheme defined in
connection
5. For each pixel in the original image,
if the value of that pixel is rk, map this
value to its corresponding level sk;
then map then map level sk into thefinal level zk.
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
13/48
Original Histogram equalizedimage
Using mappings fromcurve
ImagestakenfromGonzalez&Wood
s,DigitalImageProces
sing(2002)
HISTOGRAM MATCHING
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
14/48
HISTOGRAM SUMMARY
Useful for assessment of acquisition quality.
Critical for image presentation
Used as basis for subsequent analysis steps such as
thresholding etc.
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
15/48
NEIGHBORHOOD OPERATIONS
Neighborhood is defined asany area bigger than thesingle pixel.
May be of any size orshape.
Most used rectangle are
around the central pixel
Might be referred to asfilters, kernels, templates,or windows.
Origin x
y Image f (x, y)
(x, y)Neighbourhood
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
16/48
NEIGHBOURHOOD OPERATIONS
For each pixel in the origin image, the outcome is
written on the same location at the target image.
Originx
y Image f (x, y)
(x, y)Neighbourhood
Target
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
17/48
SIMPLE NEIGHBOURHOOD
OPERATIONS
Simple neighbourhood operations example:
Min: Set the pixel value to the minimum in the
neighbourhood
Max: Set the pixel value to the maximum in the
neighbourhood
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
18/48
Max Filter
Radius = 3
Original Min Filter
Radius = 3
SIMPLE NEIGHBOURHOOD OPERATIONS
http://www.biologyimagelibrary.com/
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
19/48
48 4 5 2 082 29 5 1 2115 66 9 1 0135 103 33 12 0142 132 82 43 9121 140 124 80 3086 121 135 108 6763 98 129 125 10252 70 108 125 11753 55 83 113 12372 62 66 98 12477 73 63 77 10755 69 69 62 8132 61 80 63 7214 45 71 70 742 28 53 67 732 7 35 64 697 10 25 52 644 5 7 31 554 1 0 14 43
135 135 115 82 29142 142 135 115 66142 142 142 135 103142 142 142 142 132142 142 142 142 140142 142 142 142 140142 142 142 140 140142 142 140 140 135140 140 140 135 135129 135 135 135 129113 129 129 129 12898 124 126 127 14180 107 124 127 14480 81 110 127 14580 80 102 127 14580 80 96 126 14571 80 86 119 14464 71 77 115 14452 64 75 111 14431 55 74 108 145
1 0 0 0 01 0 0 0 01 0 0 0 01 0 0 0 09 0 0 0 033 9 0 0 052 30 7 0 052 52 30 7 152 52 52 30 752 52 52 52 3532 32 52 53 5514 14 32 55 622 2 14 32 612 2 2 14 452 2 2 2 282 2 2 2 71 0 0 0 70 0 0 0 00 0 0 0 00 0 0 0 0R=3
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
20/48
48 4 5 2 082 29 5 1 2115 66 9 1 0135 103 33 12 0142 132 82 43 9121 140 124 80 3086 121 135 108 6763 98 129 125 10252 70 108 125 11753 55 83 113 12372 62 66 98 12477 73 63 77 10755 69 69 62 8132 61 80 63 7214 45 71 70 742 28 53 67 732 7 35 64 697 10 25 52 644 5 7 31 554 1 0 14 43
3 2 0 0 03 1 1 0 09 1 0 0 033 9 0 0 082 33 9 0 063 80 30 7 052 63 67 30 752 52 63 67 3052 52 52 70 6752 52 53 55 8352 53 55 62 6632 55 62 62 6214 32 55 62 622 14 32 61 622 2 14 45 632 2 2 28 532 2 2 7 352 1 0 7 250 0 0 0 70 0 0 0 0
115 82 48 6 6135 115 82 29 5142 135 115 65 12142 142 135 103 43142 142 142 132 82142 142 140 140 124142 140 140 134 134129 140 134 134 129108 129 134 129 12583 113 129 125 12677 98 124 126 12677 77 107 124 12677 80 81 110 12780 80 80 102 12771 80 80 96 12653 71 80 86 11935 64 71 77 11525 52 64 75 11110 31 55 74 1087 14 42 69 100 R=1.5
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
21/48
62 82 91 87 5680 91 105 105 80
106 115 123 119 100133 154 151 137 115147 181 181 159 130125 163 186 174 14889 125 164 170 15855 89 116 133 13542 71 80 102 12026 47 69 84 10214 24 59 74 929 11 27 50 797 7 7 27 496 2 7 13 203 0 2 4 80 0 13 7 10 0 6 3 00 1 0 0 00 1 0 0 01 0 4 0 0
62 62 56 19 562 62 56 19 562 62 80 33 580 80 91 55 1489 89 115 79 3255 55 89 98 5142 42 55 80 8226 26 42 69 8014 14 24 47 699 9 11 24 507 7 7 7 272 2 2 7 70 0 0 2 40 0 0 0 10 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 0
114 123 123 122 119154 154 154 151 137181 180 181 181 159181 186 186 186 181186 186 185 186 186186 186 186 186 186186 186 186 186 186164 186 186 186 174124 164 170 171 17089 116 134 136 15072 83 102 120 13359 74 92 102 10927 59 79 92 9211 27 50 79 8213 13 27 49 5513 13 13 30 5213 12 13 22 506 13 13 14 394 6 6 8 294 4 4 5 16
R=2
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
22/48
THE SPATIAL FILTERING PROCESS
j k l
m n o
p q r
Origin x
y Image f (x, y)
eprocessed= n*e +
j*a + k*b + l*c +
m*d + o*f +p*g + q*h + r*i
Filter (w)Simple 3*3Neighbourhood
e 3*3 Filter
a b c
d e f
g h i
OriginalImage Pixels
*
Performed for each pixel in the original image
to generate the filtered image
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
23/48
SMOOTHING SPATIAL FILTERS
Simple spatial filter
Average all of the pixels in a neighbourhood around a
central value according to selected mask.
Especially useful
in removing noise
from images
Also useful for
highlighting gross
detail
1/91/9
1/9
1/9
1/9
1/9
1/91/9
1/9
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
24/48
SMOOTHING SPATIAL FILTERING
1/91/9
1/91/
9
1/9
1/9
1/91/9
1/9
Origin x
y Image f (x, y)
e= 1/9*106 + 1/
9*104 + 1/
9*100 + 1/
9*108 + 1/
9*99 + 1/
9*98 +
1
/9*95 +1
/9*90 +1
/9*85 = 98.3333
Filter
Simple 3*3
Neighbourhood106
104
99
95
100 108
98
90 85
1/91/9
1/9
1/91/9
1/9
1/91/9
1/9
3*3 Smoothing
Filter
104 100 108
99 106 98
95 90 85
Original
Image Pixels
*
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
25/48
Original Mean R=1
Mean R=2 Mean R=4
MEAN FILTER
SMOOTHING
As R grows
Fine details and
noise vanish
AVERAGING
FILTER
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
26/48
WEIGHTED AVERAGE
Created by defining different weight for different
pixels around the center pixel.
Pixels closer to the center pixel
are contribute more to the average
Size of objects in the image should
taken into account.
1/162/16
1/16
2/164/16
2/16
1/162/16
1/16
a
as
b
bt
a
as
b
bt
tsw
tysxftsw
yxg
),(
),(),(
),(General annotation for
weighted average filtering
an MxN image
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
27/48
Comparison ofMean and
Median
R=2
Mean Filter Median Filter
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
28/48
GENERAL FILTERING REMARKS
There is no such thing as GOOD FILTER
but a SUITABLE filter for a specific need / task.
Spatial filters can and should be applied in
combination for optimal results.
Spatial filters changethe numbers of signal
intensities and might change the area of an objectshould be remembered in quantification
GO BACK TO THE ORIGINAL
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
29/48
SHARPENING SPATIAL FILTERS
The principal objective of sharpening is to highlight fine
detail in an image or to enhance detail that has been
blurred, either in error or as a natural effect of a
particular method of image acquisition.
Sharpening filters are based on spatial differentiation
Averaging Integration
= Blurring
Sharpening
spatial differentiation
Gonzalez Woods Chapter 3
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
30/48
SPATIAL DIFFERENTIATION
Differentiation measures the rate of change of a function.For a simplified explanation we will use a 1 dimensional
example
ImagestakenfromGonzalez&Woods,DigitalImageProcessing(2002)
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
31/48
SPATIAL DIFFERENTIATION
ImagestakenfromGonzalez&Woods,DigitalImageProcessing(2002)
A B
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
32/48
1ST DERIVATIVE
The formula for the 1st derivative of a function is as
follows:
Calculates difference between subsequent values and
measures the rate of change of the function
)()1( xfxfxf
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
33/48
1STDERIVATIVE (CONT)
0
1
2
3
4
5
6
7
8
-8
-6
-4
-2
0
2
4
6
8
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
f(x)
f (x)
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
34/48
2ND DERIVATIVE
The formula for the 2nd derivative of a function is as
follows:
Takes into account the values both before and after the
current value
)(2)1()1(2
2xfxfxf
xf
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
35/48
1ST AND 2ND DERIVATIVE
-15
-10
-5
0
5
10
f(x)
f(x)
f(x)
0
2
4
6
8
-8
-6
-4
-2
0
2
4
6
8
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
36/48
2ND DERIVATIVES FOR IMAGE
ENHANCEMENTThe 2nd derivative is more useful for image enhancement
Stronger response to fine detail Simpler implementation
The approach
Define a discrete formulation of the second-order derivative. Construct a filter mask based on that formulation.
We are interested in isotropic filters
Independent of the direction of the discontinuities in the image
Rotation invariant
Laplacian - the first sharpening filter we will look at
One of the simplest sharpening filters Isotropic
Linear
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
37/48
THE LAPLACIANThe Laplacian is defined as follows:
Partial 1st order derivative in thex :
In they direction as follows:
y
f
x
ff
2
2
2
22
),(2),1(),1(2
2
yxfyxfyxfx
f
),(2)1,()1,(2
2
yxfyxfyxfy
f
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
38/48
THE LAPLACIAN (CONT)
The sum is given by:
A filter built based on this
),1(),1([2 yxfyxff
)]1,()1,( yxfyxf ),(4 yxf
0 1 0
1 -4 1
0 1 0
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
39/48
THE LAPLACIAN (CONT)
Applying the Laplacian to an image we get a new
image that highlights edges and other discontinuities
Ima
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)
Original
Image
Laplacian
Filtered Image
Laplacian
Filtered Image
Scaled for Display
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
40/48
LAPLACIAN IMAGE ENHANCEMENT
In the final sharpened image edges and fine detail aremuch more obvious
Ima
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)
- =
Original
Image
Laplacian
Filtered Image
Sharpened
Image
fyxfyxg 2),(),(
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
41/48
LAPLACIAN IMAGE ENHANCEMENT
Ima
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
42/48
Original channel Laplace filter Subtraction result
http://www.biologyimagelibrary.com/Image - 21481_0_Miller_28_BIL27090
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
43/48
SHARPENING SUMMARY
A derivative operator is proportional to the degree of
discontinuity of the image at the point at which the
operator is applied.
Thus, image differentiation enhances edges and other
discontinuities (such as noise) and deemphasizes
areas with slowly varying gray-level values
Gonzalez Woods 2nd eddition Chapter 3
EDGE DETECTION AND FILTER
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
44/48
Original Gaussian blur
Laplace Gradient
magnitude
EDGE DETECTION AND FILTER
COMBINATIONS
X
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
45/48
COMBINING SPATIAL
ENHANCEMENT METHODS
Applying a single spatial
operation is usually not enough
Acombination of a range of
techniques in will usually result
in a better final result.
This example will focus on
enhancing the bone scan to the
right
Im
agestakenfromGonzalez&Woods,DigitalImageProcessing(2002)
COMBINING SPATIAL
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
46/48
COMBINING SPATIAL
ENHANCEMENT METHODS (CONT)
Ima
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)
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)
COMBINING SPATIAL
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
47/48
COMBINING SPATIAL
ENHANCEMENT METHODS (CONT)
Ima
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)
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 a5*5 averaging filter
-
7/27/2019 Image Enhancement in the Spatial Domain_SA
48/48
COMBINING SPATIAL
ENHANCEMENT METHODS (CONT)
Compare the original and final images
gestakenfromGonzalez&Woods,DigitalIm
ageProcessing(2002)