Professional Documents
Culture Documents
Information Representation
Information Representation
REPRESENTATION
CHAPTER 1
NUMBERS AND QUANTITIES
DECIMAL PREFIX AND BINARY PREFIX
ACTIVITY
Example : 011101
CONVERTING NEGATIVE NUMBER EXPRESSED IN 2’C TO CORRESPONDING DENARY
NUMBER
=-128 + 0 + 32 + 16 + 0 + 0 + 0 + 1
=-79
TASK
• Convert a negative number expressed in two’s complement
form to get corresponding denary number:
a. 1101011 b. 100101 c. 1101111 d. 1001001
EXAMPLE
• Lets take an example for two’s complement of negative number 5. (TASK 1.02)
Two’s complement (-5)= 1011
Take two’s complement of the binary number again to get the code for
positive number.
So, Two’s complement= 0101 (which is actually positive no, 0+4+0+1=5)
• Take two’s complement for of binary code and show that you get positive code.
a. -7 b. -41(7 bits) c. -6
BINARY ARITHMETIC
BINARY ADDITION BINARY SUBTRACTION
0+0=0 0-0=0
0+1=1 1-0=1
1+0=1 1-1=0
1+1= 0 WITH CARRY OVER 1
0-1= 1 WITH BORROW 1
1+1+1=1 WITH CARRY OVER 1
BINARY SUBTRACTION USING TWO’S
COMPLEMENT
• If a denary number with more than one digit is to be converted to BCD there has
to be a group of four bits for each denary digit.
• There are, however, two options for BCD:
1. To store one BCD code in one byte leaving 4 bits unused.(unpacked BCD)
2. The other option is packed BCD where two 4-bit codes are stored in one byte.
(packed)
BCD Code for denary number 2408
00100100 00001000
Packed BCD
• A widely used variation of the two-digits-per-byte encoding is called packed BCD (or simply
packed decimal), where numbers are stored with two decimal digits "packed" into one byte each,
and the last digit (or nibble) is used as a sign indicator.
• The preferred sign values are 1100 (hex C) for positive (+) and 1101 (hex D) for negative (−);
other allowed signs are 1010 (A) and 1110 (E) for positive and 1011 (B) for negative.
• Some implementations also provide unsigned BCD values with a sign nibble of 1111 (hex F).
• In packed BCD, the number +127 is represented as the bytes 00010010 01111100 (hex 12 7C),
and −127 as 00010010 01111101 (hex 12 7D).
ADVANTAGES OF BCD CODE
• The codes for numbers and for letters are in sequence in each case so that if 1
is added to the code for 7 the code for 8 is produced.
• The codes for the uppercase letters differ from the codes for the corresponding
lower case letters only in the value of bit 5. This makes the conversion of upper
case to lower case and vice versa easy.
IMAGES
1. Images can be stored in a computer system for displaying
on the screen or for presenting it on paper: created by using
an appropriate drawing package.
2. When an image already exists independently of the
computer system, the image can be captured by using
photography or by scanning.
VECTOR GRAPHICS( FOR GEOMETRICALLY DEFINED
SHAPES
1. An image that is created by a drawing package or a computer aided design (CAD) package to consist of a
number of geometric objects. The outcome is then usually for the image to be stored as a vector graphic file.
2. Vector graphic: a graphic consisting of components defined by geometric formulae and associated properties
such as line color and style.
3. We don’t need to consider how an image of this type is created here rather we need to know how the data is
stored after the image has been created.
4. a. A vector graphics file contains a drawing list.
b.The list contains a command for each object included in the image.
c.Each command has a list of attributes that define the properties of the object.
d.The properties include the basic geometric data such as , for circle, the position of the center and its
radius. The thickness, style of the line, the color of the line and the color that fills the shape.
5.The image is scalable.( the dimensions of the objects are not defined explicitly but instead are defined relative
to an imaginary drawing canvas.)
BITMAPS
• Most images do not consist of geometrically defined shapes so a vector graphic
representation is inappropriate.
• The general purpose approach is to store an image as a bitmap.
• The fundamental concept underlying the creation of a bitmap file is that picture element
(pixel) is the smallest identifiable component of a bitmap image.
• The image is stored as two dimensional matrix of pixels.
• The pixel itself is a very simple construct; it has a position in the matrix and it has a color.
WHAT IS THE DIFFERENCE BETWEEN
BITMAP AND VECTOR IMAGES?
• 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.
• 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.
Vector Vs Bitmap
• Vector images have some important advantages over bitmap images.
• A bit depth of 8 bits per primary color provides 256 × 256 × 256 =
16 777 216 different colors
• You can calculate the size of a bitmap graphic knowing the
resolution and the color depth.
RESOLUTION
• The following are considerations when justifying the use of either a bit map or a
vector graphic for a specific task.
• A vector graphic is chosen if a diagram is needed to be constructed for part of an
architectural, engineering or manufacturing design.
• If a vector graphic file has been created but there is a need to print a copy using a
laser or inkjet printer the file has first to be converted to a bitmap
. • A digital camera automatically produces a bitmap
. • A bitmap file is the choice for insertion of an image into a document, publication
or web page
FILE HEADER
• A bitmap file has to store the pixel data that defines the graphic, but the file must
also have a file header that contains information on how the graphic has been
constructed.
• Because of this, the bitmap file size is larger than the size of the graphic alone.
• At the very least the header will define the color depth or bit depth and the
resolution.
• Four binary digits count up to 15 (1111) but in BCD we only use the representations up
to 9 (1001). The difference between 15 and 9 is 6. If you want 9+1 to produce 10, which
is 1 0000, you have to add 6 to make 1010 wrap to 1 0000.
• If you're adding minutes, you similarly add 40 to a time which exceeds 59 minutes.
Example: 45 minutes plus 35 minutes is 80 minutes. Correction, add 40 to make 120.
Now insert a colon: 1:20. One hour, twenty minutes. 40 is the difference between 100
and 1:00.
SOUND REPRESENTATION
• To create digital music that sounds close to the real thing you need to look at the analogue
sound waves and try to represent them digitally.
• This requires you to try to replicate the analogue (and Continuous) waves as discrete
values.
• The first step in doing this is deciding how often you should sample the sound wave, if you
do it too little, the sample stored on a computer will sound very different from the one
being recorded.
• Sample too often and sound stored will resemble that being recorded. But having to store
each of the samples means you'll get very large file sizes. To decide how often you are
Sampling Theorem (NYQUIST'S THEOREM )
• If this variable uses eight bits, this means it can hold values from 0 to 255 (2^8 = 256).
• If this variable uses 16 bits, this means it can hold values from 0 to 65,535 (2^16 =
65,536). And so on.
FILE SIZES
• Sound file sizes if you wanted to record a 30 second voice message on your mobile phone you would use the
following:
Sample rate = 8,000hz
sample resolution = 16 bit
length of sound = 30 seconds
• Therefore the total file size would be:
8,000 * 16 * 30 = 3 840 000 bits = 480 000 bytes
COMPRESSION TECHNIQUE
• Lossless Compression
• Lossy Compression
LOSSY COMPRESSION
• Lossy compression removes some of a file’s original data in order to reduce the file size.
• This might mean reducing the numbers of colors in an image or reducing the number of
samples in a sound file.
• This can result in a small loss of quality of an image or sound file.
• JPEG for image and MP3 for sound.
• Once a file has been compressed using lossy compression, the discarded data cannot be
retrieved again
• Lossy compression reduces bits by identifying unnecessary information and removing it. The process
of reducing the size of a data file is referred to as data compression.
• Image compression may be lossy or lossless.
• Lossless compression is preferred for archival purposes and often for medical imaging, technical
drawings, clip art, or comics.
• If a file contains text, then compression must be lossless because any loss of information would lead
to errors in the text. .
• Lossy methods are especially suitable for natural images such as photographs in applications where
minor (sometimes imperceptible) loss of fidelity is acceptable to achieve a substantial reduction in bit
rate.
• The lossy compression that produces imperceptible differences may be called visually lossless.
• Lossy compression methods, especially when used at low bit rates, introduce compression artifacts
• Lossy eliminate less audible or meaningful sounds, thereby reducing the space required to store or
transmit them.
LOSS LESS COMPRESSION
• The idea is that compression converts sequences of the same byte value into a code
that defines the byte value and the number of times it is repeated (the count).
• For example, the sequence of the same four bytes:
01100110 01100110 01100110 01100110
could be replaced by:
00000100 01100110
Which says that there is a run of four of the bytes.
HUFFMAN CODING
• Instead of having each character coded in one byte, the text is analyzed to find the most often used
characters.
• These are then given shorter codes.
• The Huffman Code compression technique is used to create variable-length coding, which uses a
varied amount of bits for each letter or symbol.
• Huffman coding can also be used for compressing a sound file. This is effective because some
values for the amplitude occur far more often than others do.
• If a vector graphic file needs to be compressed it is best converted to a scalable vector graphics
format. This uses a markup language description of the image which is suitable for lossless
compression
DISCUSSION POINT