Digital Image Processing Lecture 04 Image Enhancement-II (Histogram Processing) Naveed Ejaz 2 of 44 A Note About Grey Levels So far when we have spoken about image grey level values we have said they are in the range [0, 255] – Where 0 is black and 255 is white There is no reason why we have to use this range – The range [0,255] stems from display For many of the image processing operations in this lecture grey levels are assumed to be given in the range [0.0, 1.0] 3 of 44 Image Histograms 4 of 44 Image Histograms Frequencies The histogram of an image shows us the distribution of grey levels in the image Massively useful in image processing, especially in segmentation Grey Levels Images taken from Gonzalez & Woods, Digital Image Processing (2002) 5 of 44 Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 6 of 44 Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 7 of 44 Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 8 of 44 Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 9 of 44 Histogram Examples (cont…) Images taken from Gonzalez & Woods, Digital Image Processing (2002) 10 of 44 Histogram Examples (cont…) A selection of images and their histograms Notice the relationships between the images and their histograms Note that the high contrast image has the most evenly spaced histogram 11 of 44 Contrast Stretching through Histogram C If rmax and rmin are the maximum and minimum gray level of the input image and L is the total gray levels of output image The transformation function for contrast stretching will be 12 of 44 Histogram Equalization 13 of 44 Histogram Equalization 14 of 44 Background (Probability Distribution) 15 of 44 Histogram Equalization 16 of 44 Histogram Equalization 17 of 44 Histogram Equalization 18 of 44 Histogram Equalization 19 of 44 Histogram Equalisation(Summary) Spreading out the frequencies in an image (or equalising the image) is a simple way to improve dark or washed out images The formula for histogram sk T (rk ) equalisation is given where – rk: input intensity – sk: processed intensity – k: the intensity range (e.g 0.0 – 1.0) – nj: the frequency of intensity j – n: the sum of all frequencies k pr ( r j ) j 1 k nj j 1 n 20 of 44 21 of 44 Example 22 of 44 Example: cdf 23 of 44 Example Initial Image Image After Equalization Notice that the minimum value (52) is now 0 and the maximum value (154) is now 255. 24 of 44 Example 25 of 44 Histogram Equalization-Examples 26 of 44 Histogram Equalization-Examples 27 of 44 Histogram Equalization-Examples 28 of 44 Histogram Equalization-Examples Images taken from Gonzalez & Woods, Digital Image Processing (2002) 29 of 44 Equalisation Transformation Function 30 of 44 Histogram Equalization-Examples 31 of 44 Histogram Equalization-Examples 32 of 44 Histogram Equalization-Examples 33 of 44 Histogram Equalization-Examples 34 of 44 Histogram Specification/Matching 35 of 44 Histogram Specification/Matching 36 of 44 Histogram Specification/Matching 37 of 44 Histogram Specification/Matching 38 of 44 Histogram Specification/Matching 39 of 44 Histogram Matching Example 40 of 44 Histogram Matching Example(continued) 41 of 44 Histogram Matching Example (continued)