1.1.2 Images

advertisement
1.1 Information
Representation
1.1.2 Images
Bitmapped Image
• A rectangular grid built up from a number of PIXELS.
• Pixel - the smallest addressable picture element which
can be represented
• Each pixel will be a particular color
• Each pixel color is represented as binary pattern
• The content of the bitmap file will be a sequence of
binary colour codes.
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.
How data for a bitmapped image is encoded?
The letter 'a' might be
represented in a 12x14 matrix as
depicted in the 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.
Encodings for Bitmap image
Bitmap Encoding
Pixel Representation
Explanation
Monochrome
1 bit
Only two colors needed
(Black and white). 1 byte
can store 8 pixels
16 colour
4 bits
Each byte can store 2
pixels
256 colour
8 bits (1 byte)
Each byte stores one pixel
24-bit colour
24 bits (3 bytes)
The number of different
colours possible is 2^24
Binary Representation of Bitmap Image
• 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).
• This image could be represented by the following 35
binary digits (5 bytes):
00100 01010 01010 10001 11111 10001 00000
Binary Representation of Bitmap 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 1byte 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.
Estimating file size of bitmapped image of
different resolutions
How to compute bitmapped file size?
Vector Graphics
• Made up from a number of drawing objects
• Made from software like Corel Draw
• Objects are organized into groups of shapes
• Advantage: changing the size of any object will not affect the quantity
of the drawing appearance // the objects are scalable.
Applications of Bitmapped and Vector
graphics
• Bitmap images:
• Capture scanned images from a paper document
• Scan a photograph
• Vector images:
• General line – drawing diagrams
• Diagrams like flowcharts, OOP diagrams, network topologies
Worksheet