Histogram Processing 8/1/2020 1 Histogram Processing Histogram h( rk ) nk rk is the k th intensity value nk is the number of pixels in the image with intensity rk nk Normalized histogram p(rk ) MN nk : the number of pixels in the image of size M N with intensity rk 8/1/2020 2 8/1/2020 3 Histogram Equalization The intensity levels in an image may be viewed as random variables in the interval [0, L-1]. Let pr (r ) and ps ( s ) denote the probability density function (PDF) of random variables r and s. 8/1/2020 4 Histogram Equalization s T (r ) 0 r L 1 a. T(r) is a strictly monotonically increasing function in the interval 0 r L -1; b. 0 T (r ) L -1 for 0 r L -1. 8/1/2020 5 Histogram Equalization s T (r ) 0 r L 1 a. T(r) is a strictly monotonically increasing function in the interval 0 r L -1; b. 0 T (r ) L -1 for 0 r L -1. T (r ) is continuous and differentiable. ps ( s)ds pr (r )dr 8/1/2020 6 Histogram Equalization r s T (r ) ( L 1) pr ( w) dw 0 ds dT (r ) d r ( L 1) p ( w ) dw r 0 dr dr dr ( L 1) pr (r ) pr (r )dr pr (r ) 1 pr (r ) ps ( s ) ( L 1) pr (r ) L 1 ds ds dr 8/1/2020 7 Example Suppose that the (continuous) intensity values in an image have the PDF 2r , 2 pr (r ) ( L 1) 0, for 0 r L-1 otherwise Find the transformation function for equalizing the image histogram. 8/1/2020 8 Example r s T (r ) ( L 1) pr ( w) dw 0 ( L 1) r 0 2w dw 2 ( L 1) 2 r L 1 8/1/2020 9 Histogram Equalization Continuous case: r s T (r ) ( L 1) pr ( w)dw 0 Discrete values: k sk T (rk ) ( L 1) pr (rj ) j 0 L 1 k ( L 1) nj MN j 0 j 0 MN k 8/1/2020 nj k=0,1,..., L-1 10 Example: Histogram Equalization Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096) has the intensity distribution shown in following table. Get the histogram equalization transformation function and give the ps(sk) for each sk. 8/1/2020 11 Example: Histogram Equalization 0 s0 T (r0 ) 7 pr (rj ) 7 0.19 1.33 1 s1 T (r1 ) 7 pr (rj ) 7 (0.19 0.25) 3.08 3 j 0 1 j 0 8/1/2020 s2 4.55 5 s3 5.67 6 s4 6.23 6 s5 6.65 7 s6 6.86 7 s7 7.00 7 12 Example: Histogram Equalization 8/1/2020 13 8/1/2020 14 8/1/2020 15 8/1/2020 16