03-2 - histogram processing
Post on 29-Mar-2015
19 Views
Preview:
TRANSCRIPT
4/28/2008
1
Histogram processingg p g
Spring 2008 ELEN 4304/5365 DIP 1
by Gleb V. Tcheslavski: gleb@ee.lamar.edu
Preliminaries
The histogram of a digital image with intensity levels in the range [0, L‐1] is a discrete function
( )k kh r n=
kth intensity value
Number of pixels in the image with intensity rk
Histograms are frequently normalized by the total number of pixels in the image. Assuming a M x N image, a normalized histogram
Spring 2008 ELEN 4304/5365 DIP 2
( ) , 0,1,... 1kk
np r k LMN
= = −
is related to probability of occurrence of rk in the image
4/28/2008
2
Preliminaries
Components are concentrated on the low (dark) side
Components are concentrated on the high (light) side
Narrow histogram typically concentrated around the middle
Components cover a wide range of intensities – high contrast
Spring 2008 ELEN 4304/5365 DIP 3
Histogram equalizationAssuming that r represents the intensity of an input image in the range [0, L-1] (black to white), we consider the intensity mapping
( ) 1T L 0 ≤ ≤( ) 1s T r r L= 0 ≤ ≤ −such that a) T(r) is monotonically increasing in [0, L-1] – to prevent reversal intensity artifacts;
b) T(r) being in [0, L-1] for r in [0, L-1] – to ensure the range of output intensity being the same as for input intensity.
F l
Spring 2008 ELEN 4304/5365 DIP 4
For example:
4/28/2008
3
Histogram equalizationThe image intensity levels can be viewed as random variables in [0, L-1]. Let pr(r) and ps(s) represent pdfs of rand s We need a transformation that would produce theand s. We need a transformation that would produce the output image with uniform ps(s) for an input image with an arbitrary pr(r).Note, histograms are approximations of pdfs!The desired transformation is
( ) ( 1) ( )r
s T r L p w dw= = − ∫
Spring 2008 ELEN 4304/5365 DIP 5
0
( ) ( 1) ( )rs T r L p w dw∫It can be shown that this transformation leads to the rv suniformly distributed in [0,L-1].
Histogram equalization
For instance: ( )22 0 1
1( )r
r r LLp r
⎧ ≤ ≤ −⎪ −= ⎨⎪ 0 otherwise⎪⎩
Therefore:2
0 0
2( ) ( 1) ( )1 1
r r
rrs T r L p w dw w dw
L L= = − = =
− −∫ ∫For discrete values, we work with normalized histogram
l d ti i t d f i t ti
Spring 2008 ELEN 4304/5365 DIP 6
values and summation instead of integration.
( ) , 0,1,... 1kr k
np r k LMN
≈ = −
4/28/2008
4
Histogram equalization
The discrete form of the equalizing transformation is
0 0
1( ) ( 1) ( ) 0,1,... 1k k
k k r j jj j
Ls T r L p r n k LMN= =
−= = − = = −∑ ∑
This mapping is called a histogram equalization or histogram linearization.
It’ t t i
Spring 2008 ELEN 4304/5365 DIP 7
It’s not necessary one-to-one mapping.
Histogram equalization: Ex
A simple 3-bit (L=8) 64 by 64 image has the intensity distributionIntensity levels are integers in [0, 7].y g [ ]
histogram transformation Equalized histogram
Spring 2008 ELEN 4304/5365 DIP 8
Values of the histogram equalization transform function are0
0 0 00
( ) 7 ( ) 7 ( ) 1.33r j rj
s T r p r p r=
= = = =∑
4/28/2008
5
Histogram equalization: ExSimilarly:
1
1 1 0 1( ) 7 ( ) 7 ( ) 7 ( ) 3.08r j r rs T r p r p r p r= = = + =∑0j=
and s2 = 4.55, s3 = 5.67, s4 = 6.23, s5 = 6.65, s6 = 6.86, s7 = 7.00. we notice that the transformation function has fractional values that need to be rounded to obtain a quantized histogram:
0 1 2 3
4 5 6 7
1.33 1; 3.08 3; 4.55 5; 5.67 6;6.23 6; 6.65 7; 6.86 7; 7.00 7.
s s s ss s s s
= → = → = → = →= → = → = → = →
Spring 2008 ELEN 4304/5365 DIP 9
4 5 6 76.23 6; 6.65 7; 6.86 7; 7.00 7.s s s s→ → → →Dividing these values by MN, we obtain a new histogram, No new intensity levels are allowed. Therefore, perfectly uniform results cannot be achieved for digital images.
Histogram equalization
Previously seen images
Histogram-equalized images
Spring 2008 ELEN 4304/5365 DIP 10
images
And their histograms
4/28/2008
6
Histogram matching (specification)
Histogram equalization automatically determines a transformation function seeking to produce an output image with a uniform histogram.Another method is to generate an image having a specified histogram – histogram matching:1. Find the histogram pr(r) of the input image and determine its equalization transformation: r
Spring 2008 ELEN 4304/5365 DIP 11
0
( ) ( 1) ( )r
rs T r L p w dw= = − ∫2. Use the specified pdf pz(r) of the output image to obtain the transformation function:
Histogram matching (specification)
( ) ( 1) ( )z
zG z L p t dt s= − =∫0∫
3. Find the inverse transformation z = G-1(s) – the mapping from s to z:
[ ]1 1( ) ( )z G T r G s− −= =
4. Obtain the output image by equalizing the input image first; th f h i l i th li d i f th i
Spring 2008 ELEN 4304/5365 DIP 12
then for each pixel in the equalized image, perform the inverse mapping to obtain the corresponding pixel of the output image.
4/28/2008
7
Histogram matching (specification)
Spring 2008 ELEN 4304/5365 DIP 13
Original image of Phobos and its histogram
A histogram-equalized image and its histogram
Histogram matching
A large concentration of pixel values near zero in the originalvalues near zero in the original image leads to unsatisfactory results of histogram equalization (“washed out appearance”). Histogram matching may lead to much better results…
Spring 2008 ELEN 4304/5365 DIP 14
However, this technique is a “trial-and-error” process. There are no step-by-step recipes…
4/28/2008
8
Local histogram processingSometimes, it is desired to apply histogram processing to a portion (portions) of am image…
Spring 2008 ELEN 4304/5365 DIP 15
Original image Global histogram equalization
Local histogram equalization using neighborhood of 3 x 3
Histogram statistics in image enhancement
Let the intensity in an image is represented by a discrete rv rin [0, L-1] and let p(ri) is the normalized histogram – estimate of pdf for the intensity.The nth statistical moment is
( )1
0
( ) ( )L
nn i i
i
r r m p rμ−
=
= −∑Mean value
For image intensities, a sample mean:
Spring 2008 ELEN 4304/5365 DIP 16
1 1
0 0
1 ( , )M N
x y
m f x yMN
− −
= =
= ∑∑
[ ]1 1
22
0 0
1 ( , )M N
x yf x y m
MNσ
− −
= =
= −∑∑and sample variance:
4/28/2008
9
Histogram statistics in image enhancement
As previously, we may specify global mean and variance (for the entire image) and local mean and variance for a specifiedthe entire image) and local mean and variance for a specified sub-image (subset of pixels).
Spring 2008 ELEN 4304/5365 DIP 17
Original imageResult of global histogram equalization
Result of local histogram equalization
Conclusion
Out of the methods discussed above, only theOut of the methods discussed above, only the global histogram equalization can be done completely automatically. The rest is … an art.
Spring 2008 ELEN 4304/5365 DIP 18
top related