The basics of images

When we say camera, we don't necessarily think of it as a sensor, even tough it is one. However, it is slightly different from all the sensors that we have studied until now. Most of the sensors are consisting of one sensing element such as proximity sensing, temperature sensing, or passive IR sensing. With a camera, what we are doing is capturing light; now, rather than having one light sensor, we have multiple, in fact an array of millions of these sensors grouped together on a single chip. But the story does not end here, and these sensors not only capture just light, but also different intensities of light; they can sense the color spectrum and its relative brightness. Every sensing element that does this functionality is named a pixel. Most of these pixels generate an RGB value, which is nothing but the intensity of red, green, and blue color. Why RGB, you might think? These are primary colors, and mixing these colors up in the right quantities results in making different shades of colors.

So, if we have a value of these colors, we can recreate the colors that we want. As we earlier understood, there are millions of these pixels in any camera, making up the length and the breadth of the image-sensing chip. The data from these image-sensing elements makes up the image. So far so good. But why are we talking about this? The reason is, this is how a camera sees the world and just to not how we see it. Biological vision is entirely a different story. So, we need to understand how the camera works and what the raw data that it gives is to go ahead and do the vision processing.

Now, let's get back to the pixels and their data. As there are millions of these pixels, there must be millions of readings of these pixels, and these readings would be in the form of RGB values. Now, this data must be arranged in a specific form so as to understand which pixel data we are dealing with. If it is not arranged, then none of this data would make any sense. 

As you learned previously, an array/list is the best way to store large, structured data, and if you look at the data from the image, then it is nothing but the values of RGB for individual structured pixels. Perfect! So, now we know what we are dealing with and how we have to deal with it. Or do we?

As you may recollect, the images we are talking about here are made by millions of pixels. So, the pixel data would also be in the magnitude of millions as well. This data is extremely huge, as we are not just talking about millions of pixels but each RGB value. In other words, every single pixel will give us three values, that is, the value of red, green, and blue. In other words, it's a lot of data. Normal lists cannot handle this much of data; hence, we have to install a special library named NumPy to take care of this vast arrays. In this chapter, there are multiple dependencies that we will have to install and update in order for the Raspberry Pi to go ahead and do vision processing. We will see how we will install it.

Now moving forward, we have the data of every single pixel in a very structured way, but what are we exactly going to do with it? Well as you have learned in the previous chapters, when we have data in a structured form, then we can go ahead and do multiple operations as we have done in the previous chapter of lists. The data we are dealing with here is somewhat in a specific domain. That is, we know that the data we would be receiving would be image data. Hence, there are certain very specific libraries that has been made to do the tasks with ease. One of the most commonly used vision processing algorithm is OpenCV. It is widely used, and there are multiple functions in this library that are very specific to dealing with image data itself. So with a single command, you should be able to capture image, and with another command, we would be able to put filters over the image. No not the Instagram filters, but the filters that will segregate a specific type of object in the image from others.

Finally, we would also be able to output the data in the desired image format. So, it is quite interesting on what all we can do with OpenCV. But do keep in mind that this is an introductory lesson. OpenCV itself can be a topic for an entire book, but here, I'm trying to give you all a heads-up regarding the vision processing. You would be learning the basic commands and how to use it to make out projects.

Now it is time to stop talking and start doing stuff. So, let's see what all we have to do.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.174