Digital Image
Processing
Lecture 3
Histogram Representation and Processing
Histogram Processing
• Histograms plots how many times (frequency) each intensity value in
image occurs
• Image below (left) has 256 distinct gray levels (8 bits)
• Histogram (right) shows frequency (how many times) each gray level
occurs
• E.g. K = 16, 10 pixels have intensity value = 2
• Only statistical information
• No indication of location of pixels
Rough guess about the histogram of these
images ?
Histogram Processing
• Different images can have same histogram
• 3 images below have same histogram
• Half of pixels are gray, half are white
• Same histogram = Same statistics
• Distribution of intensities could be different
Histogram Processing
• Many cameras display real time
histograms of scene
• Helps taking pictures according
to your requirement
• Also easier to detect types of
processing previously applied to
image
?
• Can we reconstruct image from histogram ?
• Why ???
Histogram
• Histograms help detect image acquisition issues
• Histogram representation of an image can be useful in following
characteristics of an image.
• Exposure: amount of light per unit area reaching the image sensor
• Brightness: average intensity of all pixels in image
• Contrast: difference of foreground and background (objects distinction)
• Dynamic Range: Number of distinct pixels in image
• Artifacts: Image alteration after it is being captured
Histogram Processing
Histogram Processing
Histogram Processing
Histogram Processing
Histogram Processing
Contrast
• Good Contrast?
• Widely spread intensity
values
• Large difference between
min and max intensity
values
High Dynamic Range Imaging
• High dynamic range means very bright and very dark parts in a single
image (many distinct values)
• Dynamic range in photographed scene may exceed number of
available bits to represent pixels
• Solution:
• Capture multiple images at different exposures
• Combine them using image processing
Histogram Equalization
Example 3.5
s0 = 1.33 = 1
s1 = 3.08 = 3
s2 = 4.55 = 5
s3 = 5.67 = 6
s4 = 6.23 = 6
s5 = 6.65 = 7
s6 = 6.86 = 7
s7 = 7.00 = 7
• 1 bit = 2
• 2 bits = 4
• 3 bits = 8
• 4 bits = 16
• 8 bits = 256
• Round off rules
4.785 = 4.XX
• 4.775 = 4.XX
S0 = 7 * [pr(r0)] = 7* 0.19 = 1.33 = 1
S1 = 7 * [pr(r0) + pr(r1)] = 7 * [0.19 + 0.25] = 3.08 = 3
S2 = 7 * [pr(r0) + pr(r1) + pr(r2)] = 7*[ 0.19 + 0.25 +
0.21 ]
= 4.55 = 5
S3 = 7 * [pr(r0) + pr(r1) + pr(r2) + pr(r3)]
7 * [0.19+0.25+0.21+0.16] = 5.67 = 6
rk Nk pr Sk New freq New pr
0 790 0.19 1 0 0
1 1023 0.25 3 790 0.19
2 850 0.21 5 0 0
3 656 0.16 6 1023 0.25
4 329 0.08 6 0 0
5 245 0.06 7 850 0.21
6 122 0.03 7 985 0.24
7 81 0.02 7 448 0.11
Histogram Matching (Specification)
• A histogram of intensity probability is given.
• These values are used in Transformation Function.
Histogram Matching (Specification)
• Example 3.8
• Given Data
Histogram Matching (Specification)
s0 = 1.33 = 1
s1 = 3.08 = 3
s2 = 4.55 = 5
s3 = 5.67 = 6
s4 = 6.23 = 6
s5 = 6.65 = 7
s6 = 6.86 = 7
s7 = 7.00 = 7
How all sk values are mapped to zq
s0 = 1.33 = 1
s1 = 3.08 = 3
s2 = 4.55 = 5
s3 = 5.67 = 6
s4 = 6.23 = 6
s5 = 6.65 = 7
s6 = 6.86 = 7
s7 = 7.00 = 7
Histogram Matching (Specification)
Comparison of Probability Distribution between
Specified Histogram and
Actually Produced Histogram