Expt1 Iplab
Expt1 Iplab
Contents
1. Introduction
2. Algorithm
3. Output Results
4. Discussion
5. References
INTRODUCTION
Bitmap or BMP files are quite old file formats used by the
”Windows” operating system. BMP images can range from 1 bit per
pixel (thus a black and white image) to 24 bits per pixel (providing
1.67 million colors). In the experiment we used an 8 bits per pixel
(Grayscale image) and 12 bits per pixel (RGB color image) formats
for operating upon. Following are two parts of a BMP file:
Header: It contains information about file and image. This part can
be broken into two parts:
(a) File Header, which contains general information related to the
file like type of the image file ( BM for the Bitmap file) and Size of
the file. Other fields are reserved and are not to be edited by the
user.
(b) Information Header( BITMAPINFOHEADER) , which contains
information about the image, like Width, Height and Bits per pixel
among other data
2. Image Data: It contains the pixel data or the color table
contents which are to be manipulated to transform the image. The
data starts from the address stored in the offset field of the
BITMAPINFOHEADER. It was observed that for grayscale images,
the offset was generally 1078, while for RGB color images it was 54.
The data is stored Bottom-to-Top and Left-to-Right, i.e. the data is
stored in rows which start filling at bottom first and then keep
filling to the top. The row size(in bytes) should be divisible by 4,
otherwise it should be padded with zeros such that the row size
become divisible by 4.
RowSize = [BitsPerPixel·ImageWidth+31/ 32 ]· 4
For flipping, contents are swapped about the diagonal of the
image data while, for the color to grayscale conversion, grayscale
value is calculated as,
Algorithm
● First, we read the input corn image file. Then we find the
information about the header.
● Since it is an 8-bit image then we allocate 256 x 4 size to the
extra variable to store the color table data.
● Then we call the write function and while writing the data from
extra we make one of the channels say Blue = 0 and store the
intensities of other channels as it is.
●Finally, we write the data in the final output image
“Cornupdated”.
Output Results
Part-1
Part-2
These are the following results when we give input file as
corn.bmp,cameraman.bmp,lena_coloured_256.bmp respectively
Part-3
These are the results when
Discussion
The BMP file format, also known as bitmap image file or device
independent bitmap (DIB) file format or simply a bitmap, is a
raster graphics image file format used to store bitmap digital
images, independently of the display device.
BMP file format is well defined, the file format consists of file
header, information header, and the pixel array. BMP file header
gives important information such as height, width, size, offset and
number of bits per pixel.
To set the intensity zero of any of the colors in the corn image we
have assigned value 0 to a particular column of a color table and
increased our pointer by 4 to reach the next element of the same
column.
Therefore, for output images we have used the same file header
and just altered the pixel array, rest of the file data has been copied
as it is.
References