Image Resizing Narbonic Shaenon Garrity http://www.narbonic.com Reminder no class next Tuesday, but your problem set is due. 9/19/08 Comp 665 Image Resizing 1
Magnifica/on = Reconstruc/on Conceptually (forward mapping) Up sample (needs not be an integer mulfple) Convolve with reconstrucfon filter Wasteful (lots of zeros) In PracFce (inverse mapping) Iterate over all pixels in the output range Accumulate reconstrucfon kernel contribufons at each pixel (finite extents help here) 9/19/08 Comp 665 Image Resizing 2
Illustra/on of Forward Mapping Foreach output pixel compute and accumulate contribufons due to just the relevant inputs Only helpful for reconstrucfon kernels with limited extents 9/19/08 Comp 665 Image Resizing 3
Box Filter Reconstruc/on Enlarges Pixels 9/19/08 Comp 665 Image Resizing 4
Linear Interpola/on Recall that a tent filter provided piecewise linear (planar in 2D) reconstrucfons Extent 2 pixels 9/19/08 Comp 665 Image Resizing 5
Sinc Reconstruc/on The ringing of the Ideal reconstrucfon filter dominates in magnificafon Extent infinite 9/19/08 Comp 665 Image Resizing 6
Gaussian Gaussian ReconstrucFon provides smoothness at the cost of exposing the pixel grid Extent infinite 9/19/08 Comp 665 Image Resizing 7
Tuned Gaussian If we are willing to further compromise on passing through the samples we can improve on Gaussian reconstrucfon, but this comes at the cost of increased blur and, even so, the pixel grid is sfll evident Extent infinite 9/19/08 Comp 665 Image Resizing 8
Raised Cosine A raised cosine reconstrucfon is both smooth and passes through the samples, but it sfll retains some high frequencies (pixelafon) arffacts Extent 2 pixels 9/19/08 Comp 665 Image Resizing 9
Piecewise Cubic Like a raised cosine, piecewise cubic reconstrucfons are smooth and pass through the given sample values. In fact, they are hard to disfnguish, but the cubic is slightly easier to compute. Extent 2 pixels 9/19/08 Comp 665 Image Resizing 10
Mitchell Netravali Cubics B = ⅓, C = ⅓ Other piecewise cubic filters tradeoff pixel grid arffacts with blur. This preferred version also approximates rather than interpolates sample values Extent 4 pixels 9/19/08 Comp 665 Image Resizing 11
Another Mitchell Netravali Filter B = 0, C = ½ This variant is less blurry, and interpolates (passes through) the samples, but the pixel arffacts are more apparent. Some people prefer its greater sharpness. Extent 4 pixels 9/19/08 Comp 665 Image Resizing 12
Example 9/19/08 Comp 665 Image Resizing 13
Side by Side Comparison These examples show a range of reconstrucfon arffacts. Note the differences in blur, evidence of the pixel grid, and afenuafon (approximafon) of samples Piecewise Linear Raised Cosine Mitchell-Netravali B=⅓, C= ⅓ 9/19/08 Comp 665 Image Resizing 14
Side by Side Comparison ReconstrucFon filter preference is also frequently content dependent Piecewise Linear Raised Cosine Mitchell-Netravali B=⅓, C= ⅓ 9/19/08 Comp 665 Image Resizing 15
Minifica/on = Filter & Sample Flip side: Reducing the size of an image We ve discussed sampling = MinificaFon is merely sampling followed by down sampling or decimafon (retaining only the sampled values) 9/19/08 Comp 665 Image Resizing 16
Sampling in the Fourier Domain Recall modulafon dual is convolufon = * = 9/19/08 Comp 665 Image Resizing 17
Pre Aliasing Problem Overlapping copies of spectrum make it impossible to recover a single original Thus, we can never fully recover the original Moreover, high frequencies from nearby copies add to the center one, introducing arffacts These arffacts, which look like blockiness or stair steps are called Aliasing What images can we can exactly reconstruct? 9/19/08 Comp 665 Image Resizing 18
Nyquist Sampling Criterion If a funcfon contains no frequencies higher than ω cycles over its input domain, it is completely determined by samples spaced 1/(2ω) apart. If the bandwidth of a signal is limited to ½ the sample frequency then its spectrums can not overlap and it can, in theory, be recovered without loss (assumes ideal reconstrucfon) But real world signals are not so well behaved, but we can filter them prior to sampling to minimize arffacts 9/19/08 Comp 665 Image Resizing 19
Prefiltering AnFaliasing requires filtering prior to sampling = 9/19/08 Comp 665 Image Resizing 20
Sample Filtered Image Recall modulafon dual is convolufon = * = 9/19/08 Comp 665 Image Resizing 21
PuMng it all together An image that is properly prefiltered also leads to befer reconstrucfons 9/19/08 Comp 665 Image Resizing 22
PuMng it all together And the choice of reconstrucfon filter is less crucial 9/19/08 Comp 665 Image Resizing 23
Prefiltering Compromises In theory, prefiltering, sampling, and reconstrucfon can be accomplished without signal loss, degradafon or arffacts. In pracfce, it is hard Ideal prefilters have infinite extent in the spafal domain Gibbs phenomenon suggests ringing at disconfnuifes (including image boundaries) Ideal reconstrucfon filters are also linear in extent SubopFmal filters tend to be either excessively blurry, or expose the underlying pixel structure 9/19/08 Comp 665 Image Resizing 24