This set of OpenCV Multiple Choice Questions & Answers (MCQs) focuses on “Image Sharpening”.

1. What does the anchor parameter indicates in the filter2D() function?

a) Anchor of the kernel that indicates the relative position of a filtered point within the kernel

b) Anchor of the kernel that indicates the parallel position of a filtered point within the kernel

c) Value added to the filtered pixels before storing them in dst

d) Desired depth of the destination image

View Answer

Explanation: Anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel, default value (-1, -1) means that the anchor is at the kernel center.

2. What does the kernel parameter indicates in the filter2D() function?

a) A double-channel floating point matrix

b) A half-channel floating point matrix

c) A quadratic-channel floating point matrix

d) A single-channel floating point matrix

View Answer

Explanation: Kernel parameter indicates a single-channel floating point matrix. if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.

3. Which OpenCV method or function is used for Median Filtering?

a) cv.bilateralBlur()

b) cv2.medianFilter()

c) cv2.mediansmooth()

d) cv2.medianBlur()

View Answer

Explanation: cv2.medianBlur() function is used for Median Filtering technique. Cv2.medianBlur() computes the median of all the pixels under the kernel window and the central pixel is replaced with this median value. The kernel size must be a positive odd integer.

4. The filter2D() function uses the FFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger).

a) True

b) False

View Answer

Explanation: The filter2D() function or method uses the DFT (Discrete Fourier transform) – based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm for small kernels.

5. Which of the following statement is TRUE about filter2D() function in OpenCV?

a) The function does actually compute convolution, not the correlation

b) The function does actually compute both correlation and convolution

c) The function does actually compute correlation, not the convolution

d) The function does actually compute anchor value, not the convolution

View Answer

Explanation: The filter2D function does actually compute correlation, not the convolution. That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using flip and set the new anchor to (kernel.cols – anchor.x – 1, kernel.rows – anchor.y – 1).

6. The sepFilter2D() function applies a separable linear filter to the image.

a) True

b) False

View Answer

Explanation: The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst.

7. What is the output of the following code?

import numpy as one s = one.ones(2, dtype = int) print("Matrix s : \n", s)

a)

Matrix s : [1 1]

b)

Matrix s : [0 1]

c)

Matrix s : [[1 1] [1 1]]

d)

Matrix s : [[0 1] [0 1]View Answer

Explanation: The output of the code will be Matrix s : [1 1]. The numpy.ones function returns a new array of given shape and type, filled with ones. It takes three parameters: shapeint or sequence of ints , dtypedata -type, optional and order {‘C’, ‘F’}, optional, default: C.

8. Which of the following statement is correct about kernel in OpenCV?

a) Kernel is also known as convolution matrix in OpenCV

b) Kernel is also known as Filtering matrix in OpenCV

c) Kernel is also Known as Normalized matrix in OpenCV

d) Kernel is also known as Mixing Matrix in OpenCV

View Answer

Explanation: Kernel is also known as convolution matrix in OpenCV. Kernel or convolution matrix mixes up or convolutes the pixels in the region. Kernel is a set of weights, which determine how each output pixel is calculated from a neighborhood of input pixels.

9. Which OpenCV function is used to return Gaussian filter coefficients?

a) getGaussianKernel()

b) getKernel()

c) GaussianKernel()

d) getGKernel()

View Answer

Explanation: The OpenCV (Open computer Vision)’s getGaussianKernel() function or method returns Gaussian filter coefficients. The function computes and returns the ksize × 1 matrix of Gaussian filter coefficients.

10. Which OpenCV method or function is used to calculates the Laplacian of an image?

a) Laplacianimage()

b) Laplacian()

c) getLaplacian()

d) getimageLaplacian()

View Answer

Explanation: Laplacian() function is used to calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator.

**Sanfoundry Global Education & Learning Series – OpenCV.**

To practice all areas of OpenCV, __ here is complete set of Multiple Choice Questions and Answers__.

**If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]**