#139How many raw pixel values?EasyComputer Vision
How many raw pixel values?
Background
An image is a dense grid of numbers. The total number of raw values is the product of its dimensions:
A grayscale image has ; an RGB image has . This count is what you'd get if you flattened the image into a single feature vector.
Problem statement
Implement raw_value_count(H, W, C) returning the number of scalar values in the image.
Input
H—int, height.W—int, width.C—int, number of channels (1 grayscale, 3 RGB).
Output
Returns an int: .
Examples
Example 1 — an RGB ImageNet crop
Input: H = 224, W = 224, C = 3
Output: 150528
Explanation: .
Example 2 — a grayscale MNIST digit
Input: H = 28, W = 28, C = 1
Output: 784
Constraints
- Return
H * W * Cas a plainint.
Notes
- 150,528 inputs is exactly why feeding raw images to a dense MLP explodes the parameter count — and why CNNs, which share weights, are used instead.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Example RGB 224x224 ImageNet crop
- •Reference grayscale MNIST digit
- •Sample small RGB tile