0% found this document useful (0 votes)
132 views10 pages

1.1.2 Images

The document discusses how digital images are represented in computers using pixels and binary numbers. Each pixel of an image is represented by a set of binary digits that indicate its color. More bits per pixel allow more possible colors but increase the file size. Image quality is affected by resolution, the number of pixels per inch. Common file formats like JPEG and GIF are described along with differences between raster images made of pixels and vector images represented mathematically.

Uploaded by

jubair baker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
132 views10 pages

1.1.2 Images

The document discusses how digital images are represented in computers using pixels and binary numbers. Each pixel of an image is represented by a set of binary digits that indicate its color. More bits per pixel allow more possible colors but increase the file size. Image quality is affected by resolution, the number of pixels per inch. Common file formats like JPEG and GIF are described along with differences between raster images made of pixels and vector images represented mathematically.

Uploaded by

jubair baker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

Representing images
Images also need to be converted into binary in order for a computer to process them so that they
can be seen on our screen. Digital images are made up of pixels. Each pixel in an image is made
up of binary numbers.

If we say that 1 is black (or on) and 0 is white (or off), then a simple black and white picture can be
created using binary.

R
To create the picture, a grid can be set out and the squares coloured (1 – black and 0 – white). But
before the grid can be created, the size of the grid needs be known. This data is
called metadata and computers need metadata to know the size of an image. If the metadata for

KU
the image to be created is 10x10, this means the picture will be 10 pixels across and 10 pixels down.
This example shows an image created in this way:

A
TH
Adding colour
ED

The system described so far is fine for black and white images, but most images need to use colours
as well. Instead of using just 0 and 1, using four possible numbers will allow an image to use four
colours. In binary this can be represented using two bits per pixel:
 00 – white
 01 – blue
HM

 10 – green
 11 – red

While this is still not a very large range of colours, adding another binary digit will double the number
of colours that are available:
 1 bit per pixel (0 or 1): two possible colours
 2 bits per pixel (00 to 11): four possible colours
 3 bits per pixel (000 to 111): eight possible colours
 4 bits per pixel (0000 – 1111): 16 possible colours
 …
A

 16 bits per pixel (0000 0000 0000 0000 – 1111 1111 1111 1111): over 65 0000 possible colours

The number of bits used to store each pixel is called the colour depth. Images with more colours
need more pixels to store each available colour. This means that images that use lots of colours are
stored in larger files.

Image quality
Image quality is affected by the resolution of the image. The resolution of an image is a way of
describing how tightly packed the pixels are.

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 1
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

In a low-resolution image, the pixels are larger so fewer are needed to fill the space. This results in
images that look blocky or pixelated. An image with a high resolution has more pixels, so it looks a
lot better when you zoom in or stretch it. The downside of having more pixels is that the file size will
be bigger.

IMAGE FILE FORMATS

R
Bitmaps

KU
A
A large part of using modern computers involves sending pictures and films to each other, along
TH
with using a graphical user interface. All of this involves computers saving and processing images.
This section will cover the two main image types: vector and bitmap, along with some compression
techniques.

Bitmap Graphics - a collection of pixels from an image mapped to specific memory locations holding
their binary colour value.

Pixel - the smallest possible addressable area defined by a solid colour, represented as binary, in an
ED

image.
HM

Resolution
 Image Resolution - how many pixels an image contains per inch/cm
A

 Screen Resolution - the number of pixels per row by the number of pixels per column

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 2
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

R
KU
Video Display Formats

A
TH
ED
HM
A

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 3
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

Calculating screen resolutions


Using the diagram above we are going to work out how many pixels are required to display a single
frame on a VGA screen.

Checking the resolution:


Height = 480
Width = 640
Area = Width * Height = Total Pixels

R
Area = 640 * 480 = 307200

Colour depth - The number of bits used to represent the colour of a single pixel

KU
Colour
1 bit 2 bit 4 bit
depth

A
Example TH
stores 4 colours:
Mono-chrome, only stores RGB(70,61,55), RGB(79,146,85)
Description Stores limited colours
black and white RGB(129,111,134),
RGB(149,146,166)
Number of
colours
ED

per pixel

Colour
8 bit 24 bit
depth
HM

Example

Description close to reality hard to see any difference between reality


A

Number of
colours
per pixel

It seems pretty obvious that the higher the colour depth, the closer the picture will look to reality.
Why then don't we just ramp up the colour depth on every image that we make? The answer should
be obvious, for a fixed resolution, the higher the colour depth, the larger the file size.

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 4
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

Calculating file size for different colour depths


All the images above are of the same resolution:
300*225 = 67500 pixels

If the first image uses 1 bit to store the colour for each pixel, then the image size would be:
Number of Pixels * Colour Depth = Image Size
67500 * 1 bit = 67500 bits

R
For the second image uses 2 bits to store the colour for each pixel, then the image size would be:
Number of Pixels * Colour Depth = Image Size
67500 * 2 bit = 135000 bits

KU
Vector graphics
Vector graphics are graphics in which the image is represented in a mathematical fashion. What
this allows one to do is to zoom in an image to infinite precision. They are ideal for situations in which
an image might be used at various resolutions and dimensions.

A
Raster graphics
Raster graphics are of a fixed dimension, somewhat like a grid pattern with specified values at each
point. These graphics are the default for things from the real world (IE, scanned images, photographs,
etc). They are ideal for use when an image will only be used once, and will never need to be
enlarged, or if portions are coming from a photograph or other real-world image.
TH
Differences between Raster(bitmaps) and vector graphics
ED
HM

 Vector images scale without file size increase / decrease


 Bitmap images scale resulting in file size increase / decrease
 Vector images scale without distortion to the image
 Bitmap images distort (pixellate) when scaling
 Bitmaps are better for photo editing

Bitmaps require less processing power to display


A

.GIF — Graphics Interchange Format


The most common image format on the Internet. Good for simple images. Read our Image File
Formats page for more. Your browser can display them, or any image editor.

.JPG/ .JPEG — Joint Photographic Experts Group file


Another very common image file format, mainly used for photos. Again, for more check out
the Image File Formats page. Your browser can show them, or an image editor.

Look at the following five photographs of the same car wheel:

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 5
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

R
KU
The resolution of the photographs is reduced from A to E. Photographs A and B are very sharp whilst
photograph D is very fuzzy and E is almost unrecognisable. This is the result of changing the number
of PIXELS per centimetre used to store the image (that is, reducing the PICTURE RESOLUTION).

When a photographic file undergoes file compression, the size of the file is reduced. The trade-off for
this reduced file size is reduced quality of the image. One of the file formats used to reduce
photographic file sizes is known as JPEG. This is another example of lossy file compression. As with

A
MP3 format, once the image is subjected to the jpeg compression algorithm, a new file is formed
and the original file can no longer be constructed. Jpeg will reduce the RAW BITMAP image by a
factor of between 5 and 15 depending on the quality of the original.

An image that is 2048 pixels wide and 1536 pixels high is equal to 2048 × 1536 pixels; in other words,
TH
3 145 728 pixels. This is often referred to as a 3-megapixel image (although it is obviously slightly larger).
A raw bitmap can often be referred to as a TIFF or BMP image (file extension .TIF or .BMP). The file size
of this image is determined by the number of pixels. In the previous example, a 3-megapixel image
would be 3 megapixels × 3 colours. In other words, 9 megabytes (each pixel occupies 3 bytes
because it is made up of the three main colours: red, green and blue). TIFF and BMP are the highest
image quality because, unlike jpeg, they are not in a compressed format. The same image stored in
jpeg format would probably occupy between 0.6 megabytes and 1.8 megabytes.
ED

Jpeg relies on certain properties of the human eye and, up to a point, a certain amount of file
compression can take place without any real loss of quality. The human eye is limited in its ability to
detect very slight differences in brightness and in colour hues. For example, some computer imaging
software boasts that it can produce over 40 million different colours – the human eye is only able to
differentiate about 10 million colours.
HM

.PNG — Portable Network Graphics


PNGs are a file format designed to be used in place of GIFs. They are usually slightly smaller, and
sport advanced features like alpha-channel transparency and 24-bit colour support. Read more
on our image formats page. Your browser can view them.

.TIFF — Tagged Image File Format


For really high quality images, TIFFs are used, but cannot be viewed through a browser.
Program: image editor.
A

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 6
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

Image File Header


The header is a section of binary- or ASCII-format data normally found at the beginning of the file,
containing information about the bitmap data found elsewhere in the file. All bitmap files have
some sort of header, although the format of the header and the information stored in it varies
considerably from format to format. Typically, a bitmap header is composed of fixed fields. None
of these fields is absolutely necessary, nor are they found in all formats, but this list is typical of those
formats in widespread use today. The following information is commonly found in a bitmap header:

R
Header

KU
Palette

Bitmap Index

Palette 1

File Identifier

A
File Version

Number of Lines per Image

Number of Pixels per Line


TH
Number of Bits per Pixel

Number of Color Planes

Compression Type

X Origin of Image
ED

Y Origin of Image

Text Description

Unused Space
HM

Later in this chapter we will present examples of headers from several actual formats, containing
fields similar to those presented above.

File Identifier
A header usually starts with some sort of unique identification value called a file identifier, file ID, or
ID value. Its purpose is to allow a software application to determine the format of the particular
graphics file being accessed.

ID values are often magic values in the sense that they are assigned arbitrarily by the creator of the
file format. They can be a series of ASCII characters, such as BM or GIF, or a 2- or 4-byte word
A

value, such as 4242h or 596aa695h, or any other pattern that made sense to the format creator.
The pattern is usually assumed to be unique, even across platforms, but this is not always the case,
as we describe in the next few paragraphs. Usually, if a value in the right place in a file matches
the expected identification value, the application reading the file header can assume that the
format of the image file is known.

Three circumstances arise, however, which make this less than a hard and fast rule. Some formats
omit the image file identifier, starting off with data that can change from file to file. In this case,
there is a small probability that the data will accidentally duplicate one of the magic values of
another file format known to the application. Fortunately, the chance of this occurring is remote.

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 7
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

The second circumstance can come about when a new format is created and the format creator
inadvertently duplicates, in whole or in part, the magic values of another format. In case this seems
even more unlikely than accidental duplication, rest assured that it has already happened several
times. Probably the chief cause is that, historically, programmers have borrowed ideas from other
platforms, secure in the belief that their efforts would be isolated behind the "Chinese Wall" of
binary incompatibility. In the past, confusion of formats with similar ID fields seldom came about
and was often resolved by context when it did happen. Obviously this naive approach by format

R
creators is no longer a survival skill. In the future, we can expect more problems of this sort as users,
through local area networking and through advances in regional and global interconnectivity,
gain access to data created on other platforms.

KU
This third circumstance comes about when a vendor--either the format creator or format caretaker
or a third party--changes, intentionally or unintentionally, the specification of the format, while
keeping the ID value specified in the format documentation. In this case, an application can
recognize the format, but be unable to read some or all of the data. If the idea of a vendor
creating intentional, undocumented changes seems unlikely, rest assured that this, too, has

A
already happened many times. Examples are the GIF, TIFF, and TGA file formats. In the case of the
GIF and TGA formats, vendors (not necessarily the format creators) have extended or altered the
formats to include new data types. In the case of TIFF, vendors have created and promulgated
what only can be described as convenience revisions, apparently designed to accommodate
coding errors or application program quirks.
TH
File Version
Following the identification value in the header is usually a field containing the file version. Naturally
enough, successive versions of bitmap formats may differ in characteristics such as header size,
bitmap data supported, and color capability. Once having verified the file format through the ID
value, an application will typically examine the version value to determine if it can handle the
image data contained in the file.
ED

Image Description Information


Next comes a series of fields that describe the image itself. As we will see, bitmaps are usually
organized, either physically or logically, into lines of pixels. The field designated number of lines per
image, also called the image length, image height, or number of scan lines, holds a value
corresponding to the number of lines making up the actual bitmap data. The number of pixels per
line, also called the image width or scan-line width, indicates the number of pixels stored in each
HM

line.

The number of bits per pixel indicates the size of the data needed to describe each pixel per color
plane. This may also be stored as the number of bytes per pixel, and is more properly called pixel
depth. Forgetting the exact interpretation of this field when coding format readers is a common
source of error. If the bitmap data is stored in a series of planes, the number of color planes
indicates the number of planes used. Often the value defaults to one. There is an increasing
tendency to store bitmaps in single-plane format, but multi-plane formats continue to be used in
support of special hardware and alternate color models.
A

The number of bits in a line of the image can be calculated by multiplying the values of number of
bits per pixel, number of pixels per line, and number of color planes together. We can determine
the number of bytes per scan line by then dividing the resulting product by eight. Note that there is
nothing requiring number of bits per pixel to be an integral number of 8-bit bytes.

Compression Type
If the format supports some sort of encoding designed to reduce the size of the bitmap data, then
a compression type field will be found in the header. Some formats support multiple compression
types, including raw or uncompressed data. Some format revisions consist mainly of additions or
changes to the compression scheme used. Data compression is an active field, and new types of

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 8
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

compression accommodating advances in technology appear with some regularity. TIFF is one of
the common formats which has exhibited this pattern in the past.

For more information about compression, see Chapter 9, Data Compression.

x and y Origins
x origin of image and y origin of image specify a coordinate pair that indicates where the image
starts on the output device. The most common origin pair is 0,0, which puts one corner of the

R
image at the origin point of the device. Changing these values normally causes the image to be
displayed at a different location when it is rendered.

KU
Most bitmap formats were designed with certain assumptions about the output device in mind,
and thus can be said to model either an actual or virtual device having a feature called the
drawing surface. The drawing surface has an implied origin, which defines the starting point of the
image, and an implied orientation, which defines the direction in which successive lines are drawn
as the output image is rendered. Various formats and display devices vary in the positioning of the
origin point and orientation direction. Many place the origin in the upper-left corner of the display

A
surface, although it can also appear in the center, or in the lower-left corner. Others, although this
is far less common, put it in the upper- or lower-right corner.

Orientation models with the origin in the upper-left corner are often said to have been created in
support of hardware, and there may be some historical and real-world justification for this. People
TH
with backgrounds in mathematics and the natural sciences, however, are used to having the
origin in the lower-left corner or in the center of the drawing surface. You might find yourself
guessing at the background of the format creator based on the implied origin and orientation
found in the format. Some formats include provisions for the specification of the origin and
orientation.

An image displayed by an application incorporating an incorrect assumption about the origin


point or orientation may appear upside down or backwards, or may be shifted horizontally some
ED

fraction of the width of the drawing surface on the output device.

Sometimes the header will contain a text description field, which is a comment section consisting
of ASCII data describing the name of the image, the name of the image file, the name of the
person who created the image, or the software application used to create it. This field may
contain 7-bit ASCII data, for portability of the header information across platforms.
HM

Unused Space
At the end of the header may be an unused field, sometimes referred to as padding, filler, reserved
space, or reserved fields. Reserved fields contain no data, are undocumented and unstructured
and essentially act as placeholders. All we know about them are their sizes and positions in the
header. Thus, if the format is altered at some future date to incorporate new data, the reserved
space can be used to describe the format or location of this data while still maintaining backward
compatibility with programs supporting older versions of the format. This is a common method used
to minimize version problems--creating an initial version based on a fixed header substantially
larger than necessary. New fields can then be added to reserved areas of the header in
A

subsequent revisions of the format without altering the size of the header.

Often format headers are intentionally padded using this method to 128, 256, or 512 bytes. This has
some implications for performance, particularly on older systems, and is designed to
accommodate common read and write buffer sizes. Padding may appear after the documented
fields at the end of the header, and this is sometimes an indication that the format creator had
performance and caching issues in mind when the format was created.

Reserved fields are sometimes only features left over from early working versions of the format,
unintentionally frozen into place when the format was released. A vendor will normally change or

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 9
9608
1.1 INFORMATION REPRESENTATION AHMED THAKUR

1.1.2 IMAGES

extend a file format only under duress, or as a rational response to market pressure typically
caused by an unanticipated advance in technology. In any case, the upgrade is almost always
unplanned. This usually means that a minimal amount of effort goes into shoehorning new data
into old formats. Often the first element sacrificed in the process is complete backward
compatibility with prior format versions.

R
KU
A
TH
ED
HM
A

COMPUTER SCIENCE https://www.facebook.com/groups/OAComputers/


[email protected], 0300-8268885 Page 10
9608

You might also like