Challenge - 5 Problems
Image Type Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of size for grayscale vs RGB image
What is the output size of the variable
img after running the code below?MATLAB
img = imread('peppers.png');
size_img = size(img);Attempts:
2 left
💡 Hint
Think about the dimensions of a color image in MATLAB: height x width x color channels.
✗ Incorrect
The 'peppers.png' image is 512 pixels high, 384 pixels wide, and has 3 color channels (RGB). So the size is [512 384 3].
❓ Predict Output
intermediateOutput class type of grayscale image
What is the output of the following code?
MATLAB
img = rgb2gray(imread('peppers.png')); class_type = class(img);
Attempts:
2 left
💡 Hint
Check the default class type returned by rgb2gray when input is uint8.
✗ Incorrect
The rgb2gray function converts the RGB image to grayscale but keeps the class type as uint8 by default.
🔧 Debug
advancedIdentify the error in RGB channel extraction
What error will the following code produce?
MATLAB
img = imread('peppers.png'); redChannel = img(:,:,4);
Attempts:
2 left
💡 Hint
Check how many color channels an RGB image has.
✗ Incorrect
RGB images have 3 color channels. Trying to access the 4th channel causes an index error.
🧠 Conceptual
advancedDifference between grayscale and RGB image matrices
Which statement correctly describes the difference between grayscale and RGB images in MATLAB?
Attempts:
2 left
💡 Hint
Think about how color information is stored in image arrays.
✗ Incorrect
Grayscale images store intensity in a 2D matrix (height x width). RGB images store color in a 3D matrix (height x width x 3 color channels).
🚀 Application
expertCount unique intensity values in grayscale image
Given a grayscale image
img, which code correctly counts the number of unique intensity values?MATLAB
img = rgb2gray(imread('peppers.png'));Attempts:
2 left
💡 Hint
unique returns a vector of unique values; count how many elements it has.
✗ Incorrect
unique(img) returns a column vector of unique intensity values. numel counts the number of elements correctly.
