100 likes | 111 Views
CPT 450 Computer Graphics. 8th Lecture – Intro to Bitmap or Raster Images. What is the difference between bitmap and vector graphics?. A bitmap or raster image is a collection of pixels (picture element), each with it’s own independent color.
E N D
CPT 450 Computer Graphics 8th Lecture – Intro to Bitmap or Raster Images
What is the difference between bitmap and vector graphics? • A bitmap or raster image is a collection of pixels (picture element), each with it’s own independent color. • A vector image is made up of vector graphics instructions such as drawLine or drawEllipse. • From vector to raster – scan conversion • From raster to vector – pattern recognition or OCR
Where do they come from? • Digital Cameras (now in cell phones) • Optical Scanners • Video • Fax • Medical Imaging (X-ray, CAT Scan, MRI) • Satellite data • Generated by scan converting vector graphics instructions
How are bitmap or raster images stored? • Generally, they are rectangular and can be stored in matrix form, as a table of colors. • In the old days, the pixels on the screen were directly mapped to the video memory and this could be addressed directly by the programmer. Convenient but dangerous. • The image files can contain a header and footer. This can contain the width and height of the image, the color depth, and other info about the picture.
Grayscale images • Only require on intensity per pixel, instead of 3 or 4 for color. • 8 bit can display 256 shades of gray. • Black and white only has two shades. (black or white) • Dithering – use can approximate shades of gray using a dithered black and white image. (like newsprint)
DIB and DDB • Bitmaps can be device dependant (DDB) or device independent (DIB) • Device dependant bitmaps contain color palette info, whereas DIB’s don’t. • The color palette is a lookup table that let’s the file size be smaller, but less total colors can be displayed.
Compression • Bitmap files can get large, so compression algorithms are used. • 2 types of compression algorithms: • Lossless, when uncompressed, the exact bitmap results • lossy. When uncompressed, an approximation to the original bits results.
More on Compression • Lossless algorithms • RLE – Run length encoding. Idea – replace AAAAAAAAAA with 10xA. • LZW Lempel-Ziv and Welch. Used by GIF files. Patent issue has expired. • Lossy methods • Example. JPEG compression. User adjustable compression factor.
Working with Bitmaps in GDI+ • Bitmap class. Derived from Image class. • Important Methods: • GetPixel(I, j) and SetPixel(i, j, color)