Lecture 3
Lecture 3
Lecture: (3)
Image Enhancement (histogram processing)
2025-2024
Histogram processing:
• the histogram of image records the frequency distribution of gray levels in the image.
• Histogram plots how many times(frequency) each intensity value in image occurs.
• A graph indicating the number of times each grey level occurs in the image.
count Pixel
Ex: value
7 0
6 1
8 2
6 3
4 4
2 5
3 6
36 Total
Properties of histogram:
• Let for k=0,1,2,…..,L-1, represent the intensities of an L-level image
• The unnormalized histogram of is defined as
• Where is the number of pixels of with intensity .
• The subdivisions of the intensity scale are called histogram bins.
• The normalized histogram of is defined as
• Where as usual, M and N are the number of rows and columns.
• The sum of for all values of k is always (1).
Stretch histogram
The mapping function for histogram stretch can be found by
the following equation:
[MAX-MIN]+MIN.
Where: I(r, c) max is the largest gray- level in the image I(r, c).
I(r, c) min is the smallest gray- level in the image I(r, c).
max and min the maximum and minimum gray – level values
possible (for an 8-bit image these are 255 and 0).
Example : Suppose you have the following sub of image. Perform the Stretch histogram
7 8 12 7
Answer:
I(r,c)max = 12 , I(r,c)min = 1 , Max = 63 , Min = 0 4 6 9 11
[MAX-MIN]+MIN.
5 1 5 10
7−1
𝐼 ( 𝑥 , 𝑦 )= ⌊ ⌋ [ 63 − 0 ]+ 0 =
12−1
I( r, c) = ((7-1)/(12-1) ) * (63-0)+0 = (6/11)*63 = 34.36 40. 34.
63
09 36
I( r, c) = ((12-1)/(12-1) ) * (63-0)+0 = 63
I( r, c) = ((8-1)/(12-1) ) * (63-0)+0 = (7/11)*63 = 34.36
A piecewise linear stretching function
Using it to find the pixel values in the image between ai and ai+1.
Since the line between the coordinates (ai,bi) and (ai+1,bi+1) has the equation:
Histogram Equalization:
Is a popular technique for improving the appearance of a poor image.
It's a function is similar to that of a histogram stretch but often provides more visually pleasing results a cross a wide rang
of images.
The histogram equalization process for digital images consists of four steps:
1. Find the running sum of the histogram values
2. Normalize the values from step1 by dividing by total number of pixels.
3. Multiply the values from step2 by the maximum gray level value and round.
4. Map the gray-level values to the results from step 3, using a one-to-one correspondence.
Example : - We have an image with 3 bit /pixel, so the possible range of values is 0 to 7 . We have an image with the
following histogram
Answer :
Step 1: create a running sum of histogram values. This means that the first
values is 10, The second is 10+8=18, next is 10+8+9=27, and soon. Here we get
10,18,29,43,44,49,51.
7 6 5 4 3 2 1 0 Gray level value
51 49 44 43 29 27 18 10 Run sum
Step 2: Normalize by dividing by total number of pixels. The total number of pixels is 10+8+9+2+14+1+5+2=51.
Step 3: Multiply these values by the maximum gray level values in this case 7 , and then round the result to the closet
integer. After this is done, we obtain 1,2,4,4,6,6,7,7.
All pixel in the original image with gray level 0 are set to 1, values of 1 are set to 2,
and values 2 set to 4, and values 3 set to 4, and so on. Histogram equalization,
you can see the original histogram and the resulting histogram equalized
histogram. Although the result is not flat, it is closer to being flat than the original
Before Histogram Equalization
7 6 5 4 3 2 1 0 Gray level value
1 No. of Pixel histogram
2 5 1 2 9 8 10 value
4