Um momento
0x10Lesson 2 of 6

Work with color and image arrays

Inspect channels, coordinates, and the shape of image data.

14 min 4-question quiz 1 code exercise
By the end of this lesson you can
  • Access pixel values by row and column and distinguish color channels.

A color image can store red, green, and blue channel values at every pixel. A pixel might therefore be represented as [R, G, B], with each channel often in the range 0–255. Array conventions matter: many libraries index images as image[row, column], and some libraries load color channels in BGR order instead of RGB.

cv_example.py
pixel = [255, 80, 0]
red, green, blue = pixel
print(red, green, blue)
Output
255 80 0

Image shape is commonly described as height, width, and channels. A grayscale image may omit the channel axis or have one channel. Always check a library’s color ordering before interpreting values or displaying an image.

Key takeaways

  • Access pixel values by row and column and distinguish color channels.

  • Small arrays make vision ideas concrete.

  • Check model performance across varied real-world examples.

Lesson quiz

4 questions · pass with 3 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: apply computer vision with Python

Use small pixel arrays to explore vision concepts, run your code against sample images, and connect each result to the larger computer vision idea.

Exercise 1

Read one color channel

+25 XP

Read a JSON RGB pixel such as [255, 80, 0]. Print only its green channel (the second value).

  • Orange pixel
  • Teal pixel
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Gostou da aula? 😆👍
Apoie nosso trabalho com uma doação: