Week 5
Week 5
Image Representation
Matrix representation
We are already familiar with matrix form representation of image as follows:
Image Statistics
Image Representation
Matrix representation
A(0, N − 1)
A(0, 0) A(0, 1) A(0, 2) ...
A(1, 0)
A(1, 1) A(1, 2) ... A(1, N − 1)
A(2, 0) A(2, 1) A(2, 2) ... A(2, N − 1)
A = A(3, 0)
A(3, 1) A(3, 2) ... A(3, N − 1)
.. .. .. .. ..
. . . . .
A(M − 1, 0) A(M − 1, 1) A(M − 1, 2) ... A(M − 1, N − 1)
Image Representation
Image statistics
The mean of an image, A, is denoted by mA and is expressed as follows:
PM −1 PN −1
i=0 j=0 A(i, j)
mA =
MN
2
The variance of image, A is denoted by σA and is expressed as follows:
PM −1 PN −1 2
i=0 j=0 A(i, j) − mA
2
σA =
MN
The standard
p deviation of image A is denoted by σA and is equal to
2
σA = σA
Image Statistics
Image Representation
Histogram
Histogram: An image histogram summarizes (or conveys information about)
the number of times an intensity level is used in an image.
Image Representation
Histogram
Let us consider an image in the range [0, ..., L − 1]. We can represent
the image histogram as follows:
h(rk ) = nk
where
▶ rk = kth gray level or intensity level k
▶ nk = number of pixels in the image having intensity level k
▶ h(rk ) = histogram of image having rk intensity levels
Image Statistics
Image Representation
Histogram
From the previous slide, let us write again the histogram representation as
follows:
h(rk ) = nk
Image Representation
Normalized Histogram
Let us re-visit our previous example again as follows:
Image Representation
Normalized Histogram
Image Representation
Matlab Example
Image Statistics
Image Representation
Matlab Example
Image Statistics
Image Representation
Matlab Example
Image Statistics
Image Representation
Image statistics
Image Representation
Image statistics
Can we reconstruct an image from ’Histogram’ ?
Both the images will have same histogram because both images have only
two intensity values, spread over the whole image equally.
Image Statistics
Image Representation
Contrast
Image Contrast:
Image contrast is the difference between the highest and lowest intensity in
the image. We can differentiate images on the basis of contrast in them.
Low Contrast: Those images that look soft and the range of intensity in
their histogram is only in the middle, then such images are said to be low
contrast images.
High Contrast: High contrast images are sharp or crisp and have intensity
values at darkest and lightest areas.
Image Statistics
Image Representation
Image Contrast
Image Statistics
Image Representation
Image Contrast
Contrast stretching: In contrast stretching, the range of intensity values
of input image are spanned over the desired intensity range.
In the image the intensity values are spanned over full range of possible
intensity values.
Image Statistics
Image Representation
Image Contrast
Consider an image whose intensity range is from rmin to rmax and we
have to stretch this range over 0 to 255.
Image Representation
Histogram Equalization
In histogram equalization, histogram is spread and flatten.
Image Statistics
Image Representation
Histogram Equalization
Image Representation
Image Representation
Intensity value, rk nk uk
0 2015 2015
1 2025 4040
2 2200 6240
3 2200 8440
4 2000 10440
5 2078 12518
6 2250 14768
7 1500 16268
8 1 16269
9 12 16281
10 0 16281
11 13 16294
12 45 16339
13 20 16359
14 15 16374
15 10 16384
Image Statistics
Image Representation
Image Representation
Image Representation
Transformed intensity, sk nk
2 2015
4 2025
6 2200
8 2200
10 2000
11 2078
14 2250
15 1500 + 1 + 12 + 0 + 13 + 45 + 20 + 15 + 10=1616
Image Statistics
Image Representation
Image Representation
where,
sk = Transformed intensity
nj = Frequency of intensity j
Image Statistics
Image Representation
Matlab Example
Image Statistics
Image Representation
Histogram
Image Representation
Example
Image Statistics
Image Representation
Solution
Image Representation
Histogram Specification
Image Statistics
Image Representation
Histogram Specification
Step 1:
Get the target histogram and input image histogram.
Step 2:
Equalize the histogram of input image and target image.
k
X
sk = T (rk ) = (L − 1) pr (rj )
j=0
q
X
sk = G(zq ) = (L − 1) pz (zi )
i=0
Image Statistics
Image Representation
Histogram Specification
Image Representation
Example
Consider a 3-bit 64×64 input image and a 3-bit 4×7 image whose his-
togram is used as target histogram.
Image Statistics
Image Representation
Example
Image Representation
Example
Image Statistics
Image Representation
Example
After both images have been equalized, we have to perform inverse map-
ping.
1. For each value in the round column of original image, find the corre-
sponding value in the round column of the target image and note its index.
2. If the value doesn’t exist in the round column of the target image, find
the index of the nearest value.
3. If multiple nearest values exist in the round column of the target image,
choose the index that is greater than the value.
Image Statistics
Image Representation
Example
Image Statistics
Image Representation
Example