Aliasing. Can t draw smooth lines on discrete raster device get staircased lines ( jaggies ):

Similar documents
Theoretically Perfect Sensor

Theoretically Perfect Sensor

Aliasing and Antialiasing. ITCS 4120/ Aliasing and Antialiasing

The main goal of Computer Graphics is to generate 2D images 2D images are continuous 2D functions (or signals)

Motivation. The main goal of Computer Graphics is to generate 2D images. 2D images are continuous 2D functions (or signals)

To Do. Advanced Computer Graphics. Sampling and Reconstruction. Outline. Sign up for Piazza

Advanced Computer Graphics. Aliasing. Matthias Teschner. Computer Science Department University of Freiburg

Image Filtering, Warping and Sampling

Sampling and Reconstruction

CS354 Computer Graphics Sampling and Aliasing

Lecture 6 Basic Signal Processing

Computer Graphics. Sampling Theory & Anti-Aliasing. Philipp Slusallek

Drawing a Triangle (and an introduction to sampling)

Computer Vision and Graphics (ee2031) Digital Image Processing I

Image Sampling and Quantisation

Lecture 5: Frequency Domain Transformations

Image Processing. Overview. Trade spatial resolution for intensity resolution Reduce visual artifacts due to quantization. Sampling and Reconstruction

Image Sampling & Quantisation

Sampling, Aliasing, & Mipmaps

Computer Graphics Geometry and Transform

28 SAMPLING. ALIASING AND ANTI-ALIASING

Fourier analysis and sampling theory

Aliasing And Anti-Aliasing Sampling and Reconstruction

Drawing a Triangle (and an Intro to Sampling)

Outline. Sampling and Reconstruction. Sampling and Reconstruction. Foundations of Computer Graphics (Fall 2012)

Outline. Foundations of Computer Graphics (Spring 2012)

Scaled representations

The simplest and most obvious method to go from a continuous to a discrete image is by point sampling,

Sampling, Aliasing, & Mipmaps

Computer Graphics. Texture Filtering & Sampling Theory. Hendrik Lensch. Computer Graphics WS07/08 Texturing

Filtering theory: Battling Aliasing with Antialiasing. Department of Computer Engineering Chalmers University of Technology

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

Image Processing, Warping, and Sampling

Sampling: Application to 2D Transformations

Sampling and Monte-Carlo Integration

Basics. Sampling and Reconstruction. Sampling and Reconstruction. Outline. (Spatial) Aliasing. Advanced Computer Graphics (Fall 2010)

An Intuitive Explanation of Fourier Theory

Lecture 4: Spatial Domain Transformations

Filtering theory: Battling Aliasing with Antialiasing. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Computational Aspects of MRI

Lecture 2: 2D Fourier transforms and applications

Noise Model. Important Noise Probability Density Functions (Cont.) Important Noise Probability Density Functions

convolution shift invariant linear system Fourier Transform Aliasing and sampling scale representation edge detection corner detection

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

Sampling, Aliasing, & Mipmaps

Biomedical Image Analysis. Spatial Filtering

Announcements. Image Matching! Source & Destination Images. Image Transformation 2/ 3/ 16. Compare a big image to a small image

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Texture. Outline. Image representations: spatial and frequency Fourier transform Frequency filtering Oriented pyramids Texture representation

Computer Vision. Fourier Transform. 20 January Copyright by NHL Hogeschool and Van de Loosdrecht Machine Vision BV All rights reserved

Optimised corrections for finite-difference modelling in two dimensions

Reading. 2. Fourier analysis and sampling theory. Required: Watt, Section 14.1 Recommended:

Dr Pavan Chakraborty IIIT-Allahabad

Biomedical Image Analysis. Point, Edge and Line Detection

CS 543: Computer Graphics. Rasterization

Sampling, Resampling, and Warping. COS 426, Spring 2014 Tom Funkhouser

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

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

Anti-aliasing and sampling

Prof. Feng Liu. Fall /25/2018

Section 10.1 Polar Coordinates

3. Image formation, Fourier analysis and CTF theory. Paula da Fonseca

Digital Image Processing. Lecture 6

Differential Geometry: Circle Patterns (Part 1) [Discrete Conformal Mappinngs via Circle Patterns. Kharevych, Springborn and Schröder]

Lecture 7: Most Common Edge Detectors

1 Affine and Projective Coordinate Notation

Computer Graphics Geometry and Transform

Math 26: Fall (part 1) The Unit Circle: Cosine and Sine (Evaluating Cosine and Sine, and The Pythagorean Identity)

Lecture 6: Edge Detection

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

Computer Vision I. Announcements. Fourier Tansform. Efficient Implementation. Edge and Corner Detection. CSE252A Lecture 13.

Sampling and Reconstruction

Unit 2: Trigonometry. This lesson is not covered in your workbook. It is a review of trigonometry topics from previous courses.

Homework #1. Displays, Image Processing, Affine Transformations, Hierarchical modeling, Projections

8/5/2012. Introduction. Transparency. Anti-Aliasing. Applications. Conclusions. Introduction

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

Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Fourier transforms and convolution

Edge detection. Gradient-based edge operators

Graphics and Interaction Transformation geometry and homogeneous coordinates

Homework #1. Displays, Image Processing, Affine Transformations, Hierarchical Modeling

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Homework #1. Displays, Alpha Compositing, Image Processing, Affine Transformations, Hierarchical Modeling

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Matrix Transformations. Affine Transformations

To Do. Advanced Computer Graphics. Discrete Convolution. Outline. Outline. Implementing Discrete Convolution

COMP371 COMPUTER GRAPHICS

CS1114 Assignment 5, Part 1

Image Metamorphosis By Affine Transformations

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Digital Image Processing. Prof. P. K. Biswas. Department of Electronic & Electrical Communication Engineering

Image Warping: A Review. Prof. George Wolberg Dept. of Computer Science City College of New York

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

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

Digital Signal Processing Lecture Notes 22 November 2010

Digital Image Processing. Image Enhancement in the Frequency Domain

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Image Acquisition + Histograms

Cecil Jones Academy Mathematics Fundamentals

Transcription:

(Anti)Aliasing and Image Manipulation for (y = 0; y < Size; y++) { for (x = 0; x < Size; x++) { Image[x][y] = 7 + 8 * sin((sqr(x Size) + SQR(y Size)) / 3.0); } } // Size = Size / ;

Aliasing Can t draw smooth lines on discrete raster device get staircased lines ( jaggies ): Images with too fine details create artifacts (Moire patterns) Why? How to solve? Aliasing - Center for Graphics and Geometric Computing, Technion

Antialiasing Aliasing - Center for Graphics and Geometric Computing, Technion 3

Antialiasing Aliasing - Center for Graphics and Geometric Computing, Technion 4

Sampling D raster image = discrete sampling of continuous image (signal) Consider D signal sampling Aliasing - Center for Graphics and Geometric Computing, Technion 5

Sampling D raster image = discrete sampling of continuous image (signal) Consider D signal sampling Aliasing - Center for Graphics and Geometric Computing, Technion 6

Sampling D raster image = discrete sampling of continuous image (signal) Consider D signal sampling Aliasing - Center for Graphics and Geometric Computing, Technion 7

Sampling D raster image = discrete sampling of continuous image (signal) Consider D signal sampling Aliasing - Center for Graphics and Geometric Computing, Technion 8

Sampling Theory in a Nutshell Terminology Cycle a repeated sequence over infinite signal Frequency number of cycles in a unit length Example sine wave Cycle = π Frequency = / π Aliasing - Center for Graphics and Geometric Computing, Technion 9

Sampling Theory Theorem: Any periodic signal can be represented as (infinite) sum of sine waves, at different frequencies Can represent signal using coefficients of the sine waves - alternative basis used by Fourier Analysis Fourier Transform- Tool to transform to/from sine basis, to/from the frequency domain Aliasing - Center for Graphics and Geometric Computing, Technion 0

Example A square wave is represented by infinite sum sin(3t) sin(5t) SqrWave( t) = sin( t) + + +... 3 5 First few components: Aliasing - Center for Graphics and Geometric Computing, Technion

Shannon Sampling Theorem Shannon Theorem: Any signal that is band-limited to frequency f max and sampled at equally spaced intervals smaller than t s = /(f max ) can be fully reconstructed The minimal sampling frequency of t s = /(f max ) is called the Nyquist frequency of the signal That this condition is necessary can be trivially shown: Question: What is the result of this sampling? Aliasing! Aliasing - Center for Graphics and Geometric Computing, Technion

More Aliasing Examples Sampling high frequency wave below Nyquist frequency yields results that look like a low frequency wave The appearance of high frequencies as low frequencies, due to sampling, is called Aliasing: Aliasing - Center for Graphics and Geometric Computing, Technion 3

Even More Aliasing Examples Consider two sine waves: -sin(3t) and sin(5t): -sin(3t) = sin(5t) is satisfied for t = π n / 4 Sampling sin(5t) at t i = π i / 4 looks like sampling sin(3t) Aliasing - Center for Graphics and Geometric Computing, Technion 4

Aliasing Aliasing the appearance of high frequencies as low frequencies To avoid Sample at a higher frequency - only if band-limited to begin with A-priori remove high frequencies Low pass filtering before sampling For images the discrete image is a sampling set of a continuous image (band limits?) Aliasing - Center for Graphics and Geometric Computing, Technion 5

The Fourier Transform Takes us from the spatial domain to the frequency domain: F( t) = f ( x) e itx dx The inverse Fourier transform equals f ( t) = F( x) π e itx dx We will see some examples shortly Aliasing - Center for Graphics and Geometric Computing, Technion 6

Convolution The convolution, denoted by *, is defined as: ( f * g)( x) = f ( t) g( x t) dt Question Question: What is the intuition behind the convolution operation? Theorem: Convolution in the spatial domain is the same as a multiplication in the frequency domain and vice-versa Aliasing - Center for Graphics and Geometric Computing, Technion 7

The Fourier Transform (cont d) Question: What is the Fourier transform of a hat? Aliasing - Center for Graphics and Geometric Computing, Technion 8

Convolution Consider an f max band-limited signal. Sampling is the same as multiplying the signal with equally spaced impulse functions δ(x): By the theorem, this operation is equivalent to a convolution in the frequency domain: Aliasing - Center for Graphics and Geometric Computing, Technion 9

Convolution (cont d) During the reconstruction process, we apply a low pass filter that removes all frequencies above f max This ideal filter is a box filter in the frequency domain: Samples that are less dense in the spatial domain will become more dense in the frequency domain Question: What will happen if we sample below the Nyquist limit Aliasing - Center for Graphics and Geometric Computing, Technion 0

We will get aliasing: Convolution (cont d) The different convolved elements, in the frequency domain, overlap. We have high frequencies intermixed with low frequencies and they are inseparable. The only way to prevent aliasing is pre-filtering Aliasing - Center for Graphics and Geometric Computing, Technion

Back to Computer Graphics Question: how all this sampling theory relates to computer graphics? When a discrete image I d (x,y) is created, we are effectively generating a sample set of a (possibly imaginary) continuous image I c (x,y) Extending sampling theory to two dimensions: I c (x,y) should be band-limited for it to be reconstructable Sampling should be above the Nyquist limit for I c (x,y) to be reconstructable The box filter in the frequency domain is the ideal low-pass filter (what is it in the spatial domain?) Aliasing - Center for Graphics and Geometric Computing, Technion

Back to Computer Graphics (cont d) Question: is I c (x,y) band-limited? Question: can we pre-filter I c (x,y)? One can reduce aliasing by super-sampling Question: can we post-filter the data using convolution with a sinc filter in the spatial domain? sin ( ) x + y x + y Aliasing - Center for Graphics and Geometric Computing, Technion 3

Sinc/Truncated sinc Box ) sin( y x y x + + and, y x 3 3 4 3 3 4 9 0 4 6 4 0 6 9 6 0 4 6 4 0 33 Common Filters Aliasing Aliasing - Center for Graphics and Geometric Computing, Technion Center for Graphics and Geometric Computing, Technion 4 Triangle (Hat) Guassian otherwise 0, + + otherwise 0,, y x y x 4 6 9 5 7 3 4 6 4 3 6 9 6 3 4 6 4 3 8 4 4 0 4 4 50 y x e + π

Common Filters (cont d) All filters are normalized so they sum to one. Why? Due to obvious reasons we cannot apply the infinite filters and must compromise on the truncated versions Note the sinc filter can assume negative values which is a potential for minor problems. Why? The difference between different filters are quite minor and most filters of size 4 4 offers similar improvements Aliasing - Center for Graphics and Geometric Computing, Technion 5

Filter results Unfiltered Box Gaussian Aliasing - Center for Graphics and Geometric Computing, Technion 6

Supersampling Example None 3x3 5x5 Aliasing - Center for Graphics and Geometric Computing, Technion 7

A Word on Temporal Aliasing So far we dealt with Spatial Aliasing In animation, aliasing could also occur between one frame and the next This aliasing is known as Temporal Aliasing Recall that in a movie each frame represents a finite time range of /5 or /30 of a second. Hence, it would serve better to accumulate the influence of moving objects over this time Aliasing - Center for Graphics and Geometric Computing, Technion 8

The technique of Motion Blur accumulates the affect of each object over the time step of the frame The result will look like the image on the right Playing animation with motion blur is more natural to the eye Motion Blur Aliasing - Center for Graphics and Geometric Computing, Technion 9

Image Manipulation Image operations Scaling Rotation Composition Scientific American, Feb 994 Aliasing - Center for Graphics and Geometric Computing, Technion 30

Image Scaling & Rotation Consider Linear Transformation L of image I: ImageLinTrans( I, L) clear I to background color For x from 0 to XMax(I) For y from 0 to YMax(I) I( L( x, y)) = I( x, y); What is wrong with this algorithm? Aliasing - Center for Graphics and Geometric Computing, Technion 3

Correct Image Scaling & Rotation Guarantee coverage iterate over target ImageLinTrans( I, L) clear For For I to background color x from 0 to I( x, y) = XMax(I) y from 0 to YMax(I) I( L ( x, y)); What can be wrong with this algorithm? Any reason to limit L to a linear transformations? Aliasing - Center for Graphics and Geometric Computing, Technion 3

Image Transformations Each pixel in the target image is computed from a single source pixel prone to Aliasing Solution in filtering A pixel in target image is some affine combination of several source pixels Coefficients based on area coverage Aliasing - Center for Graphics and Geometric Computing, Technion 33

Rotation By Shear Convenient for images as it involved only intra-row or intra-column operations Rotation can be performed by two shears can be lossy for large angles x cosθ = y sinθ Image size might be reduced in intermediate stage Rotation by three shears is lossless up to integer precision. cosθ sinθ 0 sinθ 0 = θ θ sinθ cosθ tan 0 tan Aliasing - Center for Graphics and Geometric Computing, Technion 34 sinθ x cosθ y

Image Composition + = Aliasing - Center for Graphics and Geometric Computing, Technion 35

Basic Method Composition ImageOverC ompose(, I clear I to background color For x from 0 to XMax(I) For y from 0 to YMax(I) if I ( x, y) = background I ( x, y) = I else I ( x, y) = I I ) ( x, y); ( x, y); color Will work until portion of foreground has background color Unfortunately we are facing more problems Aliasing - Center for Graphics and Geometric Computing, Technion 36

Composition (cont d) Question: This is the result of applying the basic algorithm to teapot-over-whitebackground. What is going on? Aliasing - Center for Graphics and Geometric Computing, Technion 37

Composition (cont d) The reason for this behavior could be found in the filtering (anti-aliasing) conducted during the rendering process On the boundary there exist pixels that are only partially covered by the teapot Rendered with black background, these boundary pixels are darker Yet, as dark as they are, they are not black and hence they are being copied verbatim Question: Any remedy? Aliasing - Center for Graphics and Geometric Computing, Technion 38

Composition (cont d) A background pixel has zero coverage while a pixel totally contained in the teapot s projection will have a coverage of one. This coverage information is also known as the Alpha channel that accompanies the RGB Question: How can we compute the Alpha channel? Question: How can we use the Alpha channel to resolve this boundary problem? Aliasing - Center for Graphics and Geometric Computing, Technion 39

Composition (cont d) T Teapot, S - Sand Over: Tα T + S( -α T ) Out: S( -α T ) In: Sα T Aliasing - Center for Graphics and Geometric Computing, Technion 40

Composition (cont d) Scientific American, Feb 994 Aliasing - Center for Graphics and Geometric Computing, Technion 4

Special Effects Chroma Key Aliasing - Center for Graphics and Geometric Computing, Technion 4

Special Effects Chroma Key II Aliasing - Center for Graphics and Geometric Computing, Technion 43

Special Effects No Blue Background Aliasing - Center for Graphics and Geometric Computing, Technion 44