Top Banner
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. MTCT DI&SP 2.3 Histogram-based Operations
41

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.

Dec 17, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 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.

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

Page 2: 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.

               

0 1 2 3 4 57

6 5

4 3

2 1

0

#pixel

intensity

Page 3: 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.

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

Page 4: 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.

MTCT DI&SP

Dark image

Normal image

Bright image

Page 5: 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.

MTCT DI&SP

High Contrast image

Low Contrast image

Page 6: 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.
Page 7: 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.
Page 8: 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.
Page 9: 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.

Histogram

Page 10: 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.

Original ImageOriginal Image + 40 Original Image - 40

Page 11: 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.

Original ImageOriginal Image * 1.2 Original Image / 1.2

Page 12: 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.

Histogram

Histogram in Color Image

RGB

Page 13: 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.

hi = histogram of gray level i

MTCT DI&SP

LN

nh i

i

2550 i

Page 14: 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.

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.

Page 15: 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.

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.

Page 16: 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.

2.3.1 Histogram Equalization

Histogram Equalization (Goal) to obtain a uniform histogram for

the output imageMapping 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)

                                                              

 

                                                                                                         

   

Page 17: 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.

2.3.1 Histogram Equalization

Histogram Equalization Steps 1. Compute histogram.

2. Calculate normalized sum of histogram

3. Transform input image to output image

                                                              

 

                                                                                                         

   

Page 18: 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.

Ex. HE

Image of 16-level intensity values

Its corresponding histogram

Page 19: 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.

1) Compute histogramGray level i ni h i=ni/Total

0 15 0.0416

1 0 0

2 0 0

3 0 0

4 0 0

5 0 0

6 0 0

7 0 0

8 0 0

9 70 0.1944

10 110 0.3055

11 45 0.1250

12 80 0.2222

13 40 0.1111

14 0 0

15 0 0

Total 360

Page 20: 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.

2) Accum. histogram

Gray level i ni h i=ni/Total Accu hi

0 15 0.0416 0.0416

1 0 0 0.0416

2 0 0 0.0416

3 0 0 0.0416

4 0 0 0.0416

5 0 0 0.0416

6 0 0 0.0416

7 0 0 0.0416

8 0 0 0.0416

9 70 0.1944 0.2360

10 110 0.3055 0.5415

11 45 0.1250 0.6665

12 80 0.2222 0.8887

13 40 0.1111 0.9998

14 0 0 0.9998

15 0 0 0.9998

Total 360

Page 21: 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.

2) Accum. histogramGray level i ni h i=ni/Total Accum. hi Accm. H x 15

0 15 0.0416 0.0416 0.6240

1 0 0 0.0416 0.6240

2 0 0 0.0416 0.6240

3 0 0 0.0416 0.6240

4 0 0 0.0416 0.6240

5 0 0 0.0416 0.6240

6 0 0 0.0416 0.6240

7 0 0 0.0416 0.6240

8 0 0 0.0416 0.6240

9 70 0.1944 0.2360 3.5400

10 110 0.3055 0.5415 8.1225

11 45 0.1250 0.6665 9.9975

12 80 0.2222 0.8887 13.3305

13 40 0.1111 0.9998 14.9970

14 0 0 0.9998 14.9970

15 0 0 0.9998 14.9970

Total 360

Page 22: 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.

3) Transform input image to output image Gray level i ni h i=ni/Total Accum. hi Accm. H x 15 New gray level

0 15 0.0416 0.0416 0.6240 1

1 0 0 0.0416 0.6240 1

2 0 0 0.0416 0.6240 1

3 0 0 0.0416 0.6240 1

4 0 0 0.0416 0.6240 1

5 0 0 0.0416 0.6240 1

6 0 0 0.0416 0.6240 1

7 0 0 0.0416 0.6240 1

8 0 0 0.0416 0.6240 1

9 70 0.1944 0.2360 3.5400 4

10 110 0.3055 0.5415 8.1225 8

11 45 0.1250 0.6665 9.9975 10

12 80 0.2222 0.8887 13.3305 13

13 40 0.1111 0.9998 14.9970 15

14 0 0 0.9998 14.9970 15

15 0 0 0.9998 14.9970 15

Total 360

Page 23: 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.

Result intensity values

Its corresponding histogram

Page 24: 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.

Histogram Equalization

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

Page 25: 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.

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.

Page 26: 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.

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.

Page 27: 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.

Histogram Equalization// histogramfor( idx = 0; idx < IpixelValue.length; idx++ ) {

    r = ( IpixelValue[idx] & 0x00FF0000 ) >> 16;    g = ( IpixelValue[idx] & 0x0000FF00 ) >> 8;    b = ( IpixelValue[idx] & 0x000000FF );

    red_pixel_value[r]++;    green_pixel_value[g]++;    blue_pixel_value[b]++;}

Page 28: 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.

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• . . .

Page 29: 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.

Histogram Equalization• Transform input image to output image

// LUT inputfor( 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]]);

                                                            

 

Page 30: 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.

Original Image Histogram Equalize ImageEqualizatio

n(256 Level)

Page 31: 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.
Page 32: 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.
Page 33: 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.

Histogram Equalization

Page 34: 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.

Histogram Equalization

Original Image Equalized Image

Page 35: 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.

Histogram Equalization

Original Image Equalized Image

Page 36: 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.

Input / Output

Saturation image

Saturation adjustment function

Saturation histogram

Histogram Equalization

Page 37: 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.

Image

Histogram equalized intensity

Histogram Equalization

Page 38: 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.

Original image

Histogram equalized intensity

Each R, G, B image is histogram equalized

Histogram Equalization

Page 39: 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.

/******************************************************** * 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 */

Page 40: 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.

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]]++;

Page 41: 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.

/* 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]]; }