Friday, September 29, 2006

How is a digital photo stored?

Just as the word digital suggests, a digital camera digitizes every image that it captures. What this means is that a typical rectangular photo is divided into a large number of squares which form the basic picture element called the pixel. Within a given pixel, the color of the image does not change. In the simple case where the pixel can either be black or white, the state of the pixel can be binary - either 0 (white) or 1 (black). The state of each pixel is stored at each location and when all the pixels are put together, you get your image back. Hence, the image is said to be digitized now.

In the real world, most pictures are stored either in color or in various layers of grey scale. For example, when each pixel element is stored as 8 bits, the number of states would be 256 - a number from 0 to 255. 0 represents white, 1 to 254 represents various scales of grey in increasing intensity, and 255 represents black. So when a color photo taken with a digital camera is converted to black and white, the correct term is actually a grey scale photo, because it has varying levels of black and white.

In color photographs, each pixel is made by combining various levels of primary colors. When an artist mixes colors with paints, he combines 2 colors to make a 3rd color. The primary colors are the colors which can combine to make all the colors required in a digital camera. In a typical camera, the primary colors used are Red, Green, and Blue (forming the RGB colors). Another set of primary colors used often are Cyan, Magenta, Yellow, and the Black (called the CMYK colors). Each color set has it's own advantages as it can capture a certain range of colors well. The rest of the post will be based on a RGB photo though it will equally apply to CMYK or any color set.

In the case of a RGB photo, each pixel uses up three storage units (for each color) of certain bit size associated with it. In the case of the 8-bit size storage unit, each pixel will have one storage unit each for intensity of red color (numbers 0 to 255 signifying varying levels of red color similar to the grey scale pictures discussed above), green color, and blue color. The various levels of red, green, and blue colors are mixed to form the actual color of that pixel. A picture stored in this manner would be 24-bit picture because each pixel would be stored in a 24-bit memory unit. The fact that the color of a pixel does not vary can be seen when you blow a picture beyond 100%. When the picture on the left is blown up to look at each pixel, the picture will look as the one on the right:



(Picture courtesy http://photo.net/equipment/digital/basics/)


The larger the resolution of the picture, the larger the number of pixels per inch (PPI). If one were to print a photo on paper, the resolution should be greater than 200 PPI on each side of the rectangle. A 3 MP camera can hence be used to print out photos of the 4" * 6" prints. The greater the resolution of the camera, the larger the size of the photo that can be printed out from it.

I will follow this post with a post on how the digital camera senses each photograph.

To get more information on this:
Photo.net's tutorial
Cambridge's tutorial

28 comments:

Prashanth said...

I was thrilled when I wrote a program to read a bitmap into an array to be manipulated. Image processing is a lot of fun! Hope you or someone else can write on DIP. Wavelet compression like JPEG is particularly cool... in fact, wavelets is a super topic by itself. If I learn wavelets I'll definitely make it a point to write on it.

Anonymous said...

cool. i appreciate this post, it also helps me understand some of the working of imaging s/ws we use all the time to make our figures.
looking forward to the follow-up post.

Sakshi said...

Nicely written. Enjoyed the links. Looking forward to the next bit.

Anonymous said...

* Usually, 240 pixels per inch is recommended for prints. The best resolution of the human eye is less than 300 pixels per inch -- so going beyond that wont gain you any more clarity. So, if you can print at 300ppi, well and good. Otherwise, a minimum of 240ppi is usually recommended. Note that printers usually have discrete settings for the ppi (180, 240, 300, 360, 600 etc) which once again is likely an artefact of the stepper motors within them... that would explain my 240ppi instead of b-a-l's 200 ppi!

* There is a significant difference between the RBG and CMYK coloring systems. CMYK is used in printers etc and works by removing the color of the dye from a white sheet of paper (which reflects all colors)-- so its called a subtractive scheme. RGB on the other hand works by adding colors from a zero background (additive scheme). Since a black dot output from a printer would require the most volume of color (C,M and Y each) to absorb all the components of white, a separate black ink cartridge is provided so that your color ink supplies dont run out fast! I dont know exactly why printers and magazine publishers use a CMYK scheme but I assume its because of the cost advantage.

* prashanth: wavelet coding is really very simple. indeed there is nothing more complicated to a DWT implementation than a convolution operation. So, go download the matlab wavelet package and give it a shot! There are plenty of matlab packages available from elsewhere too -- the stanford ones and ncar ones are good!

* Now, here is something to ponder about: Put a photograph on a scanner and it will be scanned all right. Now, put a negative and try to invert the image on your computer and you will get non-sense. Logically, a negative is the negative of a photo, right?! So why can't you scan it and negativate it to get the photo?

Well, of course, the first correct answer will get a lollypop free! (postage not included)

Born a Libran said...

@prashanth: You seem to know more about DIP than me... I would suggest that you blog about it rather than me...

@TGFI/Sakshi: Thanks :)

@bala: Thanks for the corrections/addendum. As I have told you earlier, you can be a part of the blog if you would like to. I didnt know about the printer settings and I am wondering how the book I was reading was wrong then. Dont know the answer to ur question either. Would appreciate the answer sometime soon :)

Prashanth said...

@Bala: Well, I'm sure its very easy to implement algorithms from a toolkit, but I really want to know the math behind wavelets for scale-free data processing on a different project.

I had to do a bit of research to answer your question, but I believe the answer is that the inverse to normal colour transform is logarithmic, not linear. I didn't spend the time to dig up exactly why this is so, but my guess is it has something to do with chemistry.

Anonymous said...

Get digital camera lens and professional video cameras at Megacameras.com

maths for fun said...

gurjar123
I like the article

maths for fun said...

gurjar123
I like the article

Viagra Online said...

so in this way work a digital camera, I read something about it but never with so good explanation, I knew it about the pixel system and the others functions, however I have my doubt about the rest of then.

Metro Ethernet said...

The post I just read I realize that's really interesting...
All the information that you have guys is of great benefic...

security camera system said...

Nice post. Digital camera now has made every one a good photographer.

xlpharmacy said...

Digital photos are the best one, I love take some ones with my new camera,I like take some animals and natural landscapes !

pay per head said...

Good article, read with great interest.

Anonymous said...

xanax for sale buy xanax montreal - can you overdose xanax bars

Anonymous said...

Heya i'm for the first time here. I came across this board and I find It really useful & it helped me out a lot. I'm
hoping to present something again and help others
such as you helped me.

My weblog: how to calculate bmr

Anonymous said...

Done it effectively, we were suffering with display printing
method for years. Now we could make it simple & own.

Thanks a whole lot.

Feel free to visit my weblog: chessok.com

Anonymous said...

Exists a means to alphabatize the tags once you obtain them typed?


Also visit my site ... cupcakesandcrinoline.com

Anonymous said...

Do you have any video of that? I'd like to find out more details.

Take a look at my page: TV from LG

Anonymous said...

though that should have a lot more closer focus and I'll manage them in separate blog posts: 3D printing, and mobile app.

My page xerox phaser 8560 driver ()

Anonymous said...

you are so hot.

Have a look at my blog post :: xerox phaser 8560 color printer

Anonymous said...

thats so hot!!! OOFFT.

Anonymous said...

HAVE A LOOK AT MY BLOG POST ON HAIR

Anonymous said...

HAIRRRRRRRRRRRRRRR

Anonymous said...

MY NAME IS FULLEY MULLEY. YOU MIGHT HAVE SEEN ME ON ANOTHER CAMERA WEBSITE.

Anonymous said...

I LIKE WEIGHTWATCHERS

Anonymous said...

ITS GREAT!

Anjaneyulu Batta said...

I understand about pixels and resolution.
Thanx.