We represent an image in a digital computer by a matrix of pixels (picture element). For an image containing only two colors (possibly black and white), the pixel can be a bi-level (Boolean) field with true (1) meaning white, and false (0) meaning black. One of the file formats for representing this kind of image is the PBM (Portable Bit Map) file format. In this file format, each pixel is represented by one bit. If the image is of size WIDTH * HEIGHT
, then each row is WIDTH
bits, packing eight pixels into a byte, with don't care bits to fill out the last byte in the row. There are HEIGHT
number of such rows.
Now let's consider a gray scale image. The number of distinct gray scale values that can be represented by a pixel depends on the number of Bits Per Pixel (bpp). For 8 bpp, 256 gray scale values can be represented. In this case, pixel values can vary from 0
to 255
. These pixel values are often referred to as pixel intensity levels. So a pixel may be represented as...