Vous êtes sur la page 1sur 27

HISTOGRAM PROCESSING

Histogram of an Image

The histogram of a digital image with gray levels in the range


[0, L-1] is a discrete function h(rk) = nk, where rk is the kth gray
level and nk is the number of pixels in the image having gray
level rk. Or 255

h(r ) Total Number of


k 0

pixel in the image.

We can also define a normalized histogram by dividing each of


its values by the total number of pixels in the image. Thus we
can directly approximate it as the probability density function
of an image.
A normalized histogram is defined as

p(rk) = nk/n k = 0,1,L-1


p(rk) = nk/N2 for an NxN image

Histogram - Example

Histogram - Example

Histogram of high
contrast image cover a
broad range of the gray
scale and the distribution
of pixels will be almost
uniform.

This gives an image an


appearance of high
contrast with a great deal
of gray level detail and
high dynamic range.

Thus the plot of


histogram of an image
provides a global
description of the
appearance of an image.

Histogram equalization

It is a transformation that stretches the contrast by


redistributing the gray-level values uniformly.
To find the transformation:

Let the variable r represents the normalized gray levels in


the image, where 0 < r < 1.
We apply the transformation function,
r

s T (r ) pr ( w) dw

0 r 1

If pr(r) and ps(s) are the pdfs of r and s,

Pr(r, r+dr) pr(r) dr and Ps(s, s+ds) ps(s) ds.

Histogram equalization Cont..

Histogram equalization
Discrete Case

For the discrete case the probability of occurrence


of gray level rk in the image can be approximated
by

Pr(rk) = nk/n.

k = 0,1,2,L-1.

The discrete version of the transformation


function is given by
k
k n
j
sk T (rk ) pr (rj )
k 0,1,......., L 1
j 0
j 0 n

Histogram equalization - Advantages

The method of histogram equalization is fully


automatic compared to other contrast stretching
techniques.
The process consists of simply calculating the
cumulative distribution of the gray levels in an
image and that can be directly extracted from the
image, without the need for further parameter
specification.
Simplicity of computation.

Transformation Functions

Histogram Matching / Specification

This is the method used to generate a processed


image which has a specified histogram.
Formulation:

Let pz(z) be the desired probability density function and


pr(r) the original probability density function.

Suppose histogram equalization is applied to both r and


z to get the transformations
r

s T (r ) pr ( w) dw

0 r 1

v G ( z ) p z ( w) dw
0

0 z 1

Histogram Matching / Specification

Ps(s) and pv(v) are both uniform densities and they


can be considered as identical.

So z can be obtained as G-1(s) = G-1(T(r)).

For the discrete case;


k

j 0

j 0

sk T (rk ) pr (rj )
k

nj
n

k 0,1,......., L 1

vk G ( zk ) p z ( zi ) sk k 0,1,......., L 1
i 0

So zk = G-1[T(rk)] = G-1(sk)

Histogram Matching - Implementation

1. Obtain the histogram of the given image


2.Compute

T (rk ) pr (r j ) k 0,1,......., L 1
j 0
k

3.Compute

G ( z k ) p z ( zi ) k 0,1,......., L 1
i 0

Compute zk = z for each value of k or sk where z is the


smallest integer in the interval [0,L-1] such that
(G(z) sk) 0 k = 0,1,2,L-1.
For each pixel in the original image, if the value of the pixel
is rk, map this value to its corresponding level s k, then map
level sk into the final level zk.

Histogram Matching & Equalization


Comparison

Histogram Matching & Equalization


Comparison

Histogram Matching & Equalization


Comparison

Example

Local Enhancement

To enhance details over small areas in the


image.

The number of pixels in these areas may


have negligible influence on the
computation of a global transformation.

Local histogram processing

Define a square or rectangular neighborhood and


move the centre of this area from pixel to pixel.

At each location the histogram of the points in the


neighborhood is computed and either histogram
equalization or specification transformation function
is obtained.

This function is used to map the gray level of the


pixel centered in the neighborhood

Example

Histogram Statistics for Image


Enhancement

Use the statistical parameters obtainable


from the histogram.

r - input gray levels [0,L-1]


p(rk) probability of occurrence of gray level rk.

The nth moment of r about its mean is


defined as
n
L 1
n (r ) rk m p (rk )
k 0

Histogram Statistics

m is the mean value of r


L 1

m rk p (rk )
k 0

The second moment is given by


L 1

2 (r ) (rk m) 2 p (rk )
k 0

Local Enhancement: Example

Local Enhancement: Example

Local Enhancement: Example

Vous aimerez peut-être aussi