Challenge - 5 Problems
Color Space Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output shape after converting an RGB image to grayscale using OpenCV?
Given an RGB image with shape (100, 150, 3), what will be the shape of the image after converting it to grayscale using OpenCV's cvtColor function?
Computer Vision
import cv2 import numpy as np image_rgb = np.random.randint(0, 256, (100, 150, 3), dtype=np.uint8) gray_image = cv2.cvtColor(image_rgb, cv2.COLOR_RGB2GRAY) print(gray_image.shape)
Attempts:
2 left
💡 Hint
Grayscale images have only one channel, so the shape loses the last dimension.
✗ Incorrect
When converting an RGB image (height, width, 3) to grayscale, the output image has shape (height, width) because grayscale images have only one channel.
🧠 Conceptual
intermediate1:30remaining
Why does OpenCV use BGR instead of RGB by default?
OpenCV uses BGR color order by default instead of RGB. What is the main reason for this?
Attempts:
2 left
💡 Hint
Think about historical image file formats and compatibility.
✗ Incorrect
OpenCV uses BGR by default because it matches the color order used in Windows bitmap files, which historically stored pixels in BGR order.
❓ Metrics
advanced1:30remaining
Which metric is best to compare color similarity in HSV space?
You want to measure how similar two colors are in HSV space. Which metric is most appropriate?
Attempts:
2 left
💡 Hint
Consider the numeric nature of HSV and how distances reflect similarity.
✗ Incorrect
Euclidean distance on HSV values captures differences in hue, saturation, and value, making it suitable for color similarity in HSV space.
🔧 Debug
advanced2:00remaining
Why does this code produce a blueish image instead of red?
You load an image using OpenCV and try to display a pure red color by setting pixel values to (255, 0, 0). The displayed image looks blueish. Why?
Computer Vision
import cv2 import numpy as np image = np.zeros((100, 100, 3), dtype=np.uint8) image[:] = (255, 0, 0) # Set to red cv2.imshow('Image', image) cv2.waitKey(0) cv2.destroyAllWindows()
Attempts:
2 left
💡 Hint
Check the color channel order OpenCV expects.
✗ Incorrect
OpenCV uses BGR color order by default, so setting (255, 0, 0) sets the blue channel to max, producing a blue image instead of red.
❓ Model Choice
expert2:30remaining
Which color space is best for skin tone detection in images?
You want to build a model to detect skin tones in images robustly under different lighting. Which color space is generally best to use as input features?
Attempts:
2 left
💡 Hint
Think about separating color from light intensity to handle lighting changes.
✗ Incorrect
HSV separates hue and saturation from brightness, making it easier to detect skin tones under varying lighting conditions.