#139How many raw pixel values?Easy

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:

values=C×H×W\text{values} = C \times H \times W

A grayscale image has C=1C = 1; an RGB image has C=3C = 3. 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

  • Hint, height.
  • Wint, width.
  • Cint, number of channels (1 grayscale, 3 RGB).

Output

Returns an int: C×H×WC \times H \times W.

Examples

Example 1 — an RGB ImageNet crop

Input:  H = 224, W = 224, C = 3
Output: 150528

Explanation: 3×224×224=150,5283\times224\times224 = 150{,}528.

Example 2 — a grayscale MNIST digit

Input:  H = 28, W = 28, C = 1
Output: 784

Constraints

  • Return H * W * C as a plain int.

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