Image CGT 511 Computer Images Bedřich Beneš, Ph.D. Purdue University Department of Computer Graphics Technology Is continuous 2D image function 2D intensity light function z=f(x,y) defined over a square 0 x,y 1 Continuous image is mathematical abstraction! Image the value of z can be: Digital Image Is a discretizationi i of a continuous image a single value I intensity of the light (grayscale) B 0/1 binary continuous image discrete image function z=i(x,y) a triplet an array RGB, CMY, HSV, HLS, etc. samples of spectrum a[256] x,y = 0,1, N, M, N x M the image resolution z can be the same as in the continuous case
Digital Image Discrete image a matrix picture elements pixels Pixel is determined by discrete coordinates e,g., [5, 3] and has some value z pixel Digitalization a process of making a continuous function discrete Examples: DVD, cell phone, computer image, video camera, tungsten fluorescent light ca e a, tu gste uo esce t g t It is a two step process 1 2 3 4 5 6 7 8 4 5 6 7 8 1 2 3 1) Sampling 2) Quantization Rasterization Process of finding the best pixels for a continuous object Examples: Bresenham s algorithm for lines and circles Digital Differential Analyzer for lines etc Pasteurization Pasteurization is the process of heating liquids for the purpose of destroying bacteria, protozoa, molds, and yeasts. The process was named after its creator, French chemist and microbiologist Louis Pasteur. Source: [Wikipedia]
Sampling Taking values of a continuous function in equally spread intervals Sampling frequency f how oftenthe the sample is taken continuous function samples f 1 x entire span has one value Sampling Error Decreasing the spatial resolution introduces Pixelization error It has much worse presence as alias (we will talk about it later) x Sampling Error Quantization is rounding a number to a defined value 5 e.g., 1.2 to 1; 1.4 to 1; 1.6 to 2; etc 4 Typically, it assigns a representative to 2 an interval 1 (do you remember the adaptive palette?) Original continuous values 6 3 5 4 3 2 1 0 0 New discrete values
Quantization Error Mach Band Effects Some information is lost The introduced error is called quantization error Audio quantization noise Images as Mach Band effects Ernst Mach 1938 1916 Mach Band Effects Computer Images 1) Raster images A raster image has given resolution and we (usually) cannot distinguish objects consists of pixels examples: TGA, JPG, GIF, TIF, PCX, BMP, PNG, etc. 16.7 millions, 256, 64, 32, 16, 4 colors
Computer Images 2) Vector a database of 2D objects image usually has NO resolution can be scaled to arbitrary size. examples: WMF (windows metafile), PS (postscript),clip Arts, Flash, PDF OCR Object recognition in pixels is a task of computer vision Very hard task Works well for clearly defined problems OCR (optical character recognition) converting scanned text into letters use semantic information ( he is rather than he ic ) Image Compression motivation How much space do we need for 5 minutes of uncompressed video? Answer: 25 fps, 768x524 pixels, RGB ~ 3 bytes/pixel 25[fps]*60[sec]*5[min]*768*524*3 [bytes]= =9 [Giga bytes] Compression Factor Compression factor is the ratio between compressed and uncompressed representation TGA has 0.25MB and the same file as JPEG has 51kbytes. Find thecompression factor. Solution compression factor is 51/250 = 0.204, i.e., JPEG takes 20% of the size
Compression Data is the mean by which the information is conveyed Data compression: reducing the amount of data required to represent given quantity of information Compression Data redundancy: data that is not carrying any new information "I was there only with John. We were two." (psycho visual redundancy) Data irrelevancy: Part of information that cannot be distinguished when missing Compression Two basic groups of compression algorithms Lossless (errorfree) decreases redundancy Lossy (non error free) decreases irrelevancy Lossless: 10 10 10 10 10 10 10 10 10 = 9 x 10 Lossy: 12 11 10 12 11 11 11 10 11 (approx. by) 11 11 11 11 11 11 11 11 11 = 9x11 Run Length Encoding (RLE) Idea: sequence of equal values is substituted by a pair [# of repetitions, number] 021111111122220000 can be written as 10 12 81 42 40 Compression factor 10/18 = 0.56
Run Length Encoding (RLE) Noisy sequence: 01010101 we get 10 11 10 11 10 11 10 11 Compression factor = 16/8 = 2 (!) This is called the negative compression Run Length Encoding (RLE) Solution: we define a special symbols ( and ) that denote beginning and ending of an uncompressed sequence 1212222222221212 = (121) 9 2 (1212) Compression factor = 13/16=0.8125 Run Length Encoding Summary Lossless (no error) good for cartoons, handwritings good for large areas of the same color bad fornoisy images used in compressed TGA, TIFF known since 1952, used in FAX machines 2D run length encoding also exists Lempel Ziv Welch (LZW) Idea: find themost frequented longest sequences and replace them by short ones so called dictionary based encoding
Lempel Ziv Welch (LZW) An alphabet {A, B, CC, XYZ} Sequence: 123457988123458777987712345(length=26) Make dictionary, find the coded sequence and get the compression factor. Lempel Ziv Welch (LZW) Dictionary: 12345= A 3x in the sequence 798 = B 2x in the sequence 77 = CC 2x in the sequence 8 = XYZ 1x Old sequence: 123457988123458777987712345 New seq.: A B XYZ A XYZ CC B CC A (length15) Compression factor = 15/26 = 0.5769 Lempel Ziv Welch (LZW) summary good for noisy images also good for large areas of the same color slow compression, fast decompression (asymmetric) complex algorithm used in GIF, TIFF, PNG also in ZIP, Compress, gzip, RAR, LHARC, ZOO very good compression technique lossless JPEG Joint Photographic Experts Group (ISO) it is lossy compression based on DCT (discrete cosine transform) fast and good compression always introduces artifacts Optimized is usually smaller Progressive (interlacing)
JPEG Adobe PostScript (PS) it is a page description language allows also inclusion of bitmaps communication language for printers textor binary format no internal compression but can be Original JPEG compression Adobe PostScript (PS) %!PS-Adobe-2.0 EPSF-2.0 %%BoundingBox: 63 266 549 526 %%Pages: 1 %%EndComments %%EndProlog %%Page: 1 1 % lower left corner 63 266 translate % size of image (on paper, in 1/72inch coords) 486.00000 259.9920099200 scale 486 260 8 % dimensions of data [486 0 0-260 0 260] % mapping matrix {currentfile pix readhexstring pop} Image fffffffffffffffffffffffffffffffffffffffffffffffffffff00000ffffff0000000fffff... showpage % stop using temporary dictionary end %%Trailer Summary continuous and discrete image digitalization sampling and quantization Pixelization and Mach band effect Compression factor RLE, LZW raster and vector images
Readings Rafael Gonzales, Richard Woods, Digital Image Processing, Addison Wesley Publishing, 1993, pages 307 > Peter Shirley et al, Fundamentals of Computer d Graphics 2 nd edition, pp 71 118