Sie sind auf Seite 1von 33

Digital Image Processing

Histogram Processing

Image is NOT Perfect Sometimes

http://www.eri.harvard.edu/faculty/peli/proje
cts/enhancement.html
3

Histogram - Image Enhancement

Introduction
Spatial domain (histogram based)
techniques
Histogram stretching
Histogram equalization
Histogram (specification) matching
Local and adaptive contrast
enhancement

What is a Histogram?

In Statistics, Histogram is a graphical


representation showing a visual impression of
the distribution of data.
An Image Histogram is a type of histogram
that acts as a graphical representation of the
lightness/color distribution in a digital image.
It plots the number of pixels for each value.

What is a Histogram?

In Statistics, Histogram is a graphical


representation showing a visual impression of
the distribution of data.
An Image Histogram is a type of histogram
that acts as a graphical representation of the
lightness/color distribution in a digital image.
It plots the number of pixels for each value.

Example of Histogram

Why Histogram?

Histograms are the basis for numerous


spatial domain processing techniques
Histogram manipulation can be used
effectively for image enhancement
Histograms can be used to provide useful
image statistics
Information derived from histograms are quite
useful in other image processing applications,
such as image compression and
segmentation.

Histogram Processing

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.

Histogram Processing

It is common practice to normalize a


histogram by dividing each of its values by
the total number of pixels in the image,
denoted by n. Thus, a normalized histogram
is given by p(rk) = nk / n, for k = 0, 1, , L -1.
Thus, p(rk) gives an estimate of the
probability of occurrence of gray level rk. Note
that the sum of all components of a
normalized histogram is equal to 1.

Histogram based Enhancement


Histogram of an image represents the relative frequency
of occurrence of various gray levels in the image
3000

2500

2000

1500

1000

500

50

100

150

200

16

Why Histogram stretching ?


4

x 10
4
3.5
3
2.5
2
1.5
1
0.5
0
0

50

100

150

200

250

It is a baby in the cradle!

Histogram information reveals that image is under-exposed

17

Another Example
7000
6000
5000
4000
3000
2000
1000
0
0

50

100

150

200

250

Over-exposed image

18

No stretch
0
0

64
64

128
128

input values
172
255
display level
172
255

Linear Stretch
0
64

128

172 input values


255

128

display level
172
255

64

EE465: Introduction to Digital Image


Processing

Linear
Stretch
Minimum
Old DN

ie. 64 in this example

DN - MIN
DN = --------------- x 255
MAX - MIN
New DN

Linear Stretch
0
64

Maximum
ie. 172 in this example
128
EE465: Introduction to Digital Image
Processing

172 input values


255

How to Adjust the Image?

Histogram equalization

Basic idea: find a map f(x) such that the histogram


of the modified (equalized) image is flat (uniform).
Key motivation: cumulative probability function
(cdf) of a random variable approximates a uniform
distribution

22

Histogram Equalization
x

y L h(t )
t 0

Uniform
Quantization
L

y s h(t )
t 0

Note:

h(t ) 1
t 0

cumulative probability function

http://en.wikipedia.org/wiki/Inverse_transform_sampling
23

Implementation
1.Calculate histogram
2.Form the cumulative histogram
3.Normalize the values- divide by total value
4.Multiply with maximum grey value - round off
5.Map original value to result (step4) one to one correspondance

This Performs histogram


equalization

24

Image Example

before

after
25

Histogram Comparison
3000

3000

2500

2500

2000

2000

1500

1500

1000

1000

500

500

50

100

150

200

before equalization

50

100

150

200

250

300

after equalization

26

Histogram Specification/Matching
Given a target image B, how to modify a given image A such that
the histogram of the modified A can match that of target image B?

histogram1

histogram2

S-1*T
T

?
27

Implementation

Find mapping table of histogram equalization


Specify the desired histogram, equalize
desired histogram also
Perform mapping process above two
mapping tables

29

before

after

30

Adaptive contrast enhancement

Select neibourhood of image with spatial


window
Apply histogram equalization to that window
Move window centre pixel moved by one
pixel
Update histogram (histo equ)
Repeat above two steps for entire image

Adaptive Histogram Equalization

http://en.wikipedia.org/wiki/Adaptive_histogram_equalization
32

Thank you

Das könnte Ihnen auch gefallen