Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram...

22

Transcript of Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram...

Page 1: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing

Dr. Praveen Sankaran

Department of ECE

NIT Calicut

December 31, 2012

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 1 / 20

Page 2: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Outline

1 Review

2 Histogram ProcessingHistogram EqualizationHistogram Matching (Speci�cation)

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 2 / 20

Page 3: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Review

Contrast

De�ned as the di�erence in intensity between the highest and thelowest intensity levels in an image.

Also can be explained as - the di�erence in luminance and/or colorthat makes an object (or its representation in an image or display)distinguishable.1

1http://en.wikipedia.org/wiki/Contrast_%28vision%29Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 3 / 20

Page 4: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Review

Some Calculations - Contrast

Let g be an M×N digital image with l = 0,1, ...,L−1 possible graylevels.

Dispersion → Image pixel value variance.

‖g −g‖2 = 1

MN∑M−1m=0 ∑

N−1n=0

(g [m,n]−g)2

g = 1

MN∑M−1m=0 ∑

N−1n=0

g [m,n]

Units are squared here.

Contrast = ‖g −g‖=√‖g −g‖2 → standard deviation.

Note that it would take an order O (MN) algorithm to �nd this.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 4 / 20

Page 5: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Review

Histogram

Let g be an M×N digital image with l = 0,1, ...,L−1 possible graylevels.

c [l ] =the number of pixels with gray level l .

De�ne relative frequency

p [l ] = c[l ]MN

, ∑L−1l=0

p [l ] = 1

→ digital image gray level distribution.

The probability that a randomly selected pixel has value l .

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 5 / 20

Page 6: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Review

Contrast Stretching

Idea → expand the range of intensity levels in an image so that it spans thefull intensity range of the recording medium or display device.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 6 / 20

Page 7: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Outline

1 Review

2 Histogram ProcessingHistogram EqualizationHistogram Matching (Speci�cation)

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 7 / 20

Page 8: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Variables so far

1 g = M×N digital image with l = 0,1, ...,L−1 possible gray levels.

2 r = intensities of image g to be processed, [0 · · ·L−1].

3 s = output intensity level of g after transformation, T (r).

4 c [l ] =the number of pixels with gray level l .

5 p [l ] = c[l ]MN

, gives gray level distribution of image g .

6 And more importantly, ∑L−1l=0

p [l ] = 1.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 8 / 20

Page 9: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Monotonic and Strictly Monotonic Functions

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 9 / 20

Page 10: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Cumulative Distribution Function

p [l ] = The probability that a randomly selected pixel has value l .

pr (r) =probability density function of r .

ps (s) =probability density function of s.

Figure: Slope of the r -s curve gives the transform function, ps (s) = pr (r)∣∣ drds

∣∣CDF of r → s = (L−1)

∫ r0 pr (w)dw = area under the probability

density function curve of r .→ What type of curve is this going to be?

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 10 / 20

Page 11: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

What about ps (s)?

ds

dr=

dT (r)

dr= (L−1)

d

dr

[∫ r

0pr (w)dw

]=(L−1)pr (r)

ps (s) = pr (r)∣∣drds

∣∣ps (s) = pr (r)

∣∣∣ 1(L−1)pr (r)

∣∣∣= 1L−1 → Uniform distribution.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 11 / 20

Page 12: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Discrete Equivalent

From earlier we have a general form, p [l ] = c[l ]MN

.

So modifying for current speci�cs, pr [lr ] =cr [lr ]MN

.

ls = T (lr ) = (L−1)∑lj=0 pr [jr ], l = 0,1, · · ·L−1.

Histogram equalization or histogram linearization.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 12 / 20

Page 13: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Process Example

Objective → intensity values that cover the entire gray scale.Note → see the error creeping in?

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 13 / 20

Page 14: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Equalization

Real Image Output Example

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 14 / 20

Page 15: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Outline

1 Review

2 Histogram ProcessingHistogram EqualizationHistogram Matching (Speci�cation)

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 15 / 20

Page 16: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Some More Continuous Function Theory!

s = T (r) = (L−1)∫ r0 pr (w)dw → Histogram equalization.

Let z be another random variable like r ,s, such that,

G (z) = (L−1)∫z

0pz (t)dt = s

G (z) = T (r)!→ z = G−1 (T (r)) = G−1 (s)

What does all this mean anyway?

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 16 / 20

Page 17: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Some More Continuous Function Theory!

s = T (r) = (L−1)∫ r0 pr (w)dw → Histogram equalization.

Let z be another random variable like r ,s, such that,

G (z) = (L−1)∫z

0pz (t)dt = s

G (z) = T (r)!→ z = G−1 (T (r)) = G−1 (s)

What does all this mean anyway?

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 16 / 20

Page 18: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Some More Continuous Function Theory!

s = T (r) = (L−1)∫ r0 pr (w)dw → Histogram equalization.

Let z be another random variable like r ,s, such that,

G (z) = (L−1)∫z

0pz (t)dt = s

G (z) = T (r)!→ z = G−1 (T (r)) = G−1 (s)

What does all this mean anyway?

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 16 / 20

Page 19: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Explanation

To start with we have the image values we have to modify → r .

Idea → modify the image based on the histogram of some other image(with values z)!

Why? →because we like this second image for some reason!

1 Find CDF of Image 1, to perform histogram equalization (r → s).

2 Find CDF of Image 2.

3 Now assuming that values s is on the y-axis of image 2 CDF, �nd thecorresponding nearest z value.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 17 / 20

Page 20: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Illustration

2

2http://en.wikipedia.org/wiki/File:Histogram_matching.PNGDr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 18 / 20

Page 21: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Summary

Histograms.

Monotonic/Strictly Monotonic.

Cumulative distribution/density function of an image.

Equalization.

Speci�cation/Matching.

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 19 / 20

Page 22: Histogram Processing - National Institute of Technology ... · Histogram Processing Histogram Matching (Speci cation) Explanation oT start with we have the image values we have to

Histogram Processing Histogram Matching (Speci�cation)

Questions

3.1, 3.2, 3.3, 3.4, 3.5

3.6, 3.7, 3.11

Dr. Praveen Sankaran (Department of ECE NIT Calicut )DIP Winter 2013 December 31, 2012 20 / 20