Image Processing. Blending. Blending in OpenGL. Image Compositing. Blending Errors. Antialiasing Revisited Computer Graphics I Lecture 15

Similar documents
Image Processing Computer Graphics I Lecture 15

Image Processing. CSCI 420 Computer Graphics Lecture 22

Image Processing. Alpha Channel. Blending. Image Compositing. Blending Errors. Blending in OpenGL

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

IMAGE COMPRESSION. Image Compression. Why? Reducing transportation times Reducing file size. A two way event - compression and decompression

CS 432 Interactive Computer Graphics

Image coding and compression

Review Computer Graphics I Lecture 23

VC 12/13 T16 Video Compression

Digital Image Representation Image Compression

Topic 5 Image Compression

Lecture 5: Compression I. This Week s Schedule

15 Data Compression 2014/9/21. Objectives After studying this chapter, the student should be able to: 15-1 LOSSLESS COMPRESSION

Pixels and Buffers. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Features. Sequential encoding. Progressive encoding. Hierarchical encoding. Lossless encoding using a different strategy

Digital Image Processing

CS 335 Graphics and Multimedia. Image Compression

IMAGE COMPRESSION- I. Week VIII Feb /25/2003 Image Compression-I 1

Discrete Techniques. 11 th Week, Define a buffer by its spatial resolution (n m) and its depth (or precision) k, the number of

IMAGE PROCESSING (RRY025) LECTURE 13 IMAGE COMPRESSION - I

CMPT 365 Multimedia Systems. Media Compression - Image

Computer Graphics I Lecture 11

IMAGE COMPRESSION TECHNIQUES

Multimedia Systems Image III (Image Compression, JPEG) Mahdi Amiri April 2011 Sharif University of Technology

Graphics Hardware and Display Devices

Image Coding and Data Compression

Course Syllabus. Website Multimedia Systems, Overview

Image Coding and Compression

Compression; Error detection & correction

Mahdi Amiri. February Sharif University of Technology

IT Digital Image ProcessingVII Semester - Question Bank

7.5 Dictionary-based Coding

Video Compression An Introduction

Introduction ti to JPEG

06/12/2017. Image compression. Image compression. Image compression. Image compression. Coding redundancy: image 1 has four gray levels

Buffers, Textures, Compositing, and Blending. Overview. Buffers. David Carr Virtual Environments, Fundamentals Spring 2005 Based on Slides by E.

Index. 1. Motivation 2. Background 3. JPEG Compression The Discrete Cosine Transformation Quantization Coding 4. MPEG 5.

Lecture 8 JPEG Compression (Part 3)

Image Compression - An Overview Jagroop Singh 1

Image, video and audio coding concepts. Roadmap. Rationale. Stefan Alfredsson. (based on material by Johan Garcia)

DigiPoints Volume 1. Student Workbook. Module 8 Digital Compression

Lossy Coding 2 JPEG. Perceptual Image Coding. Discrete Cosine Transform JPEG. CS559 Lecture 9 JPEG, Raster Algorithms

Height Fields and Contours Scalar Fields Volume Rendering Vector Fields [Angel Ch. 12] April 23, 2002 Frank Pfenning Carnegie Mellon University

Visualization Computer Graphics I Lecture 20

COMP371 COMPUTER GRAPHICS

Operation of machine vision system

Compression II: Images (JPEG)

ECG782: Multidimensional Digital Signal Processing

Fundamentals of Video Compression. Video Compression

Lecture 8 JPEG Compression (Part 3)

7: Image Compression

Repetition 1st lecture

G64PMM - Lecture 3.2. Analogue vs Digital. Analogue Media. Graphics & Still Image Representation

PSD2B Digital Image Processing. Unit I -V

Output models Drawing Rasterization Color models

Professor Laurence S. Dooley. School of Computing and Communications Milton Keynes, UK

Wireless Communication

Babu Madhav Institute of Information Technology Years Integrated M.Sc.(IT)(Semester - 7)

Mesh Decimation Using VTK

IMAGE COMPRESSION. Chapter - 5 : (Basic)

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

CISC 7610 Lecture 3 Multimedia data and data formats

Computer Vision I - Basics of Image Processing Part 1

JPEG Compression. What is JPEG?

color bit depth dithered

Final Review. Image Processing CSE 166 Lecture 18

Data and information. Image Codning and Compression. Image compression and decompression. Definitions. Images can contain three types of redundancy

IMAGE COMPRESSION USING FOURIER TRANSFORMS

Compression; Error detection & correction

A COMPRESSION TECHNIQUES IN DIGITAL IMAGE PROCESSING - REVIEW

INF5063: Programming heterogeneous multi-core processors. September 17, 2010

CS443: Digital Imaging and Multimedia Binary Image Analysis. Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University

Compression Part 2 Lossy Image Compression (JPEG) Norm Zeck

Engineering Mathematics II Lecture 16 Compression

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

(Refer Slide Time 00:17) Welcome to the course on Digital Image Processing. (Refer Slide Time 00:22)

Lecture 6: Compression II. This Week s Schedule

3. (a) Prove any four properties of 2D Fourier Transform. (b) Determine the kernel coefficients of 2D Hadamard transforms for N=8.

EE67I Multimedia Communication Systems Lecture 4

Chapter 1. Digital Data Representation and Communication. Part 2

Image gradients and edges April 11 th, 2017

EE795: Computer Vision and Intelligent Systems

Image Compression Algorithm and JPEG Standard

Image gradients and edges April 10 th, 2018

Image Coding. Image Coding

Lecture 4: Image Processing

compression and coding ii

Filtering and Enhancing Images

Fundamentals of Multimedia. Lecture 5 Lossless Data Compression Variable Length Coding

DCT Based, Lossy Still Image Compression

( ) ; For N=1: g 1. g n

EUROPEAN COMPUTER DRIVING LICENCE / INTERNATIONAL COMPUTER DRIVING LICENCE IMAGE EDITING

Computer Vision 2. SS 18 Dr. Benjamin Guthier Professur für Bildverarbeitung. Computer Vision 2 Dr. Benjamin Guthier

EEM 463 Introduction to Image Processing. Week 3: Intensity Transformations

Previously... contour or image rendering in 2D

CHAPTER 1 Graphics Systems and Models 3

A Image Comparative Study using DCT, Fast Fourier, Wavelet Transforms and Huffman Algorithm

Image Pyramids and Applications

Introduction to Computer Science (I1100) Data Storage

Transcription:

15-462 Computer Graphics I Lecture 15 Image Processing Blending Display Color Models Filters Dithering Image Compression March 18, 23 Frank Pfenning Carnegie Mellon University http://www.cs.cmu.edu/~fp/courses/graphics/ Blending Frame buffer Simple color model: R, G, B; 8 bits each α-channel A, another 8 bits Alpha determines opacity, pixel-by-pixel α = 1: opaque α = : transparent Blend translucent objects during rendering Achieve other effects (e.g., shadows) 3/18/23 15-462 Graphics I 2 Image Compositing Compositing operation Source: s = [s r s g s b s a ] Destination: d = [d r d g d b d a ] b = [b r b g b b b a ] source blending factors c = [c r c g c b c a ] destination blending factors d = [b r s r + c r d r b g s g + c g d g b b s b + c b d b b a s a + c a d a ] Overlay n images with equal weight Set α-value for each pixel in each image to 1/n Source blending factor is α Destination blending factor is 1 Blending in OpenGL Enable blending glenable(gl_blend); Set up source and destination factors glblendfund(source_factor, dest_factor); Source and destination choices GL_ONE, GL_ZERO GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA 3/18/23 15-462 Graphics I 3 3/18/23 15-462 Graphics I 4 Blending Errors Operations are not commutative Operations are not idempotent Interaction with hidden-surface removal Polygon behind opaque one should be culled Translucent in front of others should be composited Solution: make z-buffer read-only for translucent polygons with gldepthmask(gl_false); Antialiasing Revisited Single-polygon case first Set α-value of each pixel to covered fraction Use destination factor of 1 α Use source factor of α This will blend background with foreground Overlaps can lead to blending errors 3/18/23 15-462 Graphics I 5 3/18/23 15-462 Graphics I 6 1

Antialiasing with Multiple Polygons Initially, background color C, α = Render first polygon; color C 1 fraction α 1 C d = (1 α 1 )C + α 1 C 1 α d = α 1 Render second polygon; assume fraction α 2 If no overlap (a), then Antialiasing with Overlap Now assume overlap (b) Average overlap is α 1 α 2 So α d = α 1 + α 2 α 1 α 2 Make front/back decision for color as usual C d = (1 α 2 )C d + α 2 C 2 α d = α 1 + α 2 3/18/23 15-462 Graphics I 7 3/18/23 15-462 Graphics I 8 Antialiasing in OpenGL Avoid explicit α-calculation in program Enable both smoothing and blending glenable(gl_point_smooth); glenable(gl_line_smooth); glenable(gl_blend); glblendfunc(gl_src_alpha, GL_ONE_MINUS_SRC_ALPHA); Outline Blending 3/18/23 15-462 Graphics I 9 3/18/23 15-462 Graphics I 1 Displays and Framebuffers Image stored in memory as 2D pixel array, called framebuffer Value of each pixel controls color Video hardware scans the framebuffer at 6Hz Depth of framebuffer is information per pixel 1 bit: black and white display (cf. Smithsonian) 8 bit: 256 colors at any given time via colormap 16 bit: 5, 6, 5 bits (R,G,B), 2 16 = 65,536 colors 24 bit: 8, 8, 8 bits (R,G,B), 2 24 = 16,777,216 colors Fewer Bits: Colormaps Colormaps typical for 8 bit framebuffer depth With screen 124 * 768 = 786432 =.75 MB Each pixel value is index into colormap Colormap is array of RGB values, 8 bits each All 2 24 colors can be represented Only 2 8 = 256 at a time Poor approximation of full color Who owns the colormap? Colormap hacks: affect image w/o changing framebuffer (only colormap) 3/18/23 15-462 Graphics I 11 3/18/23 15-462 Graphics I 12 2

More Bits: Graphics Hardware 24 bits: RGB + 8 bits: A (α-channel for opacity) + 16 bits: Z (for hidden-surface removal) * 2: double buffering for smooth animation = 96 bits For 124 * 768 screen: 9 MB Image Processing 2D generalization of signal processing Image as a two-dimensional signal Point processing: modify pixels independently Filtering: modify based on neighborhood Compositing: combine several images Image compression: space-efficient formats Other topics (not in this course) Image enhancement and restoration Computer vision 3/18/23 15-462 Graphics I 13 3/18/23 15-462 Graphics I 14 Outline Blending Point Processing Input: a(x,y); Output: b(x,y) = f(a(x,y)) Useful for contrast adjustment, false colors Examples for grayscale, v 1 f(v) = v (identity) f(v) = 1-v (negate image) f(v) = v p, p < 1 (brighten) f(v) = v p, p > 1 (darken) Gamma correction compensates monitor brightness loss f(v) v 3/18/23 15-462 Graphics I 15 3/18/23 15-462 Graphics I 16 Gamma Correction Example Signals and Filtering Audio recording is 1D signal: amplitude(t) Image is a 2D signal: color(x,y) Signals can be continuous or discrete Raster images are discrete In space: sampled in x, y In color: quantized in value Filtering: a mapping from signal to signal Γ = 1.; f(v) = v Γ =.5; f(v) = v 1/.5 = v 2 Γ = 2.5; f(v) = v 1/2.5 = v.4 3/18/23 15-462 Graphics I 17 3/18/23 15-462 Graphics I 18 3

Linear and Shift-Invariant Filters Linear with respect to input signal Shift-invariant with respect to parameter Convolution in 1D a(t) is input signal b(s) is output signal h(u) is filter Shorthand: b = a h ( = h a, as an aside) Convolution in 2D Filters with Finite Support Filter h(u,v) is except in given region Represent h in form of a matrix Example: 3 3 blurring filter As function In matrix form 3/18/23 15-462 Graphics I 19 3/18/23 15-462 Graphics I 2 Blurring Filters Average values of surrounding pixels Can be used for anti-aliasing Size of blurring filter should be odd What do we do at the edges and corners? For noise reduction, use median, not average Eliminates intensity spikes Non-linear filter Examples of Blurring Filter Pictures have been removed for printing purposes due to a PowerPoint bug Original Image Blur 3x3 mask Blur 7x7 mask 3/18/23 15-462 Graphics I 21 3/18/23 15-462 Graphics I 22 Example Noise Reduction Pictures have been removed for printing due to a PowerPoint bug Edge Filters Discover edges in image Characterized by large gradient Approximate square root Approximate partial derivatives, e.g. Original image Image with noise Median filter (5x5?) 3/18/23 15-462 Graphics I 23 3/18/23 15-462 Graphics I 24 4

Sobel Filter Edge detection filter, with some smoothing Approximate Sample Filter Computation Part of Sobel filter, detects vertical edges Sobel filter is non-linear Square and square root (more exact computation) Absolute value (faster computation) -1 1 1-2 2 4-1 1 h a 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 b 3/18/23 15-462 Graphics I 25 3/18/23 15-462 Graphics I 26 Example of Edge Filter Images have been removed due to a PowerPoint bug Outline Blending Original image Edge filter, then brightened 3/18/23 15-462 Graphics I 27 3/18/23 15-462 Graphics I 28 Dithering Compensates for lack of color resolution Give up spatial resolution for color resolution Eye does spatial averaging Black/white dithering to achieve gray scale Each pixel is black or white From far away, color determined by fraction of white For 3x3 block, 1 levels of gray scale Halftone Screens Regular patterns create some artefacts Avoid stripes Avoid isolated pixels (e.g. on laser printer) Monotonicity: keep pixels on at higher intensities Example of good 3 3 dithering matrix For intensity n, turn on pixels..n 1 3/18/23 15-462 Graphics I 29 3/18/23 15-462 Graphics I 3 5

Floyd-Steinberg Error Diffusion Approximation without fixed resolution loss Scan in raster order At each pixel, draw least error output value Divide error into 4 different fractions Add the error fractions into adjacent, unwritten pixels Floyd-Steinberg Example Gray Scale Ramp Some worms Some checkerboards Enhance edges Images have been removed due to a PowerPoint bug 7/16 3/16 5/16 1/16 3/18/23 15-462 Graphics I 31 Peter Anderson 3/18/23 15-462 Graphics I 32 Color Dithering Example: 8 bit framebuffer Set color map by dividing 8 bits into 3,3,2 for RGB Blue is deemphasized since we see it less well Dither RGB separately Works well with Floyd-Steinberg Assemble results into 8 bit index into colormap Generally looks good Outline Blending 3/18/23 15-462 Graphics I 33 3/18/23 15-462 Graphics I 34 Image Compression Some Image File Formats Exploit redundancy Coding: some pixel values more common Interpixel: adjacent pixels often similar JPEG Depth 24 File Size Small Comments Lossy compression Psychovisual: some color differences imperceptible Distinguish lossy and lossless methods TIFF GIF 8, 24 1, 4, 8 Medium Medium Good general purpose Popular, but 8 bit PPM 24 Big Easy to read/write EPS 1,2,4,8,24 Huge Good for printing 3/18/23 15-462 Graphics I 35 3/18/23 15-462 Graphics I 36 6

Image Sizes 124*124 at 24 bits uses 3 MB Encyclopedia Britannica at 3 pixels/inch and 1 bit/pixes requires 25 gigabytes (25K pages) 9 minute movie at 64x48, 24 bits per pixels, 24 frames per second requires 12 gigabytes Applications: HDTV, DVD, satellite image transmission, medial image processing, fax,... Exploiting Coding Redundancy Not limited to images (text, other digital info) Exploit nonuniform probabilities of symbols Entropy as measure of information content H = -Σ i Prob(s i ) log 2 (Prob(s i )) If source is independent random variable need H bits Idea: More frequent symbols get shorter code strings Best with high redundancy (= low entropy) Common algorithms Huffman coding LZW coding (gzip) 3/18/23 15-462 Graphics I 37 3/18/23 15-462 Graphics I 38 Huffman Coding Codebook is precomputed and static Use probability of each symbol to assign code Map symbol to code Store codebook and code sequence Precomputation is expensive What is symbol for image compression? Lempel-Ziv-Welch (LZW) Coding Compute codebook on the fly Fast compression and decompression Can tune various parameters Both Huffman and LZW are lossless 3/18/23 15-462 Graphics I 39 3/18/23 15-462 Graphics I 4 Exploiting Interpixel Redundancy Neighboring pixels are correlated Spatial methods for low-noise image Run-length coding: Alternate values and run-length Good if horizontal neighbors are same Can be 1D or 2D (e.g. used in fax standard) Quadtrees: Recursively subdivide until cells are constant color Region encoding: Represent boundary curves of color-constant regions Combine methods Not good on natural images directly Improving Noise Tolerance Predictive coding: Predict next pixel based on prior ones Output difference to actual Fractal image compression Describe image via recursive affine transformation Transform coding Exploit frequency domain Example: discrete cosine transform (DCT) Used in JPEG Transform coding for lossy compression 3/18/23 15-462 Graphics I 41 3/18/23 15-462 Graphics I 42 7

Discrete Cosine Transform Used for lossy compression (as in JPEG) JPEG (Joint Photographic Expert Group) Subdivide image into n n blocks (n = 8) Apply discrete cosine transform for each block Quantize, zig-zag order, run-length code coefficients Use variable length coding (e.g. Huffman) Many natural images can be compressed to 4 bits/pixels with little visible error Summary 8 bit (colormap), 24 bit, 96 bit Blur, edge detect, sharpen, despeckle Floyd-Steinberg error diffusion Coding, interpixel, psychovisual redundancy Lossless vs. lossy compression 3/18/23 15-462 Graphics I 43 3/18/23 15-462 Graphics I 44 Preview Assignment 5 due Thursday Assignment 6 out Thursday Thursday: Ray Tracing 3/18/23 15-462 Graphics I 45 8