Challenge - 5 Problems
Image Properties Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the shape of the image array?
Given the following code that loads an image as a NumPy array, what is the shape of the array?
Computer Vision
import numpy as np image = np.zeros((128, 256, 3), dtype=np.uint8) print(image.shape)
Attempts:
2 left
💡 Hint
Remember the shape format is (height, width, channels) for color images.
✗ Incorrect
The shape (128, 256, 3) means the image has 128 pixels in height, 256 pixels in width, and 3 color channels (RGB).
❓ Predict Output
intermediate1:30remaining
What is the data type of the image array?
What will be printed by this code snippet?
Computer Vision
import numpy as np image = np.ones((64, 64), dtype=np.float32) print(image.dtype)
Attempts:
2 left
💡 Hint
Check the dtype argument used when creating the array.
✗ Incorrect
The dtype was set to np.float32, so the printed data type is float32.
❓ Metrics
advanced1:30remaining
Calculate the total number of pixels in a grayscale image
If an image has shape (512, 512), how many pixels does it contain?
Attempts:
2 left
💡 Hint
Multiply the height by the width to get total pixels.
✗ Incorrect
512 * 512 = 262144 pixels in total.
❓ Model Choice
advanced1:30remaining
Choosing the correct image property for model input
You want to feed a color image into a neural network that expects input shape (batch_size, height, width, channels). Which property must you check before feeding the image?
Attempts:
2 left
💡 Hint
The model expects a specific shape format.
✗ Incorrect
The model input requires the image array shape to match (batch_size, height, width, channels).
🔧 Debug
expert2:00remaining
Why does this code raise an error when accessing image size?
Consider this code snippet:
import numpy as np
image = np.zeros((100, 100, 3), dtype=np.uint8)
print(image.size())
Computer Vision
import numpy as np image = np.zeros((100, 100, 3), dtype=np.uint8) print(image.size())
Attempts:
2 left
💡 Hint
Check if size is a method or a property.
✗ Incorrect
The 'size' attribute is a property, not a method, so calling size() raises a TypeError.