Concept of Pixel
Pixel
Pixel is the smallest element of an image. Each pixel correspond to any one value. In an 8-bit gray scale image, the value of the pixel between 0 and 255. The value of a pixel at any point correspond to the intensity of the light photons striking at that point. Each pixel store a value proportional to the light intensity at that particular location.
PEL
- A pixel is also known as PEL. You can have more understanding of the pixel from the pictures given below.
- In the above picture, there may be thousands of pixels, that together make up this image. We will zoom that image to the extent that we are able to see some pixels division. It is shown in the image below.

figure 1
Relationship with CCD array
- We have seen that how an image is formed in the CCD array. So a pixel can also be defined as
- The smallest division the CCD array is also known as pixel.
- Each division of CCD array contains the value against the intensity of the photon striking to it. This value can also be called as a pixel.
Calculation of total number of pixels
- We have define an image as a two dimensional signal or matrix. Then in that case the number of PEL would be equal to the number of rows multiply with number of columns.
- This can be mathematically represented as below:
- Total number of pixels = number of rows XX number of columns
- Or we can say that the number of x,y coordinate pairs make up the total number of pixels.
- We will look in more detail in the tutorial of image types, that how do we calculate the pixels in a color image.
Gray level
- The value of the pixel at any point denotes the intensity of image at that location, and that is also known as gray level.
- We will see in more detail about the value of the pixels in the image storage and bits per pixel tutorial, but for now we will just look at the concept of only one pixel value.
Pixel value 0.0
- As it has already been define in the beginning of this tutorial, that each pixel can have only one value and each value denotes the intensity of light at that point of the image.
- We will now look at a very unique value 0. The value 0 means absence of light. It means that 0 denotes dark, and it further means that when ever a pixel has a value of 0, it means at that point, black color would be formed.
- Have a look at this image matrix
0 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
- Now this image matrix has all filled up with 0. All the pixels have a value of 0. If we were to calculate the total number of pixels form this matrix, this is how we are going to do it.
- Total no of pixels = total no. of rows X total no. of columns = 3 X 3 = 9.
- It means that an image would be formed with 9 pixels, and that image would have a dimension of 3 rows and 3 column and most importantly that image would be black. The resulting image that would be made would be something like this
- Now why is this image all black. Because all the pixels in the image had a value of 0.
Concept of Bits per pixel
Bpp or bits per pixel denotes the number of bits per pixel. The number of different colors in an image is depends on the depth of color or bits per pixel.
Bits in mathematics:
Its just like playing with binary bits.
How many numbers can be represented by one bit. 0,1
How many two bits combinations can be made.
00,01,10,11
If we devise a formula for the calculation of total number of combinations that can be made from bit, it would be like this.
2^bpp
Where bpp denotes bits per pixel. Put 1 in the formula you get 2, put 2 in the formula, you get 4. It grows exponentially.
Number of different colors:
Now as we said it in the beginning, that the number of different colors depend on the number of bits per pixel.
The table for some of the bits and their color is given below.
Bits per pixel | Number of colors |
1 bpp | 2 colors |
2 bpp | 4 colors |
3 bpp | 8 colors |
4 bpp | 16 colors |
5 bpp | 32 colors |
6 bpp | 64 colors |
7 bpp | 128 colors |
8 bpp | 256 colors |
10 bpp | 1024 colors |
16 bpp | 65536 colors |
24 bpp | 16777216 colors 16.7millioncolors16.7millioncolors |
32 bpp | 4294967296 colors 4294millioncolors4294millioncolors |
This table shows different bits per pixel and the amount of color they contain.
Shades
You can easily notice the pattern of the exponentional growth. The famous gray scale image is of 8 bpp , means it has 256 different colors in it or 256 shades.
Shades can be represented as:
Color images are usually of the 24 bpp format, or 16 bpp.
We will see more about other color formats and image types in the tutorial of image types.
Color values:
We have previously seen in the tutorial of concept of pixel, that 0 pixel value denotes black color.
Black color:
Remember, 0 pixel value always denotes black color. But there is no fixed value that denotes white color.
White color:
The value that denotes white color can be calculated as :
In case of 1 bpp, 0 denotes black, and 1 denotes white.
In case 8 bpp, 0 denotes black, and 255 denotes white.
Gray color:
When you calculate the black and white color value, then you can calculate the pixel value of gray color.
Gray color is actually the mid point of black and white. That said,
In case of 8bpp, the pixel value that denotes gray color is 127 or 128bpp ifyoucountfrom1,notfrom0ifyoucountfrom1,notfrom0.
Image storage requirements
After the discussion of bits per pixel, now we have every thing that we need to calculate a size of an image.
Image size
The size of an image depends upon three things.
- Number of rows
- Number of columns
- Number of bits per pixel
The formula for calculating the size is given below.
Size of an image = rows * cols * bpp
It means that if you have an image, lets say the above figure 1:
Assuming it has 1024 rows and it has 1024 columns. And since it is a gray scale image, it has 256 different shades of gray or it has bits per pixel. Then putting these values in the formula, we get
Size of an image = rows * cols * bpp
= 1024 * 1024 * 8
= 8388608 bits.
But since its not a standard answer that we recognize, so will convert it into our format.
Converting it into bytes = 8388608 / 8 = 1048576 bytes.
Converting into kilo bytes = 1048576 / 1024 = 1024kb.
Converting into Mega bytes = 1024 / 1024 = 1 Mb.
Thats how an image size is calculated and it is stored. Now in the formula, if you are given the size of image and the bits per pixel, you can also calculate the rows and columns of the image