0
0
Computer Visionml~20 mins

Image properties (shape, dtype, size) in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Properties Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1: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)
A(128, 256, 3)
B(3, 128, 256)
C(256, 128, 3)
D(128, 256)
Attempts:
2 left
💡 Hint
Remember the shape format is (height, width, channels) for color images.
Predict Output
intermediate
1: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)
Afloat64
Bfloat32
Cuint8
Dint64
Attempts:
2 left
💡 Hint
Check the dtype argument used when creating the array.
Metrics
advanced
1:30remaining
Calculate the total number of pixels in a grayscale image
If an image has shape (512, 512), how many pixels does it contain?
A512
B1024
C262144
D1048576
Attempts:
2 left
💡 Hint
Multiply the height by the width to get total pixels.
Model Choice
advanced
1: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?
AData type of the image array
BSize of the image file on disk
CNumber of unique colors in the image
DShape of the image array
Attempts:
2 left
💡 Hint
The model expects a specific shape format.
🔧 Debug
expert
2: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())
ATypeError: 'numpy.int64' object is not callable
BPrints 30000
CPrints (100, 100, 3)
DSyntaxError due to missing colon
Attempts:
2 left
💡 Hint
Check if size is a method or a property.