Thursday, February 10, 2011

Image is Everything

A few days ago a friend of mine had a question about editing a digital photograph. She was trying to change the DPI or Dots Per Inch of an image, and I did my best to explain why you can't change the DPI of an digital image because it doesn't have a DPI, but I think I wasn't very clear. At any rate, I decided that as a pennance I would write up something better.

At it's most basic, a Digital Picture is simply all the information needed to reproduce a picture. The term Pixel refers to all the little dots that make up a picture. When you have a grid of pixels, and each pixel has a specific color, you have a picture. Storing an image this way is called a bitmap because you're mapping the colors to the pixels using bits. One particular bitmap file format is Windows Bitmap, which has the file extension .bmp. These files are easy to work with, but tend to be very large. Another more popular bitmap file format is .jpg. jpegs are much smaller because the data inside them is compressed.

Suppose we have a picture that is 4 pixels wide and 2 pixels high with the following colors for the pixels:

The pixel at the 1st row and the 1st column is black.
The pixel at the 1st row and the 2nd column is green.
The pixel at the 1st row and the 3rd column is red.
The pixel at the 1st row and the 4th column is blue.
The pixel at the 2nd row and the 1st column is orange.
The pixel at the 2nd row and the 2nd column is yellow.
The pixel at the 2nd row and the 3rd column is purple.
The pixel at the 2nd row and the 4th column is green.

Those eight lines describing the locations (by row and column) and the colors of the pixels are a very rudimentary Digital Picture. Well, actually it's not exactly a digital since we didn't use numbers to identify the colors, but we'll forget about that for the moment.  Let's call the format of this image jigapic, and give all jigapic files the extension .jpc.  You can download the image file here (http://jigawatt.org/image0001.jpc). The jigapic format is not recognizable by any computer program, but any human can use it with a grid of pixels and reproduce the image. For example, I used Microsoft Excel to create the image below:







This grid of pixels is not very good. For one thing, the pixels are huge. For another, they are not square. And for yet another, there are black gridlines in between the pixels. But for our purposes here, this grid will work.

So notice the difference in the image file and the picture itself. The information in the file only says what colors go where. It doesn't care one bit about the pixels themselves. It doesn't even care if we're talking about drawing the image on a computer monitor, or with a printer, or with colored pencils on a piece of paper. We could even get pieces of colored paper and lay them out on the floor to construct the image. Our jigapic format only assumes that you'll have a rectuanglar grid of pixels with discernable rows and columns. (Displaying an image on this kind of grid is called Raster graphics for those who are interested).

In contrast, the picture itself is the pretty image we actually see, and it is very much dependent on the layout of the pixels in the grid. Here is where DPI comes in. Suppose the example image above is displayed as a 4 inch by 2 inch picture. Then, each pixel will 1 inch wide and 1 inch tall. Thus, the DPI (dots per inch) would be 1.


Well that's all for today. If there's any interest in this topic, I'll post some more. If not, thanks for your attention, and come back soon!

No comments: