lecture5 computer archers notes
lecture5 computer archers notes
Lecture 5:
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 1
Contrast Stretching
Contrast stretching
Goal:
Increase the dynamic range of the gray levels for low contrast
images
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 2
1
Contrast stretching through histogram
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
s = T (r ) = (r − rmin )
L
rmax − rmin
rmin rmax
0 L-1
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 3
2
Contrast Stretching Example
Form of
Transformation Original low-
function contrast image
Result of Result of
contrast thresholding
stretching
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 5
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 6
3
Single valued monotonically increasing function
A function T(r) is monotonically increasing
if T(r1) < T(r2) for r1 < r2,
and monotonically decreasing
if T(r1) > T(r2) for r1 < r2.
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 8
4
Histogram equalization: continuous case
▪ Fr(r) and Fs(s) : cdfs of original and transformed gray levels r and s.
▪ pr(r) and ps(s) : pdfs of original and transformed gray levels r and s.
For strictly monotonically increasing transformation function
Fs(s) = Fr(r) or ps(s) ds = pr(r) dr
Goal of histogram equalization:
Gray levels are uniformly distributed
i.e. pdf ps(s) = 1 over the range 0 s 1
dr ds dT (r )
ps ( s) = pr (r ) = 1 or pr (r ) = =
ds dr dr
r
s = T (r ) = pr ( )d
0
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 9
Histogram equalization
If the following transformation function is used
r
s = T (r ) = pr ( )d for 0 r 1
0
Then the pdf ps(s) = 1 over the range 0 s 1
In words
If we select T(r) as the cumulative distribution of r
Then the output image will have a uniform pdf of gray levels
Now Consider
1. a digital (gray level) case
2. the gray levels 0 r L −1
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 10
10
5
Histogram equalization: Discrete case
The discrete approximation of the transformation
function for histogram equalization is:
k
sk = T (rk ) = pr (r j ) for 0 k L − 1
j =0
nj L −1
11
12
6
Histogram equalization examples
Low contrast image Output image
Equalized histogram
Equalized histogram
high contrast image Output image
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 13
13
Equalized histogram
Equalized histogram
Bright input image Output image
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 14
14
7
Histogram equalization examples
15
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 16
16
8
Histogram equalization examples
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 17
17
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 18
18
9
Histogram equalization examples
3/18/2025 Capital University of Science and Technology Digital Image Processing CPE3643 19
19
10