Digital Image Processing Quiz 2 & 3 Solution Given By: Dr. Md. Hasanuzzaman
CSE433 Lecture: 7,8,9,10 Solved By: Md Saidur Rahman Kohinoor
1. Image Enhancement: Enhancement is to process an image so that the result is more suitable than the original image for a specific application. Two approaches use for image enhancement: Frequency Domain: Based on modifying the Fourier Transform of an image. Rate of change in frequency in FT is equal to the pattern of intensity variation. Away from origin higher the frequency and faster gray level change. Spatial domain: Refer to the image plane itself. Direct manipulation of pixels in an image. Spatial domain process is denoted by the expression, g (x, y) = T [f (x, y)]
2. The negative of image with gray levels in the range [0, L-1] is obtain by, s = (L–1) – r Where, L -1 ( for 8 bit 255) is the upper limit of the gray level, r = gray level of f(x, y), s = gray level of g(x, y) Procedure: for (int i=0;i< width; i++){ for (int j=0;j< height; j++){ pixels [i][j] = 255-pixels [i][j]; } }
3. ❖ Contrast stretching is piecewise-linear transformation function. ❖ to increase the dynamic range of the gray levels in the image being processed
output gray level, s
L-1 3L/4
(r2, s2)
L/2
T(r)
L/4
(r1, s1)
0
L/4 3L/4 L/2 Input gray level, r
L-1
4. Image Histogram: The histogram functions count the number of elements within a range and display each range as a rectangular bin. The height (or length when using rose) of the bins represents the number of values that fall within each range. for (int i=0;i<width;i++){ for (int j=0;j
sk = T ( rk ) =
k
Pr (rj ) = j =0
k
nj
j =0
n
❖ The probability of occurrence of gray level rk in an image is approximated by,
❖ Where k = 0, 1, 2, --- L-1; n is the total number of pixels, nk is the number of pixels that have gray level rk.
❖ A plot pr(rk) vs. rk is called histogram
❖ The transformation (mapping) sk is called histogram normalization.
5. IMAGE SMOOTHING: Linear Filter: The output (response) of a smoothing, linear spatial filter is simply the average of the pixels contained in the neighborhood of the filter mask. These filters sometimes are called averaging filters or low filters.
Non-Linear Spatial Filter: The nonlinear spatial filter whose response is based on ordering the pixels contained in the image area encomed by the filter and then replacing the value of the center pixel with the value determined by the ranking result. The best-known filter is median filters. IMAGE SHARPENING: Sharpening is to highlight fine detail in an image First-order derivative: of an one dimensional function, f(x)
f = f ( x + 1) − f ( x ) x Second-Order derivative
2 f = f ( x + 1) + f ( x − 1) − 2 f ( x) 2 x
1. Pattern: A pattern is an arrangement of descriptors (denoted as feature) or individual image regions (objects). Pattern class: A pattern class is a family of patterns that share some common properties Pattern recognition system: Pattern recognition refers to the classification of objects or patterns. Requirement of Pattern recognition system: The design of pattern recognition systems requires that a set of training patterns, which are patterns with extrinsic pattern class labels be available. ❖ Central theme of recognition is the concept of “learning” from sample pattern ❖ Formation of decision rules for pattern recognition or classification.
2. ❖ Correlation coefficient
t = M t / Pt (0< ≤1) t
Where Mt is the total number of matched pixels and Pt is the total number of pixels. ❖ Minimum distance: Manhattan distance x y
t = { | I − Gt |} 1
th
Where, I(x,y) input image and Gt(x,y) is t
template image.
Template Matching: ❖ If two methods classify the image into the same class, then the pose is recognized; ot herwise ignored. ❖ Image and Template are the same sizes (same resolution) ❖ Object size grater/smaller according to camera and object distance, in that case, ❖ Multi-resolution templates or template pyramid are used ❖ Or, Original image is resized multiple times.
3. ❖ Supervised Learning: labeled training samples ❖ Unsupervised Learning: unlabeled training samples ❖ Semi-supervised Learning: labeled with few samples and then adapt more unlabeled samples
4. Template Matching Approach for Face Detection:
Step 1: Prepare Template images with different resolutions Step 2: For each frame template image sliding starts from the (0,0) position of the image and progresses it by a given step size from left to right and top to bottom. Step 3: Measure Minimum distance or Correlation Coefficient Step 4: This process is done until template reaches the end of the input image Step5: Based on specific threshold detect face area and draw a boundary.