ELEN E48 Digital Image Processing Homework Solution Chuxiang Li cxli@ee.columbia.edu Department of Electrical Engineering, Columbia University February 4, 6 Image Histogram Stretching. Histogram of Gray-image Figure : The original gray image coin.bmp : 5 pixels; 8-bit/pixel. Fig. shows the original gray image coin.bmp, which has a spatial resolution of 5 pixels with 8 bits per pixel. To generate the histogram of a gray image which is equivalent
to an D color image, the approach is the same as that employed for each single color channel of a D color image. Please see the solution of Homework for more details. Fig. shows the histograms of the original gray image coin.bmp in the cases of n = 8 and n = 56 bins. It is seen from Fig. that the distribution of the pixel values is far from an even distribution over the entire region. In other words, most of the pixels fall in a relatively small region.. Histogram Stretching The piecewise mapping function for the stretching operation can be analytically derived as follows. Denote β, β and β as the intercepts for the three lines corresponding to the three regions [, stin ), [stin, stin max ], and (stin max, M], respectively. Denote α, α and α as the slopes for the three lines corresponding to the three regions [, stin ), [stin, stin max ], and (stin max, M], respectively. The slopes can be simply written as α = stout stin, () α = stout max stout stin max stin, () α = M stout max M stin max. () Note that the intercepts satisfy the following equations in geometry: from which the intercepts can be derived β =, stin max = stout max β, stin stout β M M β =, stin max stout max β β =, (4) β = stin stout max stin max stout stin max stin, (5) β = M stout max stin max M stin max. (6)
x 4 Histgram of the original image: n=8.5.5 4 5 6 7 8 9 Histgram of the original image: n=56 x 4.5.5 5 5 75 5 5 75 5 5 Figure : Histograms of the original gray image coin.bmp : n = 8 and n = 56.
Hence, the piecewise stretching operations can be analytically expressed by Out = α i In + β i, i =,,, (7) where α i and β i are defined in () () and (4) (6), respectively; the four parameters stin, stin max, stout, and stout max will be further detailed in Section... Parameters of Histogram Stretching The parameters of the histogram input, stin and stin max, depends on the histogram of the original gray image coin.bmp which is shown in the bottom of Fig.. It is seen from Fig. that in the case of n = 56, the gray values of most of the pixels fall in the region [, ]. Meanwhile, to transform the histogram into the one as spreadly distributed as possible, the parameters of the histogram output, stout and stout max, should be as small as possible and as large as possible, respectively. In the simulations to be demonstrated in Section.4, for n = 56 and M = 56, we choose the values of the above parameters as follows: input parameters : stin =, stin max = ; (8) output parameters : stout =, stout max = 5. (9) Note that, to gain more insight into the role of the output parameters, we choose another set of values as a comparison: stout = 5, stout max = 4. ().4 Simulation Results Fig. shows the histogram comparison between the original image and the stretched image using (9). It is seen from Fig. that the histogram is more spread over the entire region after the stretching operation (7). Similarly, Fig. 4 shows the same comparison between the 4
original image and the stretched image using (), and the similar conclusion can be drawn as from Fig.. Moreover, Fig. 5 shows the comparison between the stretched histograms using different output parameters (9) and (). It is seen from Fig. 5 that the larger the stout max is and the smaller the stout is, the histogram after stretching operation (7) is more spread. Moreover, Fig. 6 shows the subjective performance comparison between the original image and the stretched ones using (9) and (). It is seen from Fig. 6 that the images after the stretching operation (7) can offer a better subjective performance than the original one; and consistent with what Fig. 5 has demonstrated, (9) can achieve a better subjective performance than (). 5
Histgram of the original image: n=56 x 4.5.5 5 5 75 5 5 75 5 5 Histgram of the stretched image: n=56 x 4.5.5 5 5 5 Figure : Comparison between the original histogram and the stretched histogram of the gray image coin.bmp : M = 56; stin = and stin max = (i.e., (8)); stout = and stout max = 5 (i.e., (9)). 6
Histgram of the original image: n=56 x 4.5.5 5 5 75 5 5 75 5 5 Histgram of the stretched image: n=56 x 4.5.5 5 5 5 Figure 4: Comparison between the original histogram and the stretched histogram of the gray image coin.bmp : M = 56; stin = and stin max = (i.e., (8)); stout = 5 and stout max = 4 (i.e., ()). 7
x 4 n=56; stout =; stout max =5.5.5 5 5 5 x 4 n=56; stout =5; stout max =4.5.5 5 5 5 Figure 5: Comparison between the stretched histograms using different output parameters (9) and (). 8
Figure 6: Subjective performance comparison between the original image and the stretched images: M = 56; the bottom image the original one; the upper-left image the stretched one using (9); the upper-right image the stretched one using (). 9
Histogram Transformation Denote U and V as two random variables representing the input and the output of the histogram transformation, respectively. Denote p U (u) and F U (u) = u p U(u)du as the probability density function (pdf) and the cumulative probability density functions (cdf) of U, respectively. Similarly, p V (v) and F V (v) = v p V (v)dv denote the pdf and the cdf of V, respectively. The histogram transformation has the following constraint F U (u) = F V (v). () Obviously, the mapping function v = T (u) corresponding to the histogram transformation () depends on the specific distributions of both U and V.. Mapping Function: Cube-root Hyperbolically Distributed V Assume that V is a random variable with a cube-root hyperbolic distribution, i.e., v / (v p V (v) = max v / / ), if v v v max,, otherwise. Then the cdf of V can be further written as, v > v max, v F V (v) = p V (v)dv = v v p V (v)dv, v v v max,, v < v. () Note that in (), only the region v [v, v max ] is treated in the histogram transformation, and the corresponding cdf of V is given by F V (v) = v/ v /, v [v vmax / v /, v max ]. Inserting () into (), we then have the following mapping function corresponding to the cube-root hyperbolic distribution of V F U (u) = F V (v) = v/ v /, vmax / v /
[ = v = T (u) = (vmax / v / )F U(u) + vmax] /. (). Mapping Function: Uniformly Distributed U It is observed from () that u is involved in the mapping function v = T (u) by F U (u) which has no closed-form expression as long as the pdf of U is unknown. Now assume that U is a random variable with a uniform distribution over [, ], i.e.,, u, p U (u) =, otherwise. Then the cdf of U can be further written as, u >, u F U (u) = p U (u)du = u p U(u)du = u, u,, u <. (4) Similarly as revealed in (), only the region u [, ] in (4) is treated in the histogram transformation. Inserting (4) into the mapping function () obtained in Section., we find the mapping function corresponding to the cube-root hyperbolic distribution of V and the uniform distribution of U: v = T (u) = [ (v / max v / )u + v/ max]. (5) Fig. 7 shows the plot of the mapping function v = T (u) in (5) where v = and v max =, i.e., v = T (u) = u.
Mapping function: v =; v max =.9.8.7 v=t(u).6.4.......4.6.7.8.9 u Figure 7: Mapping function v = T (u) in (5): v = and v max =.