Thursday, June 9, 2011

Image Processing

Most of you may have worked with Adobe Photoshop or Picknik or gimp or other image processing software.Ever wondered, what is the actual thing going on there or how an image gets processed, how it is turned to blur or how it is filtered or what are the principles behind RGB, Grey Scale etc., If you are one among the few who likes to know and want to do it programmatically, it is just a applying a few functions with openCV and this is the most basic necessity for which openCV is created.For today let's discuss theory and tommorrow we will do programming.These are the standard def's of some of the main terms used in image processing

Pixel - Stands for "Picture Element".It is the basic unit of an image, just like seconds for time

Binary image - These are the oldest formats of images and most of these are oblivion, since it contains only two colors "Black" and "White" and each pixel is of just one bit, if it is 0 --> black and if it's 1-->White

Grey Scale Image - This is normally referred to as Black and white image and it's pixel consists of 8bits.If all those are zeros, then it is black and if all those are ones, then it is white and in the between values you will see the variations of colors obtained by the intermixing of black and white.

Note : And important point to note here is that although Binary images should be called Black and White, they are not called so. Hence in your Black and White TV, or any Black and White image you take, mostly you will see a variation of black and white colors, which are not exactly white nor exactly black.Remember, these are grey scale images actually.

RGB Image - This is normally referred to as color image and it's pixel consists of 24 bits, 8bits for each of Red, Blue and Green.You must have already known that the intermixing of these primary colors produces almost all the colors.If all the 24 bits are ones, you get a white image and if all are black, you get a black image

Note : Ever wondered, when people talk about 16 million colors, it's very simple, taking all the 24 bits as unit (although internally divided), we can change each bit as either 0 or 1, that gives us 2^24 or 16 million colors. Take a look at the below picture

A photograph of Mohammed Alim Khan (1880-1944),Emir of Bukhara, taken in 1911 by Sergei Mikhailovich Prokudin-Gorskii using three exposures with red, green, and blue filters.  (Courtesy : Wikipedia)

The three pictures on the right side are black and white images, taken with red, green and blue filters, later on they are projected and combined to give a full color image.This was one of the earliest forms of taking color photographs

We normally when referring to the 8 bits, we don't use bit wise language which will be a bit confusing, and so we will be using 0 for all 0's and 256 for all 1's and between 0 and 256 for the remaining (Simply using the decimal format, instead of binary format)

Channel - Also called as component and this is the basic unit of pixel.The combination of 8bits is called a channel. So you can naturally say, that an RGB image is an 3 channelled image and Grey Scale image is an image with only one channel and generally we don't come across or discuss binary images at all, since bit wise representation is oblivion and it is generally ignored here and the rest of our journey with openCV.

Note : Although due to their bit representation, binary images are oblivion, they are not completely gone.Using heuristics you can easily note that for a grey scale image keeping a threshold (eg:127), you can convert all the pixels greater than threshold into 256 and all of them that are below to 0's, speaking in decimal language.But the actual binary representation is lost here.There is an openCV function CVthreshold(), to do this.See the documentation part you downloaded in the previous post.

This is it, take rest for today, but don't relax too much, because tommorrow it's going to be PROGRAMMING 

No comments:

Post a Comment