Computer Science
Grade 7
20 min
5. Representing Images: Pixels and Color Codes
Learn how images are represented digitally using pixels and color codes (e.g., RGB).
Tutorial Preview
1
Introduction & Learning Objectives
Learning Objectives
Define a pixel as the smallest unit of a digital image.
Explain how computers use the RGB color model to represent different colors.
Decode simple RGB color codes to identify primary and secondary colors.
Describe the relationship between pixels, resolution, and image quality.
Calculate the total number of pixels in an image given its width and height.
Create a simple 2x2 pixel art image using given RGB values.
Have you ever zoomed in on a photo so much that you see tiny squares? 🤔 Those squares are the secret to how computers store every image you've ever seen!
In this lesson, we'll pull back the curtain on digital images. You will learn how computers see pictures not as whole images, but as a giant grid of tiny dots called pixels, each with...
2
Key Concepts & Vocabulary
TermDefinitionExample
PixelShort for 'Picture Element', it is the smallest single dot of light on a digital screen. A grid of thousands or millions of pixels makes up a complete image.If you look very closely at your phone screen, you can see the individual red, green, and blue lights that form a single pixel.
Bitmap ImageAn image made up of a grid (or map) of pixels. Each pixel in the grid is assigned a specific color.Common bitmap image file types include JPEG, PNG, and GIF. Your digital photos are bitmap images.
RGB Color ModelA system where colors are created by mixing different amounts of Red, Green, and Blue light. It's how screens on TVs, computers, and phones create all the colors you see.To make the color yellow on a screen, you mix a high amount of red light with...
3
Core Syntax & Patterns
RGB Value Range
(R, G, B) where each value is between 0 and 255.
Each part of an RGB color code (Red, Green, and Blue) is represented by a number from 0 to 255. A value of 0 means that color is 'off' (no light), and 255 means that color is at its 'brightest'.
Mixing Primary Colors
Red + Green = Yellow, Red + Blue = Magenta, Green + Blue = Cyan
When you mix the primary colors of light (Red, Green, Blue) at their maximum brightness, you create the secondary colors (Yellow, Magenta, Cyan).
Calculating Total Pixels
Total Pixels = Width (in pixels) × Height (in pixels)
To find out how many total pixels are in an image or on a screen, you multiply the number of pixels in a row (width) by the number of pixels in a column (height).
4 more steps in this tutorial
Sign up free to access the complete tutorial with worked examples and practice.
Sign Up Free to ContinueSample Practice Questions
Challenging
An image is 10 pixels wide and 8 pixels high. Each pixel's color is represented by an RGB code (3 numbers). How many individual numbers in total are required to store the color data for this entire bitmap image?
A.80
B.240
C.18
D.3
Challenging
You have the RGB color (250, 235, 215), which is a warm off-white color. How would you adjust the code to make it a 'cooler' (more bluish) off-white, while keeping the brightness about the same?
A.Decrease the Red value and increase the Blue value.
B.Increase all three values by 5.
C.Decrease all three values by 20.
D.Set the Green value to 0.
Challenging
A screen has a resolution of 200x200 pixels. You want to draw a solid blue square that takes up exactly one-quarter of the total screen area, positioned in the center. What would the width and height of this blue square be in pixels?
A.50x50 pixels
B.200x50 pixels
C.100x100 pixels
D.25x25 pixels
Want to practice and check your answers?
Sign up to access all questions with instant feedback, explanations, and progress tracking.
Start Practicing Free