Thursday, October 10, 2013

Image Processing Basics: Intensity

A digital image is nothing but an array of numbers. Every number represents intensity of corresponding pixel. We usually use 8 bits for storing intensity of a pixel i.e. we can store 0 - 255 discrete intensity values.

As we increase number of bits associated with each pixel total number of intensity levels increases and hence quality of the image. So a gray image which has only one type of intensity and has dimension NxM, will have size of 8*NxM bits or NxM bytes. Similarly a color image with 8 bit representation would consume 3*NxM bytes of memory space.

Typical range of N and M is around 1000~2000. As you can see with increase in every bit of the image representation, size of image increases significantly.

In this post we are going to discuss how to access elements of image using iterators.

But before that let's discuss few terms.

1) Iterators : Iterators are nothing but a way to access data from containers. C++ provides us a way to access elements from structures provided by standard template library like stack, queue and map. We are going to use iterators to access individual pixel of image.

2) typeof : typeof is a special keyword provided by c++ which returns type of current object.

Let's start with code.

Function saturate takes image, increase and channel no as an input.
As an output it generates new image with increased intensity for given channel.
Github : Gist

Result:

First one is the original image and the second one is output image. The dark part in output is because of overflow.






No comments:

Post a Comment