You are on page 1of 44

Department of Electrical and Electronic Engineering

Course: EE 4235
Subject: Digital Image Processing
Lecture 4
Image File Format

Edited and Presented by-


Dr. Mohiuddin Ahmad
Dept. of EEE, KUET, Khulna-9203,
Bangladesh
Contents of the Topic
❑ Computer Graphics
❑ Image file format
❑ Image Processing software
Computer Graphics
❑ “Computer graphics refers to using a computer to create or
manipulate any kind of picture, image, or diagram.”

❑ Typically you manipulate an image on your computer with


a graphics editing program
➢ MS Paint
➢ Adobe Photoshop
➢ Jasc Photoshop and Animation shop
➢ GNU Image Manipulation Program (GIMP)
• GIMP is a cross-platform image editor available for GNU/Linux,
OS X, Windows and more operating systems. It is free software,
you can change its source code and distribute your changes.
➢ etc.
Bitmapped Graphics
❑ There are two basic types of graphics:
➢ Bitmapped and
➢ Vector

❑ Bitmapped graphics are much more common, often


they are called raster graphics

❑ When you create a bitmapped graphic, you are


basically creating a bunch of colored dots
Bitmapped Graphics, cont.
❑ The bitmapped graphic is stored as an array of dots,
or pixels
❑ Each pixel gets assigned a specific color
❑ The more pixels you have, the more detailed the
image can be
➢ Imagine only have one pixel, all you get is a dot
❑ Some common bitmap graphics programs are:
➢ Photoshop
➢ Paint Shop Pro
➢ GIMP
➢ Photo-Paint
➢ Graphic Converter
❑ These are paint programs
Exaggerated Example of a Bitmap Image
Vector Graphics
❑ The second major type of computer graphics
❑ Vector graphics are created and manipulated using
drawing programs (as opposed to paint programs for
bitmapped graphics)
❑ Instead of using pixels to describe the image, it
describes the image using shapes
➢ Circles
➢ Lines
➢ Curves
❑ Also has to store the color of these shapes
❑ A verbal example would be something like:
➢ “A yellow circle with a center here and a radius of x, a purple
line from here to here”
Vector Graphics, cont.
❑The programs used with vector graphics are
drawing programs
❑Some of these programs include:
➢ Corel Draw
➢ Adobe Illustrator
➢ Acrobat
❑Most of these programs allow the use of
bitmapped images as part of a vector image
➢ Does not make them paint programs
➢ Bitmaps are a type of object (like a circle) that can
be inserted into a vector image
Bitmap vs. Vector Images
❑ Bitmap and vector images are obviously different
❑ Both have strengths and weaknesses
❑ They don’t manipulate images in the same way
❑ They don’t store images in the same way
➢ Vector images have some important advantages over
bitmap images. Vector images tend to be smaller than
bitmap images. That’s because a bitmap image has to
store color information for each individual pixel that forms
the image. A vector image just has to store the
mathematical formulas that make up the image, which
take up less space.
❑ The images are edited differently

What is the difference between bitmap and vector images? » Images » Windows » Tech Ease (usf.edu)
Bitmap Image
❑ Bitmap (or raster) images are stored as a series of tiny dots called pixels. Each pixel is
actually a very small square that is assigned a color, and then arranged in a pattern to
form the image. When you zoom in on a bitmap image you can see the individual
pixels that make up that image. Bitmap graphics can be edited by erasing or changing
the color of individual pixels using a program such as Adobe Photoshop.
Vector Image
❑ Unlike bitmaps, vector images are not based on pixel patterns, but instead
use mathematical formulas to draw lines and curves that can be combined
to create an image from geometric objects such as circles and polygons.
Vector images are edited by manipulating the lines and curves that make up
the image using a program such as Adobe Illustrator.
Comparison Table Between Bitmap and
Vector
❑ Comparison Table Between Bitmap and Vector (in Tabular
Form)
Parameter of
Bitmap Vector
Comparison

A type of graphics that are


A type of graphics that are
Definition made up of small elements
made up of lines and curves.
called pixels or pels.

.jpg, .gif, .png, .psd, .tiff,


Formats .ai, .svg, .ps, .eps, .svf
.pgm, .ppm

Elements It uses pixels. It uses geometric shapes.

Resizing the image affects its Resizing the image does not
Resolution
resolution. affect its resolution.

This type is suitable for This type is suitable for logos,


Suitable for
photographs. clip arts, and icons.

It can be edited using Adobe It can be edited using Adobe


Software program
Photoshop. Illustrator.

Comparatively larger than Comparatively less than bitmap


File Size
vector images. images.
Bitmap Images
❑ Very flexible
➢ Any image can be represented (with enough pixels)

❑ Created by scanners, digital cameras, and other


similar devices

❑ Used most commonly, especially on the web

❑ Can be displayed directly on your computer screen


if 1 image pixel is the same size as 1 screen pixel

❑ Takes a lot of memory


➢ The color of each pixel must be stored
➢ Can be compressed
Vector Images
❑ Easy to change parts of the image since each part is stored
as a different shape
❑ Can manipulate the image smoothly
➢ Rotating, changing color, size, line width, etc.
❑ Limited to the shapes the program can handle
❑ Typically takes less memory and disk space than a bitmap
❑ Must be converted to a bitmap to display
File Formats
❑ Once we’ve chosen which graphics format we’re
going to use now we have to select which file
format
❑ Each way of storing an image is called a file
format
❑ Each file format converts the image to a
corresponding string of bits differently in order
to store them on disk or transmit them over the
Internet
❑ It’s beyond the scope of this course to discuss
how these images are converted
❑ But, we will discuss the common file formats
File Formats, cont.
❑ Hopefully, you’re familiar with JPEG and GIF file formats
(at least in name only)

❑ You can’t just rename “somepicture.gif” to


“somepicture.jpg” and expect to get the desired result
➢ Can’t just rename a .doc file as .ppt and expect a
presentation out of it

❑ Images have to be converted from one file format to


another
Common File Formats

Bitmap Formats Vector Formats


❑ GIF: graphics interchange ❑ SVG : scalable vector
format graphics
❑ JPEG: joint photographic ❑ EPS: encapsulated postscript
experts group ❑ CMX: Corel meta exchange
❑ PNG: portable network ❑ PICT: Macintosh Picture
graphic ❑ WMF: Windows metafile
❑ BMP: Windows bitmap
❑ TIFF: tagged image file
format
How to Pick a File Format?
❑ Type: does the file format store the type of
image you want to use (bitmap or vector)?

❑ Portability: can other people use images in this


format?

❑ Color Depth: does the format support the


number of colors you need?

❑ Compression: can make the file smaller, but it


takes time to compress and decompress a file

❑ Transparency: do parts of your image need to


be transparent?
Color Depth
❑ Image formats will only allow a certain number of
different colors for each pixel
➢ Depends on the number of bits assigned to each pixel

❑ The format stores the level of each of the three


values for RGB to specify color

❑ R, G, and B are referred to as components


➢ Ex. “The red component”
❑ Bit depth describes the number of colors that can
be used in the image
Bit Depth
❑ 24-bit image allows you to specify up to 224
different colors in your image
➢ For each of the RGB values you can specify 28
different values (256 values)
• Remember in the color section RGB went from 0-255
➢ 28 values for R, for G, and for B gives us 224
different colors

❑ The “24” in 24-bit says how many bits it takes to


store a single color
Bit Depth cont.
❑ While most photos look good with 24-bit color, we
can have less than that
❑ 15-bit color can have 215 different colors with 25
possible values for each component
❑ 15-bit color is usually referred to as 16-bit color
➢ Use an extra bit for green (we’re more sensitive to
it)
Palettes
❑ If you have an 8-bit image, the palette will have 28 (256)
colors
➢ Each of the 256 colors in the palette come from the
possible 224 different colors in a 24-bit image

❑ A 1-bit image can have 21 (2) different colors


➢ Usually black and white
Colors vs. Image Size
❑ It’s nice to use as many colors as possible,
especially when dealing with photographs
❑ But, the more colors, the larger the image is to
store
➢ More information is required for each pixel
❑ Can work in 24-bit color then save the image
with fewer colors for storage or using online
Common Image File Formats
❑ Most of the types of file formats fall into the category of
bitmap images, for example:
➢ GIF (Graphic Interchange Format) -
➢ PNG (Portable Network Graphics)
➢ JPEG (Joint Photographic Experts Group)

➢ TIFF (Tagged Image File Format)


➢ FITS (Flexible Image Transport System)

➢ PBM (Portable Bit Map) format


➢ PGM (Portable Gray Map) format
➢ PNM (Portable aNy Map) format
File Format
❑ Header: characteristics of the image
➢ Size, color map, compression method, ……
❑ Data value:
➢ Pixel values, index values
❑ Common formats
➢ BMP, GIF, PNG, JPEG, TIFF ……
File Information
❑ PBM, PGM, and PPM files are all image file formats that hold
data in regards to pixels of an image. Compared to formats
like PNG, JPG, etc., these formats are very simplistic,
offering no compression. These are simple formats that store
the colors of pixels as bytes which can be read into your
program.

❑ There are three types:


• PBM (Portable BitMap) - 2 colors only. Black and White (0-1)
• PGM (Portable Gray Map) - 255 colors only. Black-Grey-
White (0-255)
• PPM (Portable PixMap) - 16,777,216 colors. Colored RGB (0-
255, 0-255, 0-255)
PPM
❑ A PPM file consists of two parts, a header and the
image data.
➢ The header consists of at least three parts normally
delineated by carriage returns and/or linefeeds but the
PPM specification only requires white space.
➢ The first "line" is a magic PPM identifier, it can be "P3" or
"P6" (not including the double quotes!).
➢ The next line consists of the width and height of the image
as ASCII numbers.
➢ The last part of the header gives the maximum value of
the color components for the pixels, this allows the format
to describe more than single byte (0..255) color values.
➢ In addition to the above required lines, a comment can be
placed anywhere with a "#" character, the comment
extends to the end of the line.
PPM
❑ A PPM file consists of two parts, a header and the image data.
❑ The following are all valid PPM headers.

❑ Header example 1 P6 1024 788 255

P6
1024 788
❑ Header example 2 # A comment
255

P3
❑ Header example 3 1024 # the image width
788 # the image height
# A comment
1023
PPM
❑ The format of the image data itself depends on the
magic PPM identifier. If it is "P3" then the image is given
as ASCII text, the numerical value of each pixel ranges
from 0 to the maximum value given in the header. The
lines should not be longer than 70 characters.

PPM example 4

P3
# example from the man page
44
15
0 0 0 0 0 0 0 0 0 15 0 15
0 0 0 0 15 7 0 0 0 0 0 0
0 0 0 0 0 0 0 15 7 0 0 0
15 0 15 0 0 0 0 0 0 0 0 0
PPM
❑ If the PPM magic identifier is "P6" then the image data is
stored in byte format, one byte per color component (r,
g, b). Comments can only occur before the last field of
the header and only one byte may appear after the last
header field, normally a carriage return or line feed. "P6"
image files are obviously smaller than "P3" and much
faster to read. Note that "P6" PPM files can only be used
for single byte colors.

❑ While not required by the format specification it is a


standard convention to store the image in top to bottom,
left to right order. Each pixel is stored as a byte, value 0
== black, value 255 == white. The components are
stored in the "usual" order, red - green - blue.
PPM Image
❑ Text image format

❑ This is a 3x2 image and it is a very small image. Here is what it


looks like when scaled up:
Breaking it down (PPM Text Format)
Breaking it down (PPM Text Format)
❑ A PPM file stores 3 numbers per pixel. The first is
the RED value, followed by the GREEN value, and then finally
the BLUE value.
❑ In relation to the data, let's color code it:

❑ Therefore, the first pixel has an RGB value of (255, 0, 0), which
is literally red. The second pixel has an RGB value of (0, 255, 0),
which is literally green. And so forth. Looking back at our image
above, that is pretty accurate.
Common Colors
❑ Here are some common colors you should know on the top of
your head:.
Name Red Green Blue Preview
Black 0 0 0
Gray 127 127 127
Red 255 0 0
Green 0 255 0
Blue 0 0 255
Yellow 255 255 0
Magenta 255 0 255
Cyan 0 255 255
White 255 255 255
PGM format
❑ A popular format for grayscale images (8 bits/pixel)
❑ Closely-related formats are:
➢ PBM (Portable Bitmap), for binary images (1 bit/pixel)
➢ PPM (Portable Pixelmap), for color images (24 bits/pixel)

ASCII or binary (raw) storage


PGM format
❑ PGM file
PBM
❑ PBM stores single bit pixel image as a series of ASCII "0" or
"1"'s. Traditionally "0" refers to white while "1" refers to
black. The header is identical to PPM and PGM format except
there is no third header line (the maximum pixel value
doesn't have any meaning. The magic identifier for PBM is
"P1".
❑ PBM example: Here is an example of a small bitmap in this
format, as with PPM files there can be no more than 70
characters per line.

P1
# PBM example
24 7
000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
011110011 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
010000010 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
011100011 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
010000010 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
010000011 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ASCII vs Raw/Binary format
❑ ASCII format has the following advantages:
➢ Pixel values can be examined or modified very easily
using a standard text editor.
➢ Files in raw format cannot be modified in this way since
they contain many unprintable characters.
❑ Raw format has the following advantages:
➢ It is much more compact compared to the ASCII format.
➢ Pixel values are coded using only a single character !
Text Format vs. Binary Format?
❑ Magic number and image format
Magic Number File Type Extension Type

P1 Portable BitMap PBM ASCII

P2 Portable GrayMap PGM ASCII

P3 Portable PixMap PPM ASCII

P4 Portable BitMap PBM Binary

P5 Portable GrayMap PGM Binary

P6 Portable PixMap PPM Binary

P7 Portable ArbitraryMap PAM Unknown

❑ you can clearly see that P3 is defined as a PPM file that is Text-
based (ASCII). However, there are other variants. P6 is the binary version
of PPM.
PGM
❑ This format is identical to the above except it stores greyscale
information, that is, one value per pixel instead of 3 (r,g,b). The
only difference in the header section is the magic identifiers
which are "P2" and "P5", these correspond to the ASCII and
binary form of the data respectively.
❑ PGM example: An example of a PGM file of type "P2" is given below

P2
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Image Processing Software
❑ Image processing software is software that is
designed to manipulate digital images.
❑ In particular, it captures the image if that hasn't already
been done, it converts it to a digital form, and it
performs a manipulation or manipulations on it. For
example, have you ever seen someone lighten a
photograph that was too dark? Or crop an image to
remove unwanted background clutter. These are
examples of image processing at work. Its purpose is
to improve the contents and quality of an image.
Image Processing Software
❑ What Types of Image Processing Software are Available?
❑ Some of the categories, or types, they fall into:
❑ Computer Graphics
➢ Computer graphics is one kind of image processing because it processes 2D and
3D image definition files rather than the resulting images themselves. It is a fine
point, but worthy of note.
➢ Examples include maps, posters, videos, and movies.
❑ Computer Vision
➢ This type focuses on processing that helps the software recognize objects within
the viewing area.
➢ For example, some factories use computer vision to determine if particular steps in
their process have been completed successfully.
❑ Medical Imaging
➢ This type focuses on processing that helps with issue detection and diagnosis.
➢ Examples include; Bioimaging (non-invasive visualization of biological processes)
and Neuroimaging (visualization of the nervous system).
❑ Photo Editing
➢ This type focuses on processing that helps improve photographs, like changing the
brightness, contrast, or color skew.
➢ For example, when you brighten an overly dark photograph or crop out
background clutter.
Image Processing Software

❑ What are Some Examples of Image Processing


Software?
❑ There is a lot of image processing software packages out there, too many to
enumerate here. Operating Systems like Windows, Mac OS, or Linux, install
two or three out of the box. But there are a few worth noting:
❑ Photoshop
➢ Photoshop is a general-purpose application designed to work on any raster-based
(made up of dots) image and perform any number of included manipulations. It is
one of the most popular image processing software packages available today.
❑ GIMP
➢ This is the official website of the GNU Image Manipulation Program (GIMP).
➢ GIMP is a cross-platform image editor available for GNU/Linux, OS X, Windows and
more operating systems. It is free software, you can change its source
code and distribute your changes.
❑ Whether you are a graphic designer, photographer, illustrator, or scientist,
GIMP provides you with sophisticated tools to get your job done. You can
further enhance your productivity with GIMP thanks to many customization
options and 3rd party plugins.
Image Processing Software

❑ CVIPtools (Computer Vision and Image Processing


tools)
❑ Intel Open Computer Vision Library - OpenCV
❑ Microsoft Visio SDL Library
❑ MATLAB
❑ etc.

Specification and Description Language (SDL)

You might also like