Aliasing, Image Sampling and Reconstruction
Total Page:16
File Type:pdf, Size:1020Kb
https://youtu.be/yr3ngmRuGUc Recall: a pixel is a point… Aliasing, Image Sampling • It is NOT a box, disc or teeny wee light and Reconstruction • It has no dimension • It occupies no area • It can have a coordinate • More than a point, it is a SAMPLE Many of the slides are taken from Thomas Funkhouser course slides and the rest from various sources over the web… Image Sampling Imaging devices area sample. • An image is a 2D rectilinear array of samples • In video camera the CCD Quantization due to limited intensity resolution array is an area integral Sampling due to limited spatial and temporal resolution over a pixel. • The eye: photoreceptors Intensity, I Pixels are infinitely small point samples J. Liang, D. R. Williams and D. Miller, "Supernormal vision and high- resolution retinal imaging through adaptive optics," J. Opt. Soc. Am. A 14, 2884- 2892 (1997) 1 Aliasing Good Old Aliasing Reconstruction artefact Sampling and Reconstruction Sampling Reconstruction Slide © Rosalee Nerheim-Wolfe 2 Sources of Error Aliasing (in general) • Intensity quantization • In general: Artifacts due to under-sampling or poor reconstruction Not enough intensity resolution • Specifically, in graphics: Spatial aliasing • Spatial aliasing Temporal aliasing Not enough spatial resolution • Temporal aliasing Not enough temporal resolution Under-sampling Figure 14.17 FvDFH Sampling & Aliasing Spatial Aliasing • Artifacts due to limited spatial resolution • Real world is continuous • The computer world is discrete • Mapping a continuous function to a discrete one is called sampling • Mapping a continuous variable to a discrete one is called quantizaion • To represent or render an image using a computer, we must both sample and quantize 3 Can be a serious problem… Spatial Aliasing • Artifacts due to limited spatial resolution Slide © Rosalee Nerheim-Wolfe “Jaggies” Aliasing Anti-aliasing 4 Spatial Aliasing Temporal Aliasing • Artifacts due to limited spatial resolution • Artifacts due to limited temporal resolution Strobing Flickering “Jaggies” Temporal Aliasing Temporal Aliasing • Artifacts due to limited temporal resolution • Artifacts due to limited temporal resolution Strobing Strobing Flickering Flickering 5 Temporal Aliasing Temporal Aliasing • Artifacts due to limited temporal resolution Strobing Flickering Staircasing or Jaggies …very serious problem! The raster aliasing effect – removal is called antialiasing Slide © Rosalee Nerheim-Wolfe Images by Don Mitchell 6 Sampling and artifacts Blurring doesn’t work well. Removed the jaggies, but also all the detail ! Reduction in resolution Unweighted Area Sampling Weighted Area Sampling 7 …with Overlap Sampling and Reconstruction Figure 19.9 FvDFH Antialiasing How is antialiasing done? • Sample at higher rate • We need some mathematical tools to Not always possible Doesn’t always solve problem analyse the situation. find an optimum solution. • Pre-filter to form bandlimited signal Form bandlimited function (low-pass filter) • Tools we will use : Trades aliasing for blurring Fourier transform. Convolution theory. Must consider Sampling theory. sampling theory! We need to understand the behavior of the signal in frequency domain 8 Spectral Analysis / Fourier Transforms Spectral Analysis / Fourier Transforms Note the Euler formula : eit cost isin t • Spectral representation treats the function as a weighted sum of sines and cosines F() f (x)eixdx Spatial domain Frequency domain. 1 • Every function has two representations f (x) F()eixd 2 Spatial (time) domain - normal representation Frequency domain - spectral representation • The Fourier transform converts between the spatial and frequency domain. • Real and imaginary components. • The Fourier transform converts between • Forward and reverse transforms very similar. the spatial and frequency domains. f(x) F() Sampling Theory Spectral Analysis • How many samples are required to represent a • Spatial domain: • Frequency domain: given signal without loss of information? Function: f(x) Function: F(u) Filtering: convolution Filtering: multiplication • What signals can be reconstructed without loss for a given sampling rate? Any signal can be written as a sum of periodic functions. 9 Fourier Transform Fourier Transform Figure 2.6 Wolberg Figure 2.5 Wolberg Sampling Theorem Convolution • A signal can be reconstructed from its samples, • Convolution of two functions (= filtering): if the original signal has no frequencies above 1/2 the sampling frequency - Shannon g(x) f (x) h(x) f ()h(x )d • The minimum sampling rate for bandlimited function is called “Nyquist rate” A signal is bandlimited if its highest frequency is bounded. The frequency is called the bandwidth. 10 Convolution in frequency domain is same as multiplication in spatial domain, and vice-versa f g F G F G f g Image Processing Antialiasing in Image Processing • Image processing is a resampling problem • General Strategy Pre-filter transformed image via convolution with low-pass filter to form bandlimited signal Resampling • Rationale Prefer blurring over aliasing 11 Filtering in the frequency domain Low-pass Filtering Frequency Image Filter Image domain Fourier Fourier Transform Transform Lowpass filter Highpass filter Low and High Pass Filtering. Low-pass Filtering • Low pass • High pass 12 Low-pass Filtering How can we represent sampling ? Multiplication of the sample with a regular train of delta functions. Sampling: Frequency domain. Sampling , the Comb function The Fourier transform of regular comb of delta functions is a comb. Spacing is inversely proportional Multiple solutions at regularly increasing values of f 13 Reconstruction in frequency domain Undersampling leads to aliasing. Original signal. Samples are too close Spurious components : Cause of aliasing. Bandpass filter due to regular array of pixels. The Sampling Theorem. Sampling at the Nyquist Frequency This result is known as the Sampling Theorem and is due to Claude Shannon who first discovered it in 1949 A signal can be reconstructed from its samples without loss of information, if the original signal has no frequencies above 1/2 the sampling frequency For a given bandlimited function, the rate at which it must be sampled is called the Nyquist Frequency 14 Aliasing in the frequency domain How do we remove aliasing ? • Perfect solution - prefilter with perfect bandpass filter. No aliasing. Aliased example Perfect bandpass Removing aliasing is called antialiasing How do we remove aliasing ? Adequate sampling • Perfect solution - prefilter with perfect bandpass filter. Difficult/Impossible to do in frequency domain. • Convolve with sinc function in space domain Optimal filter - better than area sampling. Sinc function is infinite !! Computationally expensive. 15 Inadequate sampling Pre-filtering The ‘Sinc’ function. The Sinc Filter 1 1/ 2 eix 2 square(x)eixdx eixdx 1 ix 1/ 2 2 1 1 1 i i sin e 2 e2 2 Recall Euler’s formula : 1 1 1 = sinc f i i eit cost i sin t 2 2 2 16 Common Filters Sample-and-Hold Image Reconstruction End… • Re-create continuous image from samples Example: cathode ray tube Image is reconstructed by displaying pixels with finite area (Gaussian) 17 Adjusting Brightness Adjusting Contrast • Simply scale pixel components • Compute mean luminance L for all pixels Must clamp to range (e.g., 0 to 255) luminance = 0.30*r + 0.59*g + 0.11*b • Scale deviation from L for each pixel component Must clamp to range (e.g., 0 to 255) L Original Brighter Original More Contrast Image Processing Adjust Blurriness • Quantization • Filtering • Convolve with a filter whose entries sum to one Each pixel becomes a weighted average of its neighbors Uniform Quantization Blur Random dither Detect edges Ordered dither • Warping Floyd-Steinberg dither Scale • Pixel operations Rotate Add random noise Warps Add luminance • Combining Original Blur Add contrast Morphs 1 2 1 Add saturation 16 16 16 Composite 2 4 2 Filter = 16 16 16 1 2 1 16 16 16 18 Edge Detection Image Processing • Convolve with a filter that finds differences • Quantization • Filtering between neighbor pixels Uniform Quantization Blur Random dither Detect edges Ordered dither • Warping Floyd-Steinberg dither Scale • Pixel operations Rotate Add random noise Warps Add luminance Original Detect edges • Combining Add contrast Morphs Add saturation 1 1 1 Composite Filter = 1 8 1 1 1 1 Scaling Summary • Resample with triangle or Gaussian filter • Image processing is a resampling problem Avoid aliasing Use filtering More on this next lecture! Original 1/4X 4X resolution resolution 19 Triangle Filter • Convolution with triangle filter • Convolution with Gaussian filter Figure 2.4 Wolberg 20.