Generic, possibly nonlinear, pointwise operator intensity mapping, gray-level transformation: Image Enhancement in the Spatial Domain: Gray-level transforms Image Enhancement in the Spat
Trang 1Generic, possibly nonlinear, pointwise operator (intensity mapping,
gray-level transformation):
Image Enhancement in the Spatial Domain:
Gray-level transforms
Image Enhancement in the Spatial Domain:
Gray-level transforms
Basic gray-level transformations:
Negative:
Generic log:
Power law:
γ
r c s
r c s
r l s
=
+
=
−
−
=
) 1 ln(
1
Image Enhancement in the Spatial Domain:
Gray-level transforms
Image Enhancement in the Spatial Domain:
Gray-level transforms
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Negative
Chapter 3 Image Enhancement in the Spatial Domain:
Negative
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Trang 2Image Enhancement in the Spatial Domain:
Nonlinear mapping
Image Enhancement in the Spatial Domain:
Nonlinear mapping
Image Enhancement in the Spatial Domain:
Gamma correction
Image Enhancement in the Spatial Domain:
Gamma correction
1) Monitor response can
"compensate" for Weber-law sensitivity of HVS:
dp = k dL/L p = k log(L) higher sensit in dark areas dark transitions can be compressed with power law
L = x^gamma
2) Beware of nonlinearities
that are already included in image data (e.g., JPEG)
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Chapter 3 Image Enhancement in the Spatial Domain:
Nonlinear mapping
Trang 3Note: stretching is formally useless if the image has to be thresholded)
Image Enhancement in the Spatial Domain:
Piecewise-linear contrast stretching
Image Enhancement in the Spatial Domain:
Piecewise-linear contrast stretching
Image Enhancement in the Spatial Domain:
Gray-level slicing
Image Enhancement in the Spatial Domain:
Gray-level slicing
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Bit-plane slicing
Chapter 3 Image Enhancement in the Spatial Domain:
Bit-plane slicing
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Bit-plane slicing
Chapter 3 Image Enhancement in the Spatial Domain:
Bit-plane slicing
Trang 4Image Enhancement in the Spatial Domain:
Bit-plane slicing
Image Enhancement in the Spatial Domain:
Bit-plane slicing
4, 8, 16 gray levels respectively
Reconstruction: Sum_n [ bit-plane_n * 2^(n-1) ]
May be useful for data compression
Image Enhancement in the Spatial Domain:
Histogram properties
Image Enhancement in the Spatial Domain:
Histogram properties
Histogram: normalized frequency (y) of gray level values (x).
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram processing via gray mapping
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram processing via gray mapping
(can be inverted and preserves gray-level ordering)
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
Let the gray levels in an image be represented as random variables r in
the range (0,1), with a probability density function (pdf):
Let be a monotonic, invertible transformation on r;
)
(r
pr
)
(r
T
s=
All the pixels below the curve in the interval are mapped to pixels below in
i.e., the two areas are equal:
Let us take the particular transformation
which is monotonic and invertible, since
it is the cumulative distribution function
(cdf) of r
)
(r
pr
) , (r r+dr
)
(s
ps (s,s+ds)
dr r p ds s
p s( ) = r( )
∫
=
) (r p w dw T
Trang 5Image Enhancement in the Spatial Domain:
Histogram equalization
Image Enhancement in the Spatial Domain:
Histogram equalization
The derivative of this function is of course
Substituting in
i.e the transformed variable has an exactly uniform pdf.
In a practical discrete case:
i.e., mapping each gray level into the value given above yields a
uniform pdf for the output image.
In general, only an approximately uniform distribution will be
obtained.
Note: no parameters are needed; the processing is automatic and
straightforward.
) ( /dr p r
1 ) ( )
( ) (s ds=p r dr → p s =
n n r p r T s
k
j j k
j j r k
0 0
∑
∑
=
=
=
=
=
k s k
r
Image Enhancement in the Spatial Domain:
Histogram equalization
Image Enhancement in the Spatial Domain:
Histogram equalization
Example (continuous case):
Equalization is obtained via the transformation:
The transformed variable has a uniform pdf Indeed:
1 0 2 2 ) (r =− r+ ≤r≤
p r
∫ − + =− +
=
s
0
2 2 )
2 2 ( ) (
S Das, IIT Madras, Course on Computer Vision
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
Example (discrete case):
S Das, IIT Madras, Course on Computer Vision
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram equalization
S Das, IIT Madras, Course on Computer Vision
Trang 6Image Enhancement in the Spatial Domain:
Histogram equalization
Image Enhancement in the Spatial Domain:
Histogram equalization
Image Enhancement in the Spatial Domain:
Histogram equalization
Image Enhancement in the Spatial Domain:
Histogram equalization
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Remember that the mapping
yields a (approx.) uniformly distributed output Another variable z,
with a different, known and desired pdf pz, will satisfy the same
equation:
substituting:
i.e., mapping each gray level rk into the zk value given above yields
the desired histogram (pdf) for the output image.
)) ( ( )
1
k k
k k
j j z
z
= 0 ) ( ) (
n n r p r T s
k
j j k
j j r k
0 0
∑
∑
=
=
=
=
=
Gianni Ramponi University of Trieste http://www.units.it/ramponi
sk: uniformly
distributed image
G: determined as cdf of
the desired pdf pz
zk: image with desired
histogram
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Trang 7Image Enhancement in the Spatial Domain:
Histogram specification
Image Enhancement in the Spatial Domain:
Histogram specification
S Das, IIT Madras, Course on Computer Vision
Then determine T(r) and G(z) (cdf’s of the histograms) :
T(r)
Image Enhancement in the Spatial Domain:
Histogram specification
Image Enhancement in the Spatial Domain:
Histogram specification
G(z)
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
)) ( ( )
(
)
S Das, IIT Madras, Course on Computer Vision
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
S Das, IIT Madras, Course on Computer Vision
distributions: original target obtained
n’ k 0 0 0 790 1023 850 656+329 245+122+81
p’(z k) 0 0 0 0.19 0.25 0.21 0.24 0.11
Trang 8Image Enhancement in the Spatial Domain:
Histogram specification
Image Enhancement in the Spatial Domain:
Histogram specification
Image Enhancement in the Spatial Domain:
Histogram specification
Image Enhancement in the Spatial Domain:
Histogram specification
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Chapter 3 Image Enhancement in the Spatial Domain:
Histogram specification
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Local Histogram modification
Chapter 3 Image Enhancement in the Spatial Domain:
Local Histogram modification
At each location the local histogram is computed, the required mapping is determined, and the pixel is mapped (At the next step, it is convenient to update the histogram rather than to re-calculate it from scratch)
Trang 9Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Local values can be estimated for different image statistics, and
used to locally control a gray-level modification function.
E.g.: local mean and variance in the neighborhood Sxy:
Enhancement example: pixels in medium-variance, low-mean
areas are scaled by a positive factor:
Mg and Dg respectively are the global average and s.d of the
image; they are used to make the operator more robust.
∑
∑
∈
∈
−
=
=
Sxy t s
Sxy Sxy
Sxy
t
s
m
,
2 2
,
)]
, ( [ ] ) , ( [ )]
, ( [ ) ,
< < <
=
otherwise y
x
f
Dg k Dg
k Mg k m if y x f
E
y
x
) , (
&
) , ( )
,
2 1
Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Chapter 3 Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Chapter 3 Image Enhancement in the Spatial Domain:
Enhancement based on local statistics
Trang 10Image Enhancement in the Spatial Domain:
Image subtraction
Image Enhancement in the Spatial Domain:
Image subtraction
Assume an image is formed as:
where n(x,y) is i.i.d zero-mean noise If we can average K
acquisitions of the image, the variance of the noise is reduced by the
factor K:
This approach is useful when the sensor noise is relatively high:
poorly illuminated (static) scenes, astronomical images, …
∑
∑
=
=
+
=
k k K
k
K y x f y x g K y x g
1 1
) , ( 1 ) , ( ) , ( 1 ) , (
) , ( ) , ( ) , (x y f x y n x y
Image Enhancement in the Spatial Domain:
Image averaging
Image Enhancement in the Spatial Domain:
Image averaging
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Image averaging
Chapter 3 Image Enhancement in the Spatial Domain:
Image averaging
Fig.3.30 A) Ideal B) Noise added (s.d.=64) C) K=8 D) K=16
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
Generic, possibly nonlinear, neighborhood-based operator:
g(x,y)=T[f(x,y)]
Trang 11∑
∑
∑
−
−
−
−
−
−
b t a
a s
b
b t a
a s
t s w
t y s x f t s w y
x g
) , (
) , ( ) , ( )
, (
The coefficients mask can be used in different ways, the
simplest of which is linear
filtering via the normalized convolution sum:
Note: if the output image is required to be the same size as the input image, the latter must
be suitably padded.
Image Enhancement in the Spatial Domain:
Local operators
Image Enhancement in the Spatial Domain:
Local operators
Image Enhancement in the Spatial Domain:
Local operators
Image Enhancement in the Spatial Domain:
Local operators
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
[dipum]
Matlab implementation using ‘imfilter’
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
Chapter 3 Image Enhancement in the Spatial Domain:
Local operators
[dipum]
Matlab:
correlation or convolution
Trang 12Image Enhancement in the Spatial Domain:
Local operators
Image Enhancement in the Spatial Domain:
Local operators
[dipum]
Matlab: image padding
Image Enhancement in the Spatial Domain:
Linear lowpass filters
Image Enhancement in the Spatial Domain:
Linear lowpass filters
Both masks have power-of-two coefficients, which are simple to implement In the second one even the sum of the coefficients is a power of two.
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
Trang 13Image Enhancement in the Spatial Domain:
Linear lowpass filters
Image Enhancement in the Spatial Domain:
Linear lowpass filters
Image Enhancement in the Spatial Domain:
Linear lowpass filters
Image Enhancement in the Spatial Domain:
Linear lowpass filters
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
Chapter 3 Image Enhancement in the Spatial Domain:
Linear lowpass filters
… A first elementary result in image segmentation!
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Chapter 3 Image Enhancement in the Spatial Domain:
Linear and nonlinear “lowpass” filters
Chapter 3 Image Enhancement in the Spatial Domain:
Linear and nonlinear “lowpass” filters
Let Sxy be an mxn neighborhood of (x,y); define the Median filter:
)}
, ( { median )
, (
) ,
y x f
Sxy t
s ∈
=
Sort the pixel values in Sxy and take the one in position (mn+1)/2.
Note: mn should be odd; if it is even one can take as output the
average of the values in positions mn/2 and mn/2+1 The formal
statistical properties of the filter change.
Trang 14Image Enhancement in the Spatial Domain:
Linear and nonlinear “lowpass” filters
Image Enhancement in the Spatial Domain:
Linear and nonlinear “lowpass” filters
Define a 1-D digital derivative (other definitions are possible):
First-order: Note: it is not “centered”
Second-order:
2-D case:
Gradient:
Laplacian:
) ( ) 1 (x f x f
x
∂
∂
) ( 2 ) 1 ( ) 1 ( )]
1 ( ) ( [ )]
( ) 1 ( [ 2
2
x f x f x f x f x f x f x f x
∂
∂
∂
∂
∂
∂
=
∇
y
f x
f
,
∂
∂
∂
=
∂
∂ +
∂
∂
=
x
f y
f y
f x
f
/ tan
;
|
2 2
α
f
2 2 2
2 2
y
f x
f f
∂
∂ +
∂
∂
=
∇
Image Enhancement in the Spatial Domain:
Sharpening operators
Image Enhancement in the Spatial Domain:
Sharpening operators
Gianni Ramponi
University of Trieste
http://www.units.it/ramponi
Measuring the derivatives of a signal:
Chapter 3 Image Enhancement in the Spatial Domain:
Sharpening operators
Chapter 3 Image Enhancement in the Spatial Domain:
Sharpening operators
Gianni Ramponi University of Trieste http://www.units.it/ramponi
Beware: all such definitions can be found in the literature
Chapter 3 Image Enhancement in the Spatial Domain:
Sharpening operators
Chapter 3 Image Enhancement in the Spatial Domain:
Sharpening operators