Challenge - 5 Problems
Color Space Conversion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of RGB to Grayscale Conversion
What is the output of this MATLAB code that converts an RGB pixel to grayscale using the luminance method?
MATLAB
rgb = [0.2, 0.4, 0.6]; gray = 0.2989 * rgb(1) + 0.5870 * rgb(2) + 0.1140 * rgb(3); disp(gray);
Attempts:
2 left
💡 Hint
Recall the weighted sum formula for luminance grayscale conversion.
✗ Incorrect
The grayscale value is calculated as 0.2989*0.2 + 0.5870*0.4 + 0.1140*0.6 = 0.3630.
❓ Predict Output
intermediateOutput of RGB to HSV Conversion
What is the output of this MATLAB code converting an RGB pixel to HSV?
MATLAB
rgb = [1, 0, 0]; hsv = rgb2hsv(rgb); disp(hsv);
Attempts:
2 left
💡 Hint
Red color in HSV has hue 0, saturation 1, and value 1.
✗ Incorrect
Pure red in RGB corresponds to HSV values [0, 1, 1].
🔧 Debug
advancedIdentify the error in RGB to YCbCr conversion code
This MATLAB code attempts to convert an RGB pixel to YCbCr but produces incorrect results. What is the error?
MATLAB
rgb = [0.5, 0.5, 0.5]; Y = 0.299*rgb(1) + 0.587*rgb(2) + 0.114*rgb(3); Cb = 128 - 0.168736*rgb(1) - 0.331264*rgb(2) + 0.5*rgb(3); Cr = 128 + 0.5*rgb(1) - 0.418688*rgb(2) - 0.081312*rgb(3); disp([Y Cb Cr]);
Attempts:
2 left
💡 Hint
YCbCr formulas expect RGB in 0-255 range, not 0-1.
✗ Incorrect
The code uses RGB values in [0,1] range but YCbCr formulas require RGB in [0,255]. Without scaling, results are incorrect.
📝 Syntax
advancedSyntax error in MATLAB code converting RGB to CMYK
Which option contains the correct syntax to convert an RGB pixel to CMYK in MATLAB?
Attempts:
2 left
💡 Hint
Check MATLAB syntax for disp and vector construction.
✗ Incorrect
Option D uses correct MATLAB syntax with commas inside disp and ends with semicolon. Option D misses commas, options C and D miss the semicolon.
🚀 Application
expertNumber of pixels converted correctly in batch RGB to grayscale
Given this MATLAB code converting a 3x3 RGB image to grayscale, how many pixels have grayscale value exactly 0.5?
MATLAB
rgbImage = cat(3, [0.5 0.5 0.5; 0.2 0.5 0.8; 0.5 0.5 0.5], ... [0.5 0.5 0.5; 0.2 0.5 0.8; 0.5 0.5 0.5], ... [0.5 0.5 0.5; 0.2 0.5 0.8; 0.5 0.5 0.5]); grayImage = 0.2989 * rgbImage(:,:,1) + 0.5870 * rgbImage(:,:,2) + 0.1140 * rgbImage(:,:,3); count = sum(grayImage(:) == 0.5); disp(count);
Attempts:
2 left
💡 Hint
Calculate grayscale for each pixel and count those equal to 0.5.
✗ Incorrect
Pixels with RGB [0.5 0.5 0.5] convert to 0.5 grayscale. There are 7 such pixels in the 3x3 image.
