CPSC 425 Linear Filtering 20 (Term 2) Practice Questions
Multiple Part True/False Questions. For each question, indicate which of the statements, (A)–(D), are true and which are false? Note: Questions may have zero, one or multiple statements that are true.
Question 1: Which of the following statements are true of a 2D (circular) pillbox filter? Which are false?
(A) A 2D (circular) pillbox filter is separable.
(B) A 2D (circular) pillbox filter is rotationally invariant.
(C) Smoothing with a 2D (circular) pillbox filter acts like a “low-pass” filter. This reduces arti- facts owing to sub-sampling when we construct a pyramid scaled representation.
(D) Smoothing with a 2D (circular) pillbox models “blurring” that occurs when the lens is out of focus.
Solution : (A) False, (B) True, (C) False (D) True
Short Answer Questions. Question 2:
(a) Give a 3 × 3 linear filter that shifts an image 1 pixel downwards and also reduces the image brightness by 50%. Assume the filter is to be implemented as a correlation.
(b) Using your answer to part (a), what is the 3 × 3 linear filter if it is to be implemented as a convolution?
Solution :
As correlation As convolution
0 12 0 0 0 0 000 000 000 0210
Question 3: Digital filtering in computer vision often includes some form of normalization of the filter values. In a sentence or two for each, describe a situation (or task) where the filter values are
(a) normalized to sum to one. (b) normalized to sum to zero.
(c) normalized so that the sum of the squared values is one (i.e., the filter has magnitude one).
Solution :
(a) Normalizationoffiltervaluestosumtooneguaranteesthattheoverallbrightnesslevelofthe image is unchanged. This typically is what we want when the filter is used for smoothing.
(b) Normalization of filter values to sum to zero means that the output is zero when the input image is constant. This typically is what we want when the filter is used for some kind of differentiation.
(c) Normalization of filter values so that the sum of the squared values is one means that, as a 1D vector, the filter is a unit vector. This typically is what we want when the filter is used for template matching (and we’d like to interpret/compare matches absolutely, as a cosine).
Question 4: In this question, we compare the computational costs of convolution with and without using separable filters. We just count the number of multiplication operations required, as they typically dominate the cost of convolution.
(a) Let S be the number of multiplication operations required to convolve a Gaussian filter with an image of size n × n pixels. Assume that we use two separable 1D filters, each of length 6 σ as in Assignment 2. Give an expression for S in terms of σ and n. For simplicity, express S as a real number without accounting for integer roundoff in filter length or any special treatment near image boundaries.
(b) Let R be the number of multiplications operations required to convolve the equivalent single 2D Gaussian filter with an image of size n × n pixels, rather than using the two separable 1D filters. Give an expression for R in terms of σ and n. Again, express R as a real number without accounting for integer roundoff in filter length or any special treatment near image boundaries.
Solution :
(a) There are n2 pixels and 2 × 6 σ multiplications at each pixel. Therefore, S = 2×6σn2 = 12σn2
(b) There are n2 pixels and (6 σ)2 multiplications at each pixel. Therefore, R = (6σ)2n2
Question 5:
(a) We can smooth an image by convolving the 1D vector [0.25, 0.5, 0.25] with the rows and then the columns of the image. Instead, give the 2D matrix that combines these row and column operations into a single 3 × 3 filter that can be convolved with the image. Hint: The calculation is easier if you represent the 1D vector with fractions, as in [1/4, 1/2, 1/4].
Solution :
The 3 × 3 filter is
Note: Here, correlation and convolution are not equivalent.
111 16 8 16 1 1 1
848 111
Note: the filter is symmetric about its center row and column so that here correlation and convolution are equivalent.
(b) Following this smoothing, we wish to use the 1D filter [−1, 0, 1], applied to the rows of the image, to calculate the first central difference in the horizontal direction and thus esti- mate image gradients corresponding to vertical edges. Combine this 1D filter with your answer from part (a) to generate a single 2D filter that estimates the horizontal derivative of the smoothed image. Hint: Be sure to indicate whether you intend your final filter to be implemented as a correlation or as a convolution.
Solution :
The final filter is 3 × 5
As correlation As convolution
−1 −1 0 16 8
11 −8 −4 0
−1 −1 0 16 8
1 1 1 1 0 −1 −1
816168 1111
488 111
4 0 −4 −8 1 0 −1 −1