Digital computers store pictures as strings of binary values. The entire picture is divided into a number of pixels—the smallest elements of the picture. The colour and intensity values of each pixel are encoded and stored as a file. Additional information such as width and height of the image, resolution and size is stored along with the image data.
Using this program, a 24-bit bitmap image file can be converted into an 8-bit bitmap file. During this process, the colour information is lost, resulting in a greyscale image.
Bitmap file structure
Bitmap is a common file format used for storing images under Windows operating system. Bitmap files are stored with extension ‘.bmp.’ Hence these are also called ‘BMP files.’
Fig. 1 shows the main sections of a bitmap file. The file header is followed by the information header. If the image is indexed colour, the palette (colour table) follows. The image pixel data forms the last part.
The file header consists of a signature and offset, or starting address of the image data. The information header consists of image parameters like width, height, type of compression and resolution. A 24-bit BMP file usually does not have palette, but for an 8-bit BMP file palette is necessary. Image data contains the values of all pixels one by one.
The number of bits used to represent a pixel is called ‘pixel depth.’ An 8-bit BMP file uses only eight bits to represent a pixel, whereas a 24-bit BMP file uses 24 bits to represent a pixel. In 8-bit representation, the value 00 (hex) corresponds to black, and FF (hex) or 255 corresponds to white. That is, by convention, 0 is normally black and 255 is white. Values in between 0 and 255 represent various shades of grey.