Challenge - 5 Problems
Image Thresholding Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of binary thresholding with OpenCV
What is the shape and unique values of the output image after applying binary thresholding with threshold=127 on a grayscale image of shape (100, 100) with pixel values ranging from 0 to 255?
Computer Vision
import cv2 import numpy as np img = np.random.randint(0, 256, (100, 100), dtype=np.uint8) _, thresh_img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY) unique_vals = np.unique(thresh_img) output_shape = thresh_img.shape print(output_shape, unique_vals)
Attempts:
2 left
💡 Hint
Binary thresholding converts pixels to either 0 or max value based on threshold.
✗ Incorrect
Binary thresholding sets pixels above threshold to max value (255) and below to 0, keeping the image shape unchanged.
🧠 Conceptual
intermediate1:30remaining
Understanding adaptive thresholding
Which statement best describes adaptive thresholding compared to global binary thresholding?
Attempts:
2 left
💡 Hint
Think about how lighting changes across an image.
✗ Incorrect
Adaptive thresholding computes thresholds locally for small areas, making it good for images with uneven lighting.
❓ Metrics
advanced2:00remaining
Evaluating Otsu's thresholding output
After applying Otsu's thresholding on a bimodal grayscale image, what metric best indicates the quality of the threshold?
Attempts:
2 left
💡 Hint
Otsu's method tries to separate two classes clearly.
✗ Incorrect
Otsu's method finds the threshold that maximizes the variance between two classes (foreground and background), improving separation.
🔧 Debug
advanced2:00remaining
Identifying error in adaptive thresholding code
What error will this code raise?
import cv2
import numpy as np
img = np.random.randint(0, 256, (50, 50), dtype=np.uint8)
thresh = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 2, 5)
Attempts:
2 left
💡 Hint
Check the blockSize parameter requirements in adaptiveThreshold.
✗ Incorrect
The blockSize parameter must be an odd number greater than 1; 2 is invalid and causes an OpenCV error.
❓ Model Choice
expert2:30remaining
Choosing thresholding method for uneven lighting
You have a grayscale image with strong shadows and bright spots. Which thresholding method is best to segment the foreground accurately?
Attempts:
2 left
💡 Hint
Consider how local lighting variations affect thresholding.
✗ Incorrect
Adaptive thresholding with Gaussian weighting adjusts thresholds locally, handling uneven lighting better than global or Otsu's methods.