Sunteți pe pagina 1din 24

Digital Image Processing

(EEE F435/ECE F435)

Lecture 7-9: Introduction to Image Histogram

EEE & ECE Department


BITS-Pilani, Hyderabad campus

September 30, 2019 Digital Image Processing 1


Learning Objectives

At the end of the lecture the students are expected to


answer the followings:

– What is image histogram

– Histogram equalization

– Histogram specification

September 30, 2019 Digital Image Processing 2


Image Histograms
• The histogram of an image shows us the
distribution of grey levels in the image
Frequencies

Grey Levels

September 30, 2019 Digital Signal Processing 3


Histogram Examples

September 30, 2019 Digital Image Processing 4


Histogram Examples (cont…)

September 30, 2019 Digital Image Processing 5


Histogram Examples (cont…)

September 30, 2019 Digital Image Processing 6


Histogram Examples (cont…)

September 30, 2019 Digital Image Processing 7


Exercise
• Draw the transformation function for the
following images:

Input Image Output Image

September 30, 2019 Digital Image Processing 8


Example
• Consider the following image and obtain its
histogram.
1 2 3 2
3 6 7 6
6 6 6 3
2 6 2 6
6 3 7 1

September 30, 2019 Digital Image Processing 9


Contrast Stretching
• The images that have poor contrast can be
processed to a high contrast image by applying
some contrast specification

• Now the problem is how to decide this


transformation function?

September 30, 2019 Digital Image Processing 10


Histogram stretching
• To expand the histogram to increase the
dynamic range

• Shape of the histogram is, however, not


changed

• Also called histogram scaling

September 30, 2019 Digital Image Processing 11


Histogram stretching
• The mapping is done as:

Smax - Smin
rmax - rmin

• The corresponding transformation is given as:


S max - Smin
T (rk ) = ( rk - rmin ) + S min
rmax - rmin

September 30, 2019 Digital Image Processing 12


Histogram equalization
• The transformation is of the form: s = T(r)

• Properties of T(r):

– Monotonically (strictly) increasing for r

– Within the maximum range of r

September 30, 2019 Digital Image Processing 13


Statistical modelling
• Intensity levels are modeled as random
variable within a range
• In order to find a suitable model, the
intensities are considered as continuous and
normalized
• The probability density functions are defined
for the input image as well as the processed
image for the continuous variable r and s

September 30, 2019 Digital Image Processing 14


CDF as T(r)
• The transformation function is defined as:
rk
sk = T (rk ) = ( L - 1) �pr ( w)dw
0

• The above function is always monotonically


increasing as well as within the range of r
• The above transformation results a uniform
pdf and also independent of the pdf for the
input image

September 30, 2019 Digital Image Processing 15


Histogram Equalisation

The formula for histogram sk = T (rk )


equalisation is given here as: k
– rk: input intensity = �p (r ) r j
– sk: processed intensity j =0

– k: the intensity range k nj


(e.g 0.0 – 1.0) = �n
– nj: the frequency of intensity j j =0
– n: the sum of all frequencies

September 30, 2019 Digital Image Processing 16


Example
4 4 4 4 4 6 6 6 6 6

3 4 5 4 3 2 6 7 6 2

3 5 5 5 3 2 7 7 7 2

3 4 5 4 3 2 6 7 6 2

4 4 4 4 4 6 6 6 6 6

Original Image Processed Image

September 30, 2019 Digital Image Processing 17


Example
• Assume that the pdf for an image is given as:

� 2r 2
� for 0 �r �L-1
pr (r ) = �( L - 1)
� 0,otherwise.

Considering r and s to be continuous variables,
show that the histogram equalized image has
a uniform pdf.
September 30, 2019 Digital Image Processing 18
Example
• A 3-bit image has the following intensity
distribution:

rk 0 1 2 3 4 5 6 7
nk 12 16 13 11 5 4 2 1

Plot the transformation function and also the


equalized histogram, comment.

September 30, 2019 Digital Image Processing 19


Histogram Equalization Limitations

• Single step processing

• Non-interactive

• Always provide uniform distribution

September 30, 2019 Digital Image Processing 20


Histogram Specification
• Let the input image has probability density
pr(r)

• The aim is to find a transformation z = G(z),


such that the probability density of the new
image obtained by this transformation is pz(z),
which is not necessarily uniform

September 30, 2019 Digital Image Processing 21


Procedure
1. Compute histogram for the input image and find
its histogram equalization transformation T and
find s k

2. Repeat ‘1’ for the target histogram for all values


of z and obtain G
3. For every value of s in T find z s.t. G(z ) is closest
k q q

to s k

4. If more than one value for z is found choose the


q

larger value
September 30, 2019 Digital Image Processing 22
Example
• Let for an image the followings pdf are
available:
r 0 1 2 3 4 5 6 7
p (r) 0.19 0.25 0.21 0.16 0.08 0.06 0.03 0.02

• Convert it into an image whose pdf is given as:


z 0 1 2 3 4 5 6 7
p (z) 0 0 0 0.15 0.20 0.30 0.20 0.15

September 30, 2019 Digital Image Processing 23


Example
• For the following image of size 8×8 with its pdf
given as:
r 0 1 2 3 4 5 6 7
n(r) 8 10 10 2 12 16 4 2

apply histogram specification technique to


convert it into another image whose pdf given
as:z 0 1 2 3 4 5 6 7
n(z) 0 0 0 0 20 20 16 8

September 30, 2019 Digital Image Processing 24

S-ar putea să vă placă și