5
M-Mushtaq Hussain Practical applications of BCD The BIOS in many personal computers stores the date and time in BCD Images How data for a bitmapped image is encoded? A bitmap images take the form of an array, where the value of each element, called a pixel picture element, correspond to the color of that portion of the image. Each horizontal line in the image is called a scan line. The letter 'a' might be represented in a 12x14 matrix as depicted in above Figure the values in the matrix depict the brightness of the pixels (picture elements). Larger values correspond to brighter areas whilst lower values are darker. Binary Representation of Bitmap Images All bitmap images are stored as an array of pixels. A monochrome bitmap will store a 1 for a black pixel and 0 for a white pixel (or vice-versa depending on the encoding protocol). Contact the teacher: 03215275281

Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

M-Mush

taq H

ussain

Practical applications of BCD

The BIOS in many personal computers stores the date and time in BCD

Images

How data for a bitmapped image is encoded?

A bitmap images take the form of an array, where the value of each element, called

a pixel picture element, correspond to the color of that portion of the image. Each

horizontal line in the image is called a scan line.

The letter 'a' might be represented in a 12x14 matrix as depicted in above Figure the

values in the matrix depict the brightness of the pixels (picture elements). Larger values

correspond to brighter areas whilst lower values are darker.

Binary Representation of Bitmap Images

All bitmap images are stored as an array of pixels. A monochrome bitmap will store a

1 for a black pixel and 0 for a white pixel (or vice-versa depending on the encoding

protocol).

Contact the teacher: 03215275281

Page 2: Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

M-Mush

taq H

ussain

This image could be represented by the following 35 binary digits (5 bytes):

00100 01010 01010 10001 11111 10001 00000

It would also be necessary to store the dimensions of the image.

If the image were in colour, using a colour palette of 256 possible shades, each pixel would need to translate to a value between 0 and 256 (8 bits). Thus we would need 35 bytes to store the image.

It is common for colours to be recorded by quantity or Red, Green and Blue (RGB) and this is stored using 3 bytes per pixel – so we would need 105 bytes to store the image. Bitmap images can be encoded in order to reduce the file size. Examples of encoded bitmaps in clued JPG, PNG and GIF file types.

Bitmap file header This block of bytes is at the start of the file and is used to identify the file. A typical

application reads this block first to ensure that the file is actually a BMP file and that it is

not damaged. The first two bytes of the BMP file format are the character 'B' then the

character 'M' in 1-byte ASCII encoding

The size value occupies 4 bytes by default. However, with the use of the 4 reserved

bytes, this value can occupy 8 bytes (64 bits) while still conforming to the BMP file

header format.

Estimating file size of bitmapped image of different resolutions

File size of a black white image

A black and white image has two dimensions that need to be considered the number of

pixels in the horizontal plane multiplied number of pixels along the vertical axis. Note

that a black and white image is not grey scale.

Example

The formula is:

File size = horizontal pixels × vertical pixels × bit depth

------------------------------------------- 8(to convert to bytes) × 1024 (kilobytes)

This image has the properties of 208 pixels wide by 182

pixels high. The file size in bits can then be worked out

by multiplying horizontal pixels by vertical pixels.

file size = 208 × 182 x 1

8 × 1024

= 37856

------ 8192 = 4.62 KB

Contact the teacher: 03215275281

Page 3: Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

M-Mush

taq H

ussain

Bit depth adds a third dimension

Bit depth plays a roll once colour is included and it is important to keep in mind that

colour includes shades of grey. Because the bit depth is no longer a 1 or a zero it plays

an important part in the formula.

Bit Depth

(Bits Per Pixel)

Number of

Colours

or Tones

Where do # of

Colours Come

From?

1 2 21=2

2 4 22=4

3 8 23=8

4 16 24=16

6 64 26=64

8 256 28=256

This grey scale image has 3 dimensions. Lets examine the properties of this image.

Remember that because this image is a gif the actual file size will be different to the

result in the formula.

The image is 200 pixels horizontal by 200 pixels vertical. Now we need to know the bit

depth. The bit depth of this image is 8.

File size = 200 × 200 × 8

----------------- 8 × 1024

= 320000

---------- 8192

=39 KB

Contact the teacher: 03215275281

Page 4: Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

M-Mush

taq H

ussain

Activity 2

1. Find an uncompressed image. Right click on the thumbnail of the image and click on

properties. Now click the summary tab. You now can find all the details you need to work out the file size of an image.

Calculating video size

The file size of an animation is simply a process of multiplying the number of frames by the

image size of each image.

image courtesy of Bettscomputers.com

Contact the teacher: 03215275281

Page 5: Hussain M-Mushtaq - Iteachiteach.pk/wp-content/uploads/2015/02/1.1.2-images.pdf · Hussain . This image could be represented by the. following 35 binary digits (5 bytes): 00100 01010

M-Mush

taq H

ussain

Calculating the total number of pixels in an image Resolution is often given in dots per inch e.g. an image is 72 dots per inch. This means

that there are 72 dots in each inch running horizontally, and 72 dots in each inch

running vertically. Therefore in the image below which is of 1 inch x 1 inch, there would

be 72 x 72 = 5184 pixels

FormulaNumber of pixels = image width x resolution x image height x resolution

ExampleCalculate the number of pixels in 4 inch by 5 inch photograph scanned which

has a resolution of 600 dots per inch.Pixels = 4 x 600 x 5 x 600 = 7,200,000

Calcluating colour depth The colour depth is the number of bits used to represent the colour of a single pixel.

1 bit can be used to represent 2 colours

2 bits can be used to represent 4 colours

3 bits can be used to represent 8 colours

4 bits can be used to represent 16 colours

Formula

Number of colours = 2bit depth

Example

Calculate the number of colours which can be represented using 16 bits

Colours = 216 = 65536

Contact the teacher: 03215275281