25
Histogram Specification desired equalize equalize G G -1

Histogram Specification - Montana State University

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Histogram Specification - Montana State University

Histogram Specification

desired

equalizeequalize G G­1

Page 2: Histogram Specification - Montana State University

Histogram Specification (cont.)

● Equalize the levels of the original image.● Specify the desired density function 

(histogram) and obtain the transformation function G(z).

● Apply the inverse transformation function  z = G  (s) to the levels obtained in first step.

-1

Page 3: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● Saw what we want the histogram to look like and come up with a transform function that will give it to us.

● Continuous random variables r & z.  Pr(r) and   Pz(z) denote their probability density functions.  (Continuous equivalent of a histogram).

● Pr(r) input image● Pz(z) desired output image (processed)  This is 

what we'd like the processed image to have.

Page 4: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● Continuous version of histogram equalization.● Cumulative Distribution Function

s=T r = ∫0

r

Pr w dw

Page 5: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● Continuous version of histogram equalization.● Cumulative distribution function.

s=T r =∫0

r

Pr w dw

G z =∫0

z

P zt dt=s

G z =T r

z=G−1s =G−1T r

Page 6: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● If you have Pr(r) estimated from input image, you can obtain T(r) from

Transformation G(z) can be obtained by using  since you

specified Pz(z)!

∫0

r

Pr w dw

∫0

z

P zt dt

Page 7: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● Assume G  exists and that is satisfys:● Single­Valued, monotonically increasing● 0 <= G (z) <= 1  for 0 <= z <= 1

-1

-1

Page 8: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● You can obtain an image with the specified probability density function from an input function using the following:– obtain T(r) using equilization– obtain G(z) by equalizing specified histogram– obtain G  (z)– obtain the output image by applying G  to all pixels 

in input image.-1

-1

Page 9: Histogram Specification - Montana State University

Histogram Specification (cont.)­from text­

● So far so good (continuously speaking)● In practice it is difficult to obtain analytical 

expressions for T(r) and G● With discrete values it becomes possible to 

make a close approximation to the histogram.

-1

Page 10: Histogram Specification - Montana State University

discrete Formulas

L is the number of discrete gray levelsn = total # pixelsn = # of pixels with gray level jj

sk=T r k =∑j=0

k

Pr r j=∑j=0

k n j

nk=0,1,2,. .. , L−1

vk=G zk =∑i=0

k

pz zi=sk k=0,1,2,. .. , L−1

zk=G−1[T r k ] k=0,1,2,. .. , L−1

zk=G−1sk k=0,1,2,. .. , L−1

Page 11: Histogram Specification - Montana State University

Implementation

● Each set of gray levels is a 1D array● All mappings from r to s and s to z are simple 

table lookups● Each element (e.g. s  ) contains 2 important 

pieces of information:– subscript k denotes the location of the element in 

the array– s denotes the value at that location

● We need to only look at integer values

k

Page 12: Histogram Specification - Montana State University

Refer to Figure 3.19 GW

● (a) a hypothetical transform function given an image that was equalized.

● (b) Equalize specified histogram.  G   is just running the transform backwards.

● But wait a minute!  Where did we get the z's???● We have to use an iterative scheme.

-1

Page 13: Histogram Specification - Montana State University

Iterative Scheme

● Obtain histogram of the given image.● Equalize the image to precompute a mapped 

level s   for each r   .   T● Obtain G from the specified histogram by 

equalization.● Precompute z   for each s   using iterative 

scheme (3.3­17)● Map r   ­>  s   and back to z   .● Moon example 3.4, page 100, 101, 102 GW

kk

k

k

k

k

k

Page 14: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

0.1

0 1 2 3 4 5 6 7

0.20.3

0 – 0.01 – 0.02 – 0.03 – 0.154 – 0.205 – 0.306 – 0.207 – 0.15

1.00.80.6

0.20.4

0.0

desired

1.00.80.6

0.20.4

0.0

0 – 0.191 – 0.252 – 0.213 – 0.164 – 0.085 – 0.066 – 0.037 – 0.02

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Page 15: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s0 1

Page 16: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

Page 17: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 5

Page 18: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 6

Page 19: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 64 6

Page 20: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 64 65 7

Page 21: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 64 65 76 7

Page 22: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 64 65 76 77 7

0 1 2 3 4 5 6 7

Page 23: Histogram Specification - Montana State University

0.30.20.1

0 1 2 3 4 5 6 7

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 701234567

0.30.20.1

equalized histogram

r s

11

0.30.20.1

03

2 53 64 65 76 77 7

0 1 2 3 4 5 6 7

1 = 0.193 = 0.255 = 0.216 = .16+.08=.247 = .06+.03+.02   = 0.11

Page 24: Histogram Specification - Montana State University

0.1

0 1 2 3 4 5 6 7

0.20.3

desired

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 7

0.30.20.1r s

10

234567

0 1 2 3 4 5 6 7

01234567

00012467

equalized histogram

Page 25: Histogram Specification - Montana State University

0.1

0 1 2 3 4 5 6 7

0.20.3

desired

1.00.80.6

0.20.4

0.0

0 1 2 3 4 5 6 7

0.30.20.1

0 1 2 3 4 5 6 7

01234567

resultant histogram

1103

2 53 64 65 76 77 7

34566777

0.30.20.1

0 1 2 3 4 5 6 7

equalized orig