This document summarizes the key steps in a digital signal processing project on simulating a basic digital camera model. It discusses face detection using the Viola-Jones algorithm and Haar-like features. It then covers adding noise to images, designing mean and median filters to reduce noise, and optimizing filter performance. The document also discusses histogram equalization for color enhancement and a technique for contrast enhancement that considers color shifting and the human visual system.
3. FACE
DETECTION:
We studied how the face detection works. For this purpose we shall
analyze theViola-JonesAlgorithm which is used extensively for face
detection.
TheViola JonesAlgorithm uses the Haar-like features, which are
shown below:
3
4. FACE
DETECTION:
There are some regularities for all human faces.These regularities
can be exploited to detect the human face.
When the haar-like features are applied onto the image, we just
calculate the sum of all the values of pixel covered by the feature.
Value = Sum(Pixels in black area) – Sum(Pixels in white area)
Each haar-like feature can be used to extract a given feature of the
face, such as the nose, eyes etc.,
4
5. FACE
DETECTION:
Integral
Image
To simplify the computation, an integral image of the original image
is created. It is an image where any pixel value is equal to the sum of
all the pixel values to the left of it and above it.
Original Image Integral Image
5
1 1 3
4 2 0
1 2 1
1 2 5
5 7 9
6 6 7
6. FACE
DETECTION:
Learning
Algorithm
It is cumbersome to evaluate every single feature for a small
window, so the object detection tool uses a learning algorithm
calledAdaBoost to select the best features, eliminating all the
redundant features.
These features are called weak classifiers. i.e., they have at least a
50% accuracy in detecting a facial feature.The output of weak
classifier is either a 0 or 1.
An example of redundant haar-like features is shown below.
6
7. These weak classifiers are given appropriate weights and summed
up. It the output of the above calculation crosses a certain
threshold, then the given part of the image has a face.
This is still computationally inefficient.Therefore, we perform
something called as cascading. In cascading, a group of 10 haar like
features compose a classifier.
If the first classifier is unable to detect a face, that region is
immediately discarded.
Input Maybe Maybe …..
Discard Discard
FACE
DETECTION:
Cascading
Stage 1:
Is input a face?
Stage 2:
Is input a face?
7
10. Filter Design:
Noise
Addition
We study the effects of most common types of noise in the images
such as Gaussian noise, Salt and Pepper Noise etc.The effect of such
noise is illustrated below.
Gaussian noise is an additive noise which follows a zero-mean
Gaussian distribution model. Each pixel is a sum of the actual pixel
value and a random noise value.
10
11. Filter Design :
Noise
Addition
Another type of noise is the salt and pepper noise.This noise is
caused by errors in data transmission.The corrupted bits are either
set to maximum value or minimum value, thus giving an appearance
of white and black spots (like salt and pepper).
Image without noise: Image with Salt and Pepper noise
11
12. Filter Design :
MEAN FILTER
MEAN FILTER:
We use mean filter to reduce the Gaussian noise in the image. We
compare the average filter in matlab and our design.
We take a small square set of pixels(3x3,5x5 or 7x7) to compute the
mean of those pixel values. The centermost value is replaced by the
mean value.
This operation is repeated throughout the image. This process
smoothens the noise, but also reduces the contrast.
12
15. Filter Design:
Mean Filter
The only drawback of the mean filter is the image is blurred. This is because,
all the pixel values are closer to each other, which means that the contrast of
the image has reduced. This effect increases as we increase the size of the
template from 3x3 –> 5x5 –> 7x7, because the mean is calculated for lot more
pixels with a 7x7 template than a 3x3 template.
15
16. Filter Design:
Median Filter
MEDIAN FILTER
To reduce the effects of salt and pepper noise, we use median filter.
It is a non-linear filter which is effective at removing noise while
preserving the edges.
The median filter takes a square set of pixels, calculates the median
of all the values in that square and replaces the centermost value
with the median.
16
22. Filter
Optimization
As shown in the Fig x.x, we find some noise left on the boundary
and we could see that the larger size filter we use, more defects
we have.
Why?
When we do the convolution close to the boundary, we only
replace the center value with the outcome but keep the rest
unchanged. Demo1(HTML)
How to eliminate it?
22
23. Filter
Optimization
Step1:
Extending border values outside with values at boundary
Demo2(HTML)
Step2:
Original image size: N x N;
Apply the 3 x 3 template, after extension, the size is N+2 x N+2
Apply the 5 x 5 template, after extension, the size is N+4 x N+4
Apply the 7 x 7 template, after extension, the size is N+6 x N+6
Or if we want to extend to a larger size, we could just extend the
current dimension by 2
Step3:
After Mean/Median filtering, we ONLY want the center N x N part of
the extended matrix, or we would still have noise in the boundary!
23
27. Color
Enhancement
The idea is to improve the color contrast in image!
Contrast is the difference in luminance or color that makes an
object distinguishable.
One typical way to achieve is: Histogram Equalization
27
28. Color
Enhancement-
Histogram
Equalization
What is Histogram in image?
An image histogram is a type of histogram that acts as a graphical
representation of the tonal distribution in a digital image. It plots
the number of pixels for each tonal value.
The histogram plots the number of pixels in the image (vertical
axis) with a particular brightness value (horizontal axis).
28
29. Color
Enhancement-
Histogram
Equalization
What is Histogram Equalization?
is a method in image processing of contrast adjustment
Through this adjustment, the intensities can be better distributed
on the histogram.This allows for areas of lower local contrast to
gain a higher contrast. Histogram equalization accomplishes this
by effectively spreading out the most frequent intensity values.
Statistically, to form a uniform distribution, following
where k ∈ [a,b], F is the cumulative distribution function
29
31. Color
Enhancement-
Histogram
Equalization
Processing flow:
1. Find numbers of occurrence of each pixel value
For example A=
1 4 2
5 1 3
1 2 4
We could see there 5 different value, so there will be 5 bins in the
histogram.
Consider pixel value 1 occurs 3 times
Same: pixel value 2 occurs 2 times
pixel value 3 occurs 1 time
pixel value 4 occurs 2 times
pixel value 5 occurs 1 times
31
32. Color
Enhancement-
Histogram
Equalization
Processing flow:
2. Find the probability of each occurrence time of each pixel
value
The probability of pixel value 1’s occurrence = occurrence time /
total number of pixels in matrix =3/9
Same: pixel value 2 probability = 2/9
pixel value 3 probability = 1/9
pixel value 4 probability = 2/9
pixel value 5 probability =1/9
32
33. Color
Enhancement-
Histogram
Equalization
Processing flow:
3. Find the cumulative histogram of each pixel
The cumulative histogram of 1 is 3
Same:The cumulative histogram of 2 is 5
The cumulative histogram of 3 is 6
The cumulative histogram of 4 is 8
The cumulative histogram of 5 is 9
33
35. Color
Enhancement-
Histogram
Equalization
Processing flow:
5. Multiply the CDF of each pixel with bin number and round off
The CDF of 1 is 3/9 * 5 = 1.67 = 2
Same:The CDF of 2 is 5/9 * 5 = 2.78 = 3
The CDF of 3 is 6/9 * 5 = 3.3 = 3
The CDF of 4 is 8/9 * 5 = 4.4 = 4
The CDF of 5 is 9/9 * 5 = 5
35
45. Contrast
Enhancement
It proposed two problem that are hardly considered in typical
image enhancement:
1. color shifting
2. human visual system
Processing H (Hue) S (Saturation) V (luminanceValue) component
in image instead of RGB
HSV color: color information encapsulated about a color are more
familiar to humans.
Algorithms: Hue preserved (no change in colors or the image will
get distorted) with human visual system considered
45
46. Contrast
Enhancement
Processing Flow:
1. Load color image
2. Read RGB value for each pixel
3. Convert RGB color space to HSV color space demo3
4. Apply wavelet transform toV component demo4
5. Apply the Reverse-S-ShapeTransform to the approximate
coefficient of V component demo5
6. ReconstructV by inverse wavelet transform demo6
7. Apply the saturation enhancement (histogram equalization)
8. Convert HSV color space to RGB color space
9. Store the color image
46
48. Contrast
Enhancement-
Performance Examination:
Contrast & Luminance
Where σout, Īout are the variance
and average of the luminance
value of the output image and
σin, Īin are those of the input
image.
C L
Old man -0.3894 -0.0337
NOT GOOD
THOUGH
48
49. Discussion:
Although it failed,What we learn and get improved are:
1. Several algorithms including: HSV to RGB color space
transform,ThresholdAutomatic Adaption and Reverse S
shape transform
2. Basic 2D wavelet decompose and reconstruct
3. coding ability
4. Paper analysis ability
49
51. Contrast
Enhancement
What is color shifting?
Color shifting can be described as a visual effect in which the
colors of various objects (particularly bright or out of place objects)
shift and change their appearance through a repeated cycling of
varying colors in a strange and fluid motion across their surface.
For example, moss on a rock could physically shift from green to
red to blue to any other color and then back to green again in the
visual style of a smooth and seamless animated loop.
https://www.youtube.com/watch?v=q-GgpxdNrc4
51
54. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
MAX is the maximal value in R, G, B of all the pixels in the
image, and MIN is the minimal one.
54
55. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
1.Get MAX, MIN in each pixel
8 6
5 4
4 9
1 8
1 2
3 4
Red
Green
Blue
1 2
1 4
8 9
5 8
MAX
MIN
55
56. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
1.Calculate H component
8 6
5 4
4 9
1 8
1 2
3 4
Red
Green
Blue
1 2
1 4
8 9
5 8
MAX
MIN
MAX=R & G>B, we use:
60 ×
4 − 1
8 − 1
+ 0 = 25.71
25.71 ÷ 360 = 0.0714
Normalize by 360 (degree):
56
57. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
2.Calculate S component
8 6
5 4
4 9
1 8
1 2
3 4
Red
Green
Blue
1 2
1 4
8 9
5 8
MAX
MIN
we use:
1 −
1
8
= 0.875
57
58. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
3.CalculateV component
8 6
5 4
4 9
1 8
1 2
3 4
Red
Green
Blue
1 2
1 4
8 9
5 8
MAX
MIN
we use:
= 8
Normalize by max(V):
8 ÷ 9 = 0.89
58
59. Contrast
Enhancement
-Demo3
RGB color space to HSV color space
4.Function in Matlab
we use: rgb2hsv, where h, s, v is normalized after processing
H: 0-1 (0-360);
S: 0-1;
V: 0-1 (0-max(V));
59
61. Contrast
Enhancement
-Demo5
Reverse S shape transform
1.Get threshold – using Automatic Adaption
Step1: Assign two constants m0 and M0, which satisfy 0<=
m0 < M0 <= 255, and M0- m0 > 150. For instance, m0=
30, M0 = 200.
Step2. Compute m1 and M1, satisfy that there are just 5%
of approximate coefficients (Aj) are less than m1 and 5%
of Aj larger than M1.
Coding part: we first get the pixel number of 5% of total matrix
number, then we pre-set a M1 (m1) use if sentence, compare all the
pixels value with M1, if it is larger (smaller) than M1, the total number
+1 so we have to change M1 (m1) until it reach 5% of total matrix
number.
Step3. Set m = min (m0, m1), M = max (M0, M1).
To ensure at least 90% Approximate coefficients A1 will be converted!
61
62. Contrast
Enhancement
-Demo5
Reverse S shape transform
2. Apply transformation
1. Compute R for each approximate coefficient in the range of
[m, M], where
K1 should be assigned a value that is less than min(I)
K2 should be assigned a value that is larger than max(I)
2. Normalize R by
3. Convert approximate coefficient by
62