How Computers See Images
The smallest element of an image is called a pixel, or a picture element. It’s basically a dot in the picture. An image contains multiple pixels arranged in rows and columns.
You’ll often see the number of rows and columns expressed as the image resolution. For example, an Ultra HD TV has the resolution of 3840x2160, meaning that it’s 3840 pixels wide and 2160 pixels high.
But a computer does not understand pixels as dots of color. It only understands numbers. To convert colors to numbers, the computer uses various color models.
In color images, pixels are often represented in the RGB color model. RGB stands for Red Green Blue. Each pixel is a mix of those three colors. RGB is great at modeling all the colors humans perceive by combining various amounts of red, green, and blue.
Since a computer only understand numbers, every pixel is represented by three numbers, corresponding to the amounts of red, green, and blue present in that pixel. You can learn more about color spaces in Image Segmentation Using Color Spaces in OpenCV + Python.
In grayscale (black and white) images, each pixel is a single number, representing the amount of light, or intensity, it carries. In many applications, the range of intensities is from
0 (black) to
255 (white). Everything between
255 is various shades of gray.
00:24 The problem is computers don’t actually know what colors are. They operate on binary values alone, 1s and 0s, which at best can produce big numbers. To convert colors to numbers, the computer uses what is known as a color model.
00:54 Each tiny little pixel is a mix of these three colors, and by altering the intensity of each channel within the pixel, we can make that pixel appear to be any color that we can perceive. Turning up the intensity of each channel will result in white and turning it all the way down will give us a black pixel. With RGB images, each channel is often represented by 8 bits.
01:20 An 8-bit number can store any value from 0 to 255, which in this case, represents the intensity of that channel. We have three color channels, each requiring 8 bits, and so RGB color is also known as 24-bit color because 24 bits of data is needed to store the color of each pixel. In grayscale images, things are a bit smaller.
01:48 This is because we only have to worry about one value per pixel. Instead of having a value for each color channel, we have just a single value that represents the amount of light given off by the pixel.
Become a Member to join the conversation.