How does a computer read an image ?

 


  • Computers do not have any understanding of colors, they only understand numbers. 
  • A color model converts colors into numbers that a computer can process in turn.
  • RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value) are the most commonly used color models. 

If you are unaware of what these models are all about and how a computer actually reads an image, this post will make you familiar with those concepts.

When we see the above image we can easily say that it is an image of a car, even a six year old child won't have a doubt saying that it is an image of a car. But, what about computers, can computers actually see this image ? The answer is NO. 

Color Model 

A color model is an organized system for creating a wide variety of colors from a small variety of primary colors. It is an abstract mathematical model that describes how colors can be represented as numbers, usually as three or four values or color components.(Primary color components like RGB). The two most commonly used color models are RGB (Red, Green, Blue) and HSV (Hue, Saturation, Value) we will understand both the color models in this computer vision series in detail. For now let us understand how the images are read using the RGB (Red, Green, Blue) color model. 

The RGB Color Model

The RGB color model is a color model that adds three primary colors Red, Green and Blue in different permutations and combinations to form a broad array of colors. The name of the model is derived from the initials of the three primary color involved. 

Until this point we know that - 

  • Computers know only numbers. 
  • Color models can convert images into numbers. 
  • The RGB color model represents all the colored images as a combination of three primary colors, Red, Green and Blue  

So, what does computer actually see ? 

Computer see a matrix of numbers and, those numbers in the matrix range from 0 to 255. For an instance if an image is red colored, it will be represented as [255,0,0] likewise a green colored image will be represented as [0,255,0] and similarly a blue colored image will be represented as [0,0,255]. I hope now all of you might have got an idea on how color models are used to represent an image.

First and Foremost, for a colored image there will be three channels since in this post we are intended to understand the RGB model, the three channels in every colored image will be the Red channel, the Green channel and the Blue channel.

Secondly, there will be a matrix associated with each of these channels Red, Green and Blue and, each element of that matrix represent the potency of brightness of that pixel. All the three channels have their distinct matrices placed on top of each other forming a 3-dimenssional matrix. 

From here we have now got a clear idea that a computer interprets a colored image as a 3D-matrix. Likewise a black and white or a grayscale image there is only one channel.  


Now, when I say that the size of the above colored image 600x300 it means that there are 3 channels RGB (because it is a colored image) and there are 600 rows and 300 columns in the matrix corresponding to each color channel. 





For a black and white image there is only a single channel and therefore, it is interpreted as a 2D-matrix. For the above gray scale image, when I say that the size of the image is 600x300 it means that there are 600 rows and 300 columns and one single channel. So I hope I am clear on this now, that for black and white images there is only one channel and for colored images there are three channels popularly RGB. 

                                                                              ..... 

In this post, we learnt that computer only understands number, and so we need to convert images into numbers for the computers to be able to process them. There are different color models that help us converting and image into matrix of numbers. We understood the most commonly used color model the RGB model to convert the image into numeric representation. We saw that a colored image has three channels and that a grayscale image has one channel. In the next post we will have some practical hands-on and see how to actually read an image in a computer. 

Comments

  1. I found one successful example of this truth through this blog. I am going to use such information now.grayscale image converter

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Capture Images and Videos With Computer Webcam Using OpenCV in Python ? | Part 2

How to Capture Images and Videos With Computer Webcam Using OpenCV in Python ? | Part 1

Real Time Face Detection - OpenCV | Python