You are on page 1of 31

ASAM - Image Processing

2008/2009

Lecture 5

Histograms

Ioannis Ivrissimtzis 13-Nov-2008


Overview

Histograms

Histogram equalisation

Histogram specification
Histograms
In the previous lectures we introduced intensity transformation
functions and linear filters as basic tools for image processing.

For the selection of the appropriate processing tool we might need


information extracted from the image.

Histograms are functions describing information extracted form the


image.

In a process called histogram equalisation, this information is used to


compute a contrast increasing intensity transformation function.
Histograms
The histogram function is defined over all possible intensity levels.

For each intensity level, its value is equal to the number of the pixels
with that intensity.
Example

Consider a 5x5 image with integer intensities in the range between one
and eight:

1 8 4 3 4
1 1 1 7 8
8 8 3 3 1
2 2 1 5 2
1 1 8 5 2
Example

1 8 4 3 4
1 1 1 7 8
8 8 3 3 1
2 2 1 5 2
1 1 8 5 2

1 2 3 4 5 6 7 8
Histogram function

n1 n2 n3 n4 n5 n6 n7 n8

h(rk )  nk

1 2 3 4 5 6 7 8
Histogram function

h(r1 )  8
n1 n2 n3 n4 n5 n6 n7 n8
h(r2 )  4
h(r3 )  3
h(r4 )  3
h(r5 )  2
h(r6 )  0
h(r7 )  1
1 2 3 4 5 6 7 8
h(r8 )  5
Example

Graph of the
histogram function
Original image
Example

Graph of the
histogram function
Original image
Example

Graph of the
histogram function
Original image
Example

Graph of the
histogram function
Original image
Normalised histogram function
The normalised histogram function is the histogram function divided by
the total number of the pixels of the image:

h(rk ) nk
p (rk )  
n n

It gives a measure of how likely is for a pixel to have a certain intensity.


That is, it gives the probability of occurrence the intensity.

The sum of the normalised histogram function over the range of all
intensities is 1.
Normalised histogram function

h( r1 )  8 p (r1 )  8 / 25  0.32
h( r2 )  4 p (r2 )  4 / 25  0.16
h( r3 )  3 p (r3 )  3 / 25  0.12
h( r4 )  2 p (r4 )  3 / 25  0.08
h( r5 )  2 p (r5 )  2 / 25  0.08
h( r6 )  0 p (r6 )  0 / 25  0.00
h( r7 )  1 p (r7 )  1 / 25  0.04
h( r8 )  5 p (r8 )  5 / 25  0.20
Overview

Histograms

Histogram equalisation

Histogram specification
Histogram Equalization

Some applications may benefit from a uniform distribution of the pixel


intensities over the whole range of the interval [0,1].

We can use the normalised histogram function to compute an intensity


transformation function giving a more uniform distribution of the
intensities.

This process is called histogram equalisation.


Histogram Equalization
Histogram equalisation algorithm: Let rk , k  1,2,..., m be the
intensities of the image, and let p(rk ) be its normalised histogram
function.

The intensity transformation function for histogram equalisation is


k
T (rk )   p(r )
j 1
k

That is, we add the values of the normalised histogram function from 1
to k to find where the intensity rk will be mapped.

Notice that the range of the equalised image is the interval [0,1].
Example

Do histogram equalization on the 5x5 image with integer intensities in


the range between one and eight:

1 8 4 3 4
1 1 1 7 8
8 8 3 3 1
2 2 1 5 2
1 1 8 5 2
Example
Normalised Intensity transformation
histogram function function

p (r1 )  0.32 T (r1 )  0.32


p (r2 )  0.16 T (r2 )  0.32  0.16  0.48
p (r3 )  0.12 T (r3 )  0.32  0.16  0.12  0.60
p (r4 )  0.08 T (r4 )  0.32  0.16  0.12  0.08  0.68
p (r5 )  0.08 T (r5 ) 
p (r6 )  0.00 T (r6 ) 
p (r7 )  0.04 T (r7 ) 
p (r8 )  0.20 T (r8 ) 
Example
Normalised Intensity transformation
histogram function function

p (r1 )  0.32 T (r1 )  0.32


p (r2 )  0.16 T (r2 )  0.48
p (r3 )  0.12 T (r3 )  0.60
p (r4 )  0.08 T (r4 )  0.68
p (r5 )  0.08 T (r5 )  0.76
p (r6 )  0.00 T (r6 )  0.76
p (r7 )  0.04 T (r7 )  0.80
p (r8 )  0.20 T (r8 )  1.00
Example
The 32% of the pixels have
p (r1 )  0.32 T (r1 )  0.32 intensity r1. We expect them
to cover 32% of the
p (r2 )  0.16 T (r2 )  0.48 possible intensities.
p (r3 )  0.12 T (r3 )  0.60
The 48% of the pixels have
p (r4 )  0.08 T (r4 )  0.68 intensity r2 or less. We
p (r5 )  0.08 T (r5 )  0.76 expect them to cover 48%
of the possible intensities.
p (r6 )  0.00 T (r6 )  0.76
p (r7 )  0.04 T (r7 )  0.80 The 60% of the pixels have
p (r8 )  0.20 T (r8 )  1.00 intensity r3 or less. We
expect them to cover 60%
of the possible intensities.

……………………………
Example
Example
Overview

Histograms

Histogram equalisation

Histogram specification
Notation
Slides marked with this sign are particularly challenging.

They do not contain examinable. Their purpose is to present the main


concepts within their wider context.
Histogram specification

The histogram function h can be seen as a continuous function.


Frequency of
occurrence

0 Intensities 1
Histogram specification
The number of occurrences in a certain region corresponds to the area
below the graph of the function and inside that region.

In the normalized histogram function p, the area below the whole curve
is equal to 1.
Frequency of
occurrence

0 Intensities 1
Histogram specification
In the discrete case we used the sum of the values of the normalized
histogram function between 1 and k.
In the continuous case we use the area below the function between 0
and r r
T (r )   p( w)dw
0
Frequency of
occurrence

T (r )
0 r 1 Intensities
Histogram specification
Histogram equalization tries to make the intensity distribution uniform.

Because of the irregular initial distribution, usually this is not possible.


Moreover, sometimes histogram equalization introduces artifacts, (see
the example with the photograph of the moon).
Frequency of

Ideal equalized
occurrence

histogram function

0 Intensities 1
Histogram specification
Instead, we can specify the function we want for the histogram.

s: specified histogram
Frequency of
occurrence

p: initial histogram

0 1 Intensities
Histogram specification
The intensity transformation function is now given by
g (r ) r
T (r )  
0
p ( w)dw, g(r)   s(w)dw
0

s: specified histogram
Frequency of
occurrence

p: initial histogram

g(r)
0 r 1
Intensities

You might also like