OpenCV Questions and Answers – Image Sharpening

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

Answer: a
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

Answer: d
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

Answer: d
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.
advertisement
advertisement

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

Answer: b
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

Answer: c
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

Answer: a
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?

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

a)

Matrix s : 
 	[1 1]
advertisement

b)

Matrix s : 
 	[0 1]

c)

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

d)

Matrix s : 
 	[[0 1]
     [0 1]   
View Answer
Answer: a
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

Answer: a
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

Answer: a
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

Answer: b
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]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.