Presentation is loading. Please wait.

Presentation is loading. Please wait.

What's a histogram? The Histogram shows the total tonal distribution in the image – global quality. It's a bar-chart of the count of pixels of every tone.

Similar presentations


Presentation on theme: "What's a histogram? The Histogram shows the total tonal distribution in the image – global quality. It's a bar-chart of the count of pixels of every tone."— Presentation transcript:

1 What's a histogram? The Histogram shows the total tonal distribution in the image – global quality. It's a bar-chart of the count of pixels of every tone of gray that occurs in the image. It helps us analyze, and more importantly, correct the contrast of the image. MTCT DI&SP 2.3 Histogram-based Operations

2 0 1 2 3 4 5 7 6 5 4 3 2 1 0 #pixel intensity

3 Histogram  Histogram A simple bar graph that stands for pixel intensities.  The pixel intensities are plotted along the x-axis and the number of occurrences for each intensity are plotted along the y-axis.  Provide information about contrast and overall intensity distribution of an image

4 MTCT DI&SP Dark image Normal image Bright image

5 MTCT DI&SP High Contrast image Low Contrast image

6

7

8

9 Histogram

10 Original Image Original Image + 40 Original Image - 40

11 Original Image Original Image * 1.2Original Image / 1.2

12 Histogram  Histogram in Color Image RGB

13 h i = histogram of gray level i MTCT DI&SP

14  The histogram barchart shows at a glance the relative image tone distribution over the entire range.  In this image, we have a very high count of pixels that are near, but not at, the white end.

15  We also have many that are near, but not at, the black end.  Our image does not totally fill the possible range from darkest to lightest tones.  Our image could have more contrast.

16 2.3.1 Histogram Equalization  Histogram Equalization (Goal) to obtain a uniform histogram for the output image  Mapping of gray level r into gray level s s.t. the distribution of gray level s is uniform.  Spreading: the peaks and valleys will be shifted (due to approximation in digitized space)

17 2.3.1 Histogram Equalization  Histogram Equalization Steps 1.Compute histogram. 2.Calculate normalized sum of histogram 3.Transform input image to output image

18 Ex. HE  Image of 16-level intensity values Its corresponding histogram

19 1) Compute histogram Gray level inini h i =n i /Total 0150.0416 100 200 300 400 500 600 700 800 9700.1944 101100.3055 11450.1250 12800.2222 13400.1111 1400 1500 Total360

20 2) Accum. histogram Gray level inini h i =n i /TotalAccu h i 0150.0416 100 200 300 400 500 600 700 800 9700.19440.2360 101100.30550.5415 11450.12500.6665 12800.22220.8887 13400.11110.9998 14000.9998 15000.9998 Total360

21 2) Accum. histogram Gray level inini h i =n i /TotalAccum. h i Accm. H x 15 0150.0416 0.6240 1000.04160.6240 2000.04160.6240 3000.04160.6240 4000.04160.6240 5000.04160.6240 6000.04160.6240 7000.04160.6240 8000.04160.6240 9700.19440.23603.5400 101100.30550.54158.1225 11450.12500.66659.9975 12800.22220.888713.3305 13400.11110.999814.9970 14000.999814.9970 15000.999814.9970 Total360

22 3) Transform input image to output image Gray level inini h i =n i /TotalAccum. h i Accm. H x 15New gray level 0150.0416 0.62401 1000.04160.62401 2000.04160.62401 3000.04160.62401 4000.04160.62401 5000.04160.62401 6000.04160.62401 7000.04160.62401 8000.04160.62401 9700.19440.23603.54004 101100.30550.54158.12258 11450.12500.66659.997510 12800.22220.888713.330513 400.11110.999814.997015 14000.999814.997015 000.999814.997015 Total360

23 Result intensity values Its corresponding histogram

24 Histogram Equalization Fig. 2.8 (a) Original image; (b) histogram of original image; (c) histogram equalized image; (d) histogram of equalized image.

25 Histogram Equalization  The effects of H.E.  H.E. stretches contrast (expand the range of gray levels) for gray levels near histogram maxima  Compresses contrast in areas with gray levels near histogram minima.  Contrast is expanded for the most of the image pixels => H.E. usually improves the detectability of many image features.

26 Histogram Equalization  The effects of H.E.  The resulting histogram is not flat nothing in the discrete approximation of the continuous result previously derived says that it should be flat.  Similar effect of enhancement could be achieved by manual contrast stretching approach But, the advantage of H.E is fully automatic.

27 Histogram Equalization // histogram for( idx = 0; idx > 16; g = ( IpixelValue[idx] & 0x0000FF00 ) >> 8; b = ( IpixelValue[idx] & 0x000000FF ); red_pixel_value[r]++; green_pixel_value[g]++; blue_pixel_value[b]++; }

28 Histogram Equalization Calculate normalized sum of histogram // red normalized sum. double scale_factor = 255.0 / IpixelValue.length; for( idx=0; idx < 256; idx++) { sum += red_pixel_value[idx]; red_Nsum[idx] = (int)((sum * scale_factor) + 0.5); } 1 * (7/16) = 0.43 3 * (7/16) = 1.31...

29 Histogram Equalization Transform input image to output image // LUT input for( idx = 0; idx < imageBuffer.getWidth() * imageBuffer.getHeight(); idx++) OpixelValue[idx] = 0xFF000000 | (red_Nsum[r[idx]] << 16) | (green_Nsum[g[idx]] << 8) | (blue_Nsum[b[idx]]);

30 Original ImageHistogram Equalize Image Equalization (256 Level)

31

32

33 Histogram Equalization

34 Original Image Equalized Image

35 Histogram Equalization Original Image Equalized Image

36 Input / Output Saturation image Saturation adjustment function Saturation histogram Histogram Equalization

37 Image Histogram equalized intensity Histogram Equalization

38 Original image Histogram equalized intensity Each R, G, B image is histogram equalized Histogram Equalization

39  /************************************************* *******  * Func: histogram_equalize  * Desc: histogram equalize an input image and write it out Params: buffer - pointer to image in memory * number_of_pixels - total number of pixels in image ************************************************** ******/  void histogram_equalize(image_ptr buffer, unsigned long number_of_pixels)  {  unsigned long histogram[256]; /* image histogram */  unsigned long sum_hist[256]; /* sum of histogram elements */

40  float scale_factor; /* normalized scale factor */  unsigned long i; /* index variable */  unsigned long sum; /* variable used to increment sum of hist */  /* clear histogram to 0 */  for(i=0; i<256; i++)  histogram[i]=0;  /* calculate histogram */  for(i=0; i<number_of_pixels; i++)  histogram[buffer[i]]++;

41  /* calculate normalized sum of hist */  sum = 0;  scale_factor = 255.0 / number_of_pixels;  for(i=0; i<256; i++)  {  sum += histogram[i];  sum_hist[i] = (sum * scale_factor) + 0.5;  }  /* transform image using new sum_hist as a LUT */  for(i=0; i<number_of_pixels; i++)  buffer[i] = sum_hist[buffer[i]];  }


Download ppt "What's a histogram? The Histogram shows the total tonal distribution in the image – global quality. It's a bar-chart of the count of pixels of every tone."

Similar presentations


Ads by Google