0% found this document useful (0 votes)
75 views

Histogram Processing1

The document discusses image enhancement techniques based on histogram equalization. It defines what a histogram is and how it relates to image contrast. Histogram equalization aims to generate a uniform histogram by transforming the input image intensities. The transformation function for histogram equalization is defined to satisfy monotonic increase and output range conditions.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

Histogram Processing1

The document discusses image enhancement techniques based on histogram equalization. It defines what a histogram is and how it relates to image contrast. Histogram equalization aims to generate a uniform histogram by transforming the input image intensities. The transformation function for histogram equalization is defined to satisfy monotonic increase and output range conditions.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

Image Enhancement Based on

Histogram

1 April 26, 2024


Overview

Image enhancement using point processing


techniques
Negative Transformation
Log transformation
Power law Transformation
Contrast Stretching
Gray level Slicing
Bit Plane slicing.

2 April 26, 2024


This topic covers

What is histogram?
Histogram equalization
Histogram
Specification/Matching/Modification

3 April 26, 2024


Definition
 Histogram of an image represents the relative frequency of
occurrence of the various gray levels in an image in range [0, L-1].

Example:
Gray Number of The histogram is a discrete function
level pixels h(rk) h(rk) = nk
0 40
40 – Where rk is the kth gray level
1 20
– nk is no. of pixels in image
2 10 having gray level rk
20
3 15
15
10 10
4 10 3 2

5 3 0 1 2 3 4 5 6
Gray levels
4 6 2 April 26, 2024
OR Normalized Histogram

Histogram of an image represents Probability occurrences of the


various gray levels in an Image.
Example: • The normalised histogram is given by p(rk) =
Gray Number of Probability nk/n for k=0,1,2,….,L-1
level pixels (nk) (nk/n)
p(rk)
0 40 0.4
0.4
1 20 0.2
2 10 0.1
3 15 0.15 0.2

4 10 0.1 0.15
0.1 0.1
5 3 0.03 0.03 0.02

6 2 0.02 0 1 2 3 4 5 6
Gray levels
5
Total April 26, 2024
n=100
Example

6 April 26, 2024


Components of histogram are concentrated on
the (low) dark side of gray scale

Components of histogram are concentrated on


the high (Light) side of gray scale

Low contrast image has narrow histogram and


centered in the middle of gray scale

The high contrast image has the most evenly spaced


histogram.
7 April 26, 2024
Uniform Histogram
We can conclude…
An image whose pixels tend to occupy the entire range
of possible gray levels and tend to be distributed
uniformly, will have an appearance of high contrast
and will display a large variety of gray tones.

Histogram Transformation Uniform/flat


of input Function histogram
image

Histogram Equalisation
8 April 26, 2024
Histogram Equalisation
We need to define transformation that transforms
bad histogram in flat (uniform) histogram.
We know s=T(r) where 0≤ r ≤L-1

But what should be T????

9 April 26, 2024


Histogram Equalisation
The transformation T must satisfy 2 conditions
s  T (r ) 0  r  L  1
a. T(r) is a monotonically increasing function in the interval 0  r  L -1;
(i.eT (r2 )  T (r1 ) for r2  r1 )
b. 0  T (r )  L -1 for 0  r  L -1.

10 April 26, 2024


Histogram Equalisation
The transformation T must satisfy 2 conditions
s  T (r ) 0  r  L  1
a. T(r) is a monotonically increasing function in the interval 0  r  L -1;
(i.eT (r2 )  T (r1 ) for r2  r1 )
b. 0  T (r )  L -1 for 0  r  L -1.

Condition a) guarantees that output intensity values will


never be less than corresponding input intensities values.

b) Guarantees that range of output intensities is same as the


input.
11 April 26, 2024
Histogram Equalization

k nj
L 1 k
 ( L  1)   nj k=0,1,..., L-1
j  0 MN MN j 0

April 26, 2024 12


Histogram Equalisation (cont..)
k
sk  T (rk )  ( L  1)  pr (r j )
j 0

Let k=0 to 7
s0=(L-1)pr(r0) This mapping is called
s1=(L-1)[pr (r0)+pr (r1)] Histogram Equalisation
s2=(L-1 )[pr (r0)+pr (r1)+pr (r2)]
.
.
s7=(L-1)[pr (r0)+pr (r1)+pr (r2)+…..+pr (r7)]

The output image (s) is obtained by mapping each


pixel with level rk in input image into
corresponding
13
pixel with level sk in output image
April 26, 2024
Example
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

Histogram of original image


h(rk) 1023

850

790 656

329
245 122
81

0 1 2 3 4 5 6 7
Gray levels

14 April 26, 2024


k
sk  T (rk )  ( L  1) pr (rj )
Example j 0
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

Grey Nk
Level
0 790
1 1023
2 850
3 656
4 329
5 245
6 122
7 81
Total=4096
15 April 26, 2024
k
sk  T (rk )  ( L  1) pr (rj )
Example j 0
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

Grey Nk Pr(rk)=nk/n
Level
0 790 0.19
1 1023 0.25
2 850 0.21
3 656 0.16
4 329 0.08
5 245 0.06
6 122 0.03
7 81 0.02
Total=4096
16 April 26, 2024
k
sk  T (rk )  ( L  1) pr (rj )
Example j 0
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

k
Grey Nk Pr(rk)=nk/n
Level  p (r )
j 0
r j

0 790 0.19 0.19


1 1023 0.25 0.44
2 850 0.21 0.65
3 656 0.16 0.81
4 329 0.08 0.89
5 245 0.06 0.95
6 122 0.03 0.98
7 81 0.02 1
Total=4096
17 April 26, 2024
k
sk  T (rk )  ( L  1) pr (rj )
Example j 0
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

k k
Grey Nk Pr(rk)=nk/n
Level  p (r )
j 0
r j ( L  1) pr (rj )
j 0

0 790 0.19 0.19 1.33


1 1023 0.25 0.44 3.08
2 850 0.21 0.65 4.55
3 656 0.16 0.81 5.67
4 329 0.08 0.89 6.23
5 245 0.06 0.95 6.65
6 122 0.03 0.98 6.86
7 81 0.02 1 7
Total=4096
18 April 26, 2024
k
sk  T (rk )  ( L  1) pr (rj )
Example j 0
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

Grey Nk Pr(rk)=nk/n s  k p (r ) ( L  1) k p (r ) new gray


Level k j 0
r j 
j 0
r j
level
0 790 0.19 0.19 1.33 1
1 1023 0.25 0.44 3.08 3
2 850 0.21 0.65 4.55 5
3 656 0.16 0.81 5.67 6
4 329 0.08 0.89 6.23 6
5 245 0.06 0.95 6.65 7
6 122 0.03 0.98 6.86 7
7 81 0.02 1 7 7
Total=4096
19 April 26, 2024
Old Gray Nk new gray New Gray Level Nk
Level level
1 790
0 790 1
3 1023
1 1023 3
5 850
2 850 5
6 656+329=985
3 656 6
7 245+122+81=448
4 329 6
5 245 7
6 122 7
7 81 7
Total=4096

20 April 26, 2024


New Gray Level Nk
0 0
1 790
2 0
3 1023
4 0
5 850
6 656+329=985
7 245+122+81=448

21 April 26, 2024


h(rk) 1023
850
790
Histogram of original Image
656

329

245
122
81

0 1 2 3 4 5 6 7
Gray levels

h(rk) 1023 985


850
790
Histogram of equalized Image

448

22 April 26, 2024


0 1 2 3 4 5 6 7
Gray levels
Equalisation Transformation Function

23 April 26, 2024


24 April 26, 2024
Original Image Equalised Image

Histogram of Original Image Histogram of Equalised Image


2000 2000

1500 1500

1000 1000

500 500

0 0
0 50 100 150 200 250 300 350 0 50 100 150 200 250 300 350

25 April 26, 2024


26 April 26, 2024
Histogram equalization
Perform histogram equalization and draw a new
equalized histogram of the following image data

Gray Level 0 1 2 3 4 5 6 7
No. of 550 900 650 150 300 250 110 90
pixels

27 April 26, 2024


Example

0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1
1 1 1 2 2 2 3 4 Perform histogram equalization of
1 1 1 2 2 2 3 4 the given image.
1 1 1 2 2 2 3 4
1 1 1 2 2 2 3 5
2 2 2 2 2 5 5 5
6 6 6 6 7 7 5 5

28 April 26, 2024


Example
Old Gray Nk new gray
Level level
0 0 0 0 0 0 0 0
0 8 1
1 1 1 1 1 1 1 1
1 20 3
1 1 1 2 2 2 3 4
2 17 5
1 1 1 2 2 2 3 4
3 4 5
1 1 1 2 2 2 3 4
1 1 1 2 2 2 3 5 4 3 6
2 2 2 2 2 5 5 5 5 6 6
6 6 6 6 7 7 5 5 6 4 7
7 2 7
Total=64

29 April 26, 2024


New Gray Level Nk
0 0
1 8
2 0
3 20
4 0
5 17+4=21
6 3+6=9
7 4+2=6

30 April 26, 2024


Histogram equalisation Cont..

31 April 26, 2024


Example cont….

32 April 26, 2024


Histogram Equalisation (Cont….)
For Some applications histogram equalization
is not the best approach.
It is useful sometimes to be able to specify the
shape of histogram that we wish the
processed image to have.
The method to generate a processed image
that has specified histogram is called
Histogram matching or Histogram
specification
33 April 26, 2024
Histogram Specification
The transformation function T(rk) for the given histogram
Pr(rj) , j=0, 1 ,2, ….L-1 is given by
k
sk  T (rk )   pr (rj )
j 0
k nj
 ( L  1)
j 0 MN
The transformation function G(z q) for the specified
histogram Pz(zi) , i=0, 1 ,2, ….L-1 is given by
q q
ni
G ( z q )   p z ( zi )  ( L  1)  sk
34 i 0 i  0 MN April 26, 2024
Histogram Specification

So we are seeking the value of z that satisfy


the equation
sk  T (rk )
G ( zk )  sk  zk  G 1 ( sk )

If don’t able to find exact G-1 , find closest z

35 April 26, 2024


Steps for histogram specification
Obtain the histogram of original image.
Equalize the histogram of original image (Obtain T(r) i. e s)
Equalize the histogram of specified image. (Obtain G(z))
Perform the mapping process so that the values of step 2 can
be mapped to the result of step 3. (i.e. Obtain G-1 )

36 April 26, 2024


Example of histogram specification
Given histogram (a) and (b). Modify (a) as given by histogram (b)
Histogram (a)
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 790 1023 850 656 329 245 122 81

Histogram (b)
Gray Level 0 1 2 3 4 5 6 7
No. of pixels 0 0 0 614 819 1230 819 614

37 April 26, 2024


s=T(r) G(z)
Old Gray nk new gray Old Gray new gray
Level rk level sk Level zk level G(zk)
0 790 1
1 1023 3
0 0 G(zk)=sk
1 0
2 850 5 zk = G-1(s)
2 0
3 6
985 3 1
4 6
5 7 4 2

6 448 7 5 5

7 7 6 6
Total=4096 7 7

38 April 26, 2024


T(r) G(z) Final Result z= G-1(s)
Old Gray Nk new gray Gray Level new gray G-1(1)=3
Level level (Sk) zk level G(zk)
G-1(3)=4
0 790 1 G-1(5)=5
0 0 G-1(6)=6
1 1023 3
1 0 G-1(7)=7
2 850 5
2 0
3 6 Gray Nk
985 3 1 Level
4 6
4 2 0 0
5 7
5 5 1 0
6 448 7
6 6 2 0
7 7
7 7 3 790
Total=4096
4 1023
5 850
6 985
7 448
Total=4096
39 April 26, 2024
Specified Histogram

Gray Level 0 1 2 3 4 5 6 7
No. of pixels 0 0 0 614 819 1230 819 614

Output Histogram

Gray Level 0 1 2 3 4 5 6 7
No. of pixels 0 0 0 790 1023 850 985 448

40 April 26, 2024


Original Image

41 April 26, 2024


Histogram Equalisation

42 April 26, 2024


(a)Specified Histogram

Enhanced image after applying Histogram


Specification

43 Histogram of above image April 26, 2024

You might also like