Table of Contents
Types of Images
There are many type of images , and we will look in detail about different types of images , and the color distribution in them.
- Binary Image
- Grayscale Image
- True color / RGB Image
- Indexed Image

The binary image
- The binary image as it name states , contain only two pixel values 0 and 1. Here 0 refers to black color and 1 refers to white color. It is also known as Monochrome.
- The resulting image that is formed hence consist of only black and white color and thus can also be called as Black and White image.
- One of the interesting this about this binary image that there is no gray level in it. Only two colors that are black and white are found in it.

Format
Binary images have a format of PBM Portable bit map
2 , 3 , 4 ,5 ,6 bit color format
- The images with a color format of 2 , 3 , 4 ,5 and 6 bit are not widely used today. They were used in old times for old TV displays , or monitor displays.
- But each of these colors have more then two gray levels , and hence has gray color unlike the binary image.
- In a 2 bit 4, in a 3 bit 8 , in a 4 bit 16, in a 5 bit 32, in a 6 bit 64 different colors are present.
8 bit color format
- 8 bit color format is one of the most famous image format. It has 256 different shades of colors in it. It is commonly known as Grayscale image.
- The range of the colors in 8 bit vary from 0-255. Where 0 stands for black , and 255 stands for white , and 127 stands for gray color.
- This format was used initially by early models of the operating systems UNIX and the early color Macintoshes.
Format
- The format of these images are PGM Portable Gray Map.
- This format is not supported by default from windows. In order to see gray scale image , we need to have an image viewer or image processing toolbox such as MATLAB.
Behind gray scale image:

- As we have explained it several times in the previous tutorials , that an image is nothing but a two dimensional function , and can be represented by a two dimensional array or matrix.
- So in the case of the image of Einstein shown above , there would be two dimensional matrix in behind with values ranging between 0 and 255. But that’s not the case with the color images.

16 bit color format
- It is a color image format. It has 65,536 different colors in it. It is also known as High color format.
- It has been used by Microsoft in their systems that support more then 8 bit color format. Now in this 16 bit format and the next format we are going to discuss which is a 24 bit format are both color format.
- The distribution of color in a color image is not as simple as it was in grayscale image.
- A 16 bit format is actually divided into three further formats which are Red , Green and Blue. The famous RGB format.
- It is pictorially represented in the image below.

- Now the question arises , that how would you distribute 16 into three. If you do it like this, 5 bits for R , 5 bits for G , 5 bits for B Then there is one bit remains in the end.
- So the distribution of 16 bit has been done like this. 5 bits for R , 6 bits for G , 5 bits for B.
- The additional bit that was left behind is added into the green bit. Because green is the color which is most soothing to eyes in all of these three colors.
- Note this is distribution is not followed by all the systems. Some have introduced an alpha channel in the 16 bit.
Another distribution of 16 bit format is like this:
- 4 bits for R , 4 bits for G , 4 bits for B , 4 bits for alpha channel.
- Or some distribute it like this 5 bits for R , 5 bits for G , 5 bits for B , 1 bits for alpha channel.


- An RGB color image is an M X N X 3 array of color pixels, where color pixel is a triplet corresponding to the red, green, and blue component RGB image at a specific spatial location. An RGB image viewed as a “stack” of three gray-scale images that, when fed into the red, green, and blue inputs of a color monitor, produce a color image on the screen.
- The data class of the component images determines their range of values. If an RGB image is of class double the range of values is [0, I]. Similarly, the range of values is [0, 255 or 0, 65535] for RGB images of class uint8 or uintl6. respectively.

Indexed Images
- An indexed image has two components: a data matrix of integers, X, and a color map matrix, map. Matrix map is an m X 3 array of class double containing floating point values in the range [0, 1].
- The length, m, of the map is equal to the number of colors it defines. Each row of map specifies the red, green and blue components of a single color. An indexed image uses ”direct mapping” of pixel intensity values to color map values.
- The color of each pixel is determined by using the corresponding value of integer matrix X as a pointer into map.
- If X is of class double then all of its components with values less than or equal to 1 point to the first row in map, all components with values 2 point to the second row, and so on.
- If X is class uint8 or uint16, then all components with value 0 point to the first row in map, all components with value 1 point to the second row, and so on.

- A colormap is stored with an indexed image and is automatically loaded with The image when function imread is used to load the image.
>> imread(X, Map)






How to add a constant to an Image
I = imread('rice.png');
J = imadd(I,50);
subplot(1,2,1);
imshow(I);
title('Original');
subplot(1,2,2);
imshow(J);
title('Constant added Image');

How to Subtract a constant to an Image
I = imread('rice.png');
J = imsubtract(I,50);
subplot(1,2,1);
imshow(I);
title('Original');
subplot(1,2,2);
imshow(J);
title('Constant subtracted Image');

How to Divide a constant to an Image
I = imread('rice.png');
J = imdivide(I,2);
subplot(1,2,1);
imshow(I);
title('Original');
subplot(1,2,2);
imshow(J);
title('Constant Divided Image');

Scale an Image by a constant factor
I = imread('rice.png');
J = immultiply(I,0.5);
subplot(1,2,1);
imshow(I);
title('Original');
subplot(1,2,2);
imshow(J);
title(‘Scaled Image by constant');
