0
0
Computer Visionml~10 mins

Histogram equalization in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to read an image using OpenCV.

Computer Vision
import cv2

image = cv2.[1]('input.jpg', 0)
Drag options to blanks, or click blank then click option'
Aimread
Bimshow
Cimwrite
DcvtColor
Attempts:
3 left
💡 Hint
Common Mistakes
Using cv2.imshow instead of cv2.imread
Using cv2.imwrite which saves images
Using cv2.cvtColor which converts color spaces
2fill in blank
medium

Complete the code to apply histogram equalization on a grayscale image.

Computer Vision
equalized_image = cv2.[1](image)
Drag options to blanks, or click blank then click option'
Athreshold
BequalizeHist
CcvtColor
Dblur
Attempts:
3 left
💡 Hint
Common Mistakes
Using cv2.cvtColor which changes color spaces
Using cv2.threshold which applies thresholding
Using cv2.blur which blurs the image
3fill in blank
hard

Fix the error in the code to display the equalized image using OpenCV.

Computer Vision
cv2.[1]('Equalized Image', equalized_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Drag options to blanks, or click blank then click option'
Aimread
Bimwrite
CequalizeHist
Dimshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using cv2.imread which reads images
Using cv2.imwrite which saves images
Using cv2.equalizeHist which equalizes histograms
4fill in blank
hard

Fill both blanks to create a histogram equalization function for color images using OpenCV.

Computer Vision
def equalize_color_image(img):
    ycrcb = cv2.cvtColor(img, [1])
    ycrcb[:, :, 0] = cv2.[2](ycrcb[:, :, 0])
    return cv2.cvtColor(ycrcb, cv2.COLOR_YCrCb2BGR)
Drag options to blanks, or click blank then click option'
ACOLOR_BGR2YCrCb
BCOLOR_BGR2GRAY
CequalizeHist
Dthreshold
Attempts:
3 left
💡 Hint
Common Mistakes
Using COLOR_BGR2GRAY which converts to grayscale
Applying threshold instead of equalizeHist
Not converting back to BGR color space
5fill in blank
hard

Fill all three blanks to compute and plot the histogram of a grayscale image using matplotlib.

Computer Vision
import matplotlib.pyplot as plt

hist = cv2.calcHist([image], [[1]], None, [256], [0, 256])
plt.plot(hist)
plt.title('[2] Histogram')
plt.xlabel('[3]')
plt.ylabel('Frequency')
plt.show()
Drag options to blanks, or click blank then click option'
A0
BGrayscale
CPixel Intensity
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using channel 1 which is invalid for grayscale
Wrong plot title or axis labels
Not calling plt.show() to display the plot