# OpenCV Questions and Answers – Erosion and Dilation

This set of OpenCV Multiple Choice Questions & Answers (MCQs) focuses on “Erosion and Dilation”.

1. Which of the following statement is TRUE about Opening in OpenCV?
a) Opening is just another name of erosion followed by dilation
b) Opening is reverse of Closing, Dilation followed by Erosion
c) It is the difference between dilation and erosion of an image
d) It is just opposite of erosion

Explanation: Opening is just another name of erosion followed by dilation. It is useful in removing noise, as we explained above. Here we use the function, cv2.morphologyEx(). Closing is reverse of Opening, Dilation followed by Erosion.

2. Morphological operations are a set of operations that process images based on shapes.
a) True
b) False

Explanation: Morphological operations are a set of operations that process images based on shapes. Morphological image processing basically deals with modifying geometric structures in the image. They apply a structuring element to an input image and generate an output image.

a) Morphological Gradient is just another name of erosion followed by dilation
b) Morphological Gradient is reverse of Closing, Dilation followed by Erosion
c) It is the difference between dilation and erosion of an image
d) It is just opposite of erosion

Explanation: Morphological Gradient is the difference between dilation and erosion of an image. The result will look like the outline of the object, while Opening is just another name of erosion followed by dilation.

4. Which function is used to Erode an image by using a specific structuring element?
a) erode()
b) eroded()
c) eroding()
d) erodestrcut()

Explanation: erode() function or method is used to Erode an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken.

5. Which of these functions is used to Dilate an image by using a specific structuring element?
a) dilater()
b) dilating()
c) dilate()
d) dilatstruct()

Explanation: dilate() function is used to Dilate an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken.

6. What statement is FALSE about Dilation?
a) Dilation removes white noises, but it also shrinks our object
b) It is just opposite of erosion
c) Dilation operation consists of convolving an image A with some kernel (B), which can have any shape or size, usually a square or circle
d) Dilation can be applied several (iterations) times

Explanation: Erosion removes white noises, but it also shrinks our object. So, we dilate it. Since noise is gone, they won’t come back, but our object area increases. It is also useful in joining broken parts of an object.

7. Black Hat is the difference between input image and Opening of the image.
a) True
b) False

Explanation: Top Hat is the difference between input image and Opening of the image, while black hat is the difference between the closing of the input image and input image. The top-hat filter is used to enhance bright objects of interest in a dark background.

8. Which OpenCV function or method returns a structuring element of the specified size and shape for morphological operations?
a) getStructElement()
b) getStructuring()
c) getStructuringElement()
d) StructuringElement()

Explanation: The getStructuringElement() function or method returns a structuring element of the specified size and shape for morphological operations. The function constructs and returns the structuring element that can be further passed to erode, dilate or morphologyEx.

9. Which of these method or function is used to destroy all of the opened HighGUI windows?
a) destroywindows()
b) destroyAllwinodw()
c) destroyAllWindows()
d) destroyWindow()

Explanation: destroyAllWindows() method or function is used to destroy all the opened highGUI (high graphics User Interface) windows, while destroyWindow is used to destroy the specified windows with the given name.

10. Which OpenCV function or method perform advanced morphological transformations using an erosion and dilation as basic operations?
a) morphologyEx()
b) morpho()
c) morphoEx()
d) morphingEx()

Explanation: The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.

11. Which of the following is useful in closing small holes inside the foreground objects, or small black points on the object?
b) Dilation
c) Erosion
d) Closing

Explanation: Closing is reverse of Opening, Dilation followed by Erosion. It is useful in closing small holes inside the foreground objects, or small black points on the object. Opening is useful in removing noise.

12. Which of the following Enumerator is used for a closing operation?
a) Morphological Gradient is just another name of erosion followed by dilation
b) Morphological Gradient is reverse of Closing, Dilation followed by Erosion
c) It is the difference between dilation and erosion of an image
d) It is just opposite of erosion

Explanation: Morphological Gradient is the difference between dilation and erosion of an image. The result will look like the outline of the object, while Opening is just another name of erosion followed by dilation.

13. Which of the following Enumerator is used for a Black hat operation?
a) MORPH_CLOSE
b) MORPH_OPEN
c) MORPH_ERODE
d) MORPH_BLACKHAT

Explanation: MORPH_BLACKHAT is the enumerator used for black hat, while MORPH_OPEN is the enumerator used for an opening operation, MORPH_TOPHAT is the enumerator used for top hat and MORPH_CLOSE is the enumerator used for a closing operation.

14. Which of the following Enumerator is used for a Top Hat operation?
a) MORPH_CLOSE
b) MORPH_OPEN
c) MORPH_TOPHAT
d) MORPH_BLACKHAT

Explanation: MORPH_TOPHAT is the enumerator used for Top Hat operation, while MORPH_OPEN is the enumerator used for an opening operation, MORPH_BLACKHAT is the enumerator used for Black Hat and MORPH_CLOSE is the enumerator used for a closing operation.

15. Which of the following Enumerator is used for a cross-shaped structuring element?
a) MORPH_RECT
b) MORPH_CROSS
c) MORPH_ELLIPSE
d) MORPH_MULTI

Explanation: MORPH_CROSS is the enumerator used for a cross-shaped structuring element while, MORPH_RECT enumerator is used for a rectangular structuring element and MORPH_ELLIPSE is the enumerator used for an elliptic structuring element.

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]