Image transformations

Slides:



Advertisements
Similar presentations
Image Processing. Overview ImagesPixel Filters Neighborhood Filters Dithering.
Advertisements

Image Interpolation CS4670: Computer Vision Noah Snavely.
Ted Adelson’s checkerboard illusion. Motion illusion, rotating snakes.
Linear Filtering – Part II Selim Aksoy Department of Computer Engineering Bilkent University
Computational Photography CSE 590 Tamara Berg Filtering & Pyramids.
Filtering CSE P 576 Larry Zitnick
Interpolation Prof. Noah Snavely CS1114
Image Filtering, Part 2: Resampling Today’s readings Forsyth & Ponce, chapters Forsyth & Ponce –
Convolution, Edge Detection, Sampling : Computational Photography Alexei Efros, CMU, Fall 2006 Some slides from Steve Seitz.
Sampling and Pyramids : Rendering and Image Processing Alexei Efros …with lots of slides from Steve Seitz.
Edges and Scale Today’s reading Cipolla & Gee on edge detection (available online)Cipolla & Gee on edge detection Szeliski – From Sandlot ScienceSandlot.
Lecture 8: Geometric transformations CS4670: Computer Vision Noah Snavely.
Lecture 2: Edge detection and resampling
Image Warping : Computational Photography Alexei Efros, CMU, Fall 2005 Some slides from Steve Seitz
Image transformations, Part 2 Prof. Noah Snavely CS1114
Image Sampling Moire patterns
Lecture 3: Edge detection, continued
CSCE 641 Computer Graphics: Fourier Transform Jinxiang Chai.
Lecture 9: Image alignment CS4670: Computer Vision Noah Snavely
Lecture 4: Image Resampling CS4670: Computer Vision Noah Snavely.
Lecture 3: Image Resampling CS4670: Computer Vision Noah Snavely Nearest-neighbor interpolation Input image 3x upsample hq3x interpolation (ZSNES)
CPSC 641 Computer Graphics: Fourier Transform Jinxiang Chai.
Computational Photography: Fourier Transform Jinxiang Chai.
Slides from Alexei Efros, Steve Marschner Filters & fourier theory.
Image Sampling Moire patterns -
Computing transformations Prof. Noah Snavely CS1114
Fourier Analysis : Rendering and Image Processing Alexei Efros.
Image warping/morphing Digital Video Special Effects Fall /10/17 with slides by Y.Y. Chuang,Richard Szeliski, Steve Seitz and Alexei Efros.
Robust fitting Prof. Noah Snavely CS1114
Image Sampling CSE 455 Ali Farhadi Many slides from Steve Seitz and Larry Zitnick.
Interpolation, extrapolation, etc. Prof. Ramin Zabih
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5409 T-R 10:30am – 11:50am.
Applications of Image Filters Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/04/10.
Image Warping (Szeliski 3.6.1) cs129: Computational Photography James Hays, Brown, Fall 2012 Slides from Alexei Efros and Steve Seitz
Image Resampling CS4670: Computer Vision Noah Snavely.
Image Resampling CS4670: Computer Vision Noah Snavely.
Digital Image Processing Lecture 6: Image Geometry
Image Processing Edge detection Filtering: Noise suppresion.
Lecture 3: Edge detection CS4670/5670: Computer Vision Kavita Bala From Sandlot ScienceSandlot Science.
Interpolation Prof. Noah Snavely CS1114
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5403 T-R 3:00pm – 4:20pm.
Brent M. Dingle, Ph.D Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin - Stout Image Processing.
Lecture 5: Fourier and Pyramids
Projects Project 1a due this Friday Project 1b will go out on Friday to be done in pairs start looking for a partner now.
Last Lecture photomatix.com. Today Image Processing: from basic concepts to latest techniques Filtering Edge detection Re-sampling and aliasing Image.
Image Warping 2D Geometric Transformations
Arithmetic and Geometric Transformations (Chapter 2) CS474/674 – Prof. Bebis.
Image Resampling & Interpolation
Linear Filtering – Part II
Many slides from Steve Seitz and Larry Zitnick
Image Sampling Moire patterns
Lecture 7: Image alignment
Image transformations
Image Sampling Moire patterns
Recap from Friday Image Completion Synthesis Order Graph Cut Scene Completion.
More Image Manipulation
CSCE 643 Computer Vision: Thinking in Frequency
Samuel Cheng Slide credits: Noah Snavely
Image Processing Today’s readings For Monday
2D transformations (a.k.a. warping)
Filtering Part 2: Image Sampling
Linear filtering.
Image Sampling Moire patterns
Lecture 5: Resampling, Compositing, and Filtering Li Zhang Spring 2008
Oh, no, wait, sorry, I meant, welcome to the implementation of 20th-century science fiction literature, or a small part of it, where we will learn about.
Image Resampling & Interpolation
Resampling.
Samuel Cheng Slide credits: Noah Snavely
Image Stitching Linda Shapiro ECE/CSE 576.
Image Stitching Linda Shapiro ECE P 596.
Presentation transcript:

Image transformations Prof. Noah Snavely CS1114 http://www.cs.cornell.edu/courses/cs1114/

Administrivia

Last time: Interpolation

Nearest neighbor interpolation

Bilinear interpolation

Bicubic interpolation

(Matlab code available) Gray2Color http://www.cs.huji.ac.il/~yweiss/Colorization/ (Matlab code available)

Example algorithm that can’t exist Consider a compression algorithm, like zip Take a file F, produce a smaller version F’ Given F’, we can uncompress to recover F This is lossless compression, because we can “invert” it MP3, JPEG, MPEG, etc. are not lossless Claim: there is no such algorithm that always produces a smaller file F’ for every input file F

Proof of claim (by contradiction) Pick a file F, produce F’ by compression F’ is smaller than F, by assumption Now run compression on F’ Get an even smaller file, F’’ At the end, you’ve got a file with only a single byte (a number from 0 to 255) Yet by repeatedly uncompressing this you can eventually get F However, there are more than 256 different files F that you could start with!

Conclusions Some files will get larger if you compress them (usually files with random data) We can’t (always) correctly recover missing data using interpolation A low-res image can represent multiple high-res images

Extrapolation Suppose you only know the values f(1), f(2), f(3), f(4) of a function What is f(5)? This problem is called extrapolation Much harder than interpolation: what is outside the image? For the particular case of temporal data, extrapolation is called prediction (what will the value of MSFT stock be tomorrow?) If you have a good model, this can work well

Computed using a database of millions of photos Image extrapolation http://graphics.cs.cmu.edu/projects/scene-completion/ Computed using a database of millions of photos

Questions?

Today: image transformations

2D Transformations 2D Transformation: Examples: f(x, y) = (0.5x, 1.5y) Function from 2D  2D f(x, y) = (x’, y’) We’ll apply this function to every pixel to get a new pixel location Examples: f(x, y) = (0.5x, 1.5y) f(x, y) = (y, x)

2D Transformations f (x, y) = (0.5x, 2y)

2D Transformations f (x, y) = (y, x)

2D Transformations Can be non-linear:

image credit: Matt Brown 2D Transformations image credit: Matt Brown

Linear transformations We will focus on linear transformations 1D: f(x) = ax 2D: f(x, y) = (ax + by, cx + dy) Examples 1. f(x, y) = (0.5x, 1.5y) 2. f(x, y) = (y, x)

2D Linear Transformations Can be represented with a 2D matrix And applied to a point using matrix multiplication

2D Linear Transformations Can be represented with a 2D matrix

Examples f(x, y) = (0.5x, 1.5y) f(x, y) = (y, x)

Common linear transformations Uniform scaling:

Common linear transformations Rotation by angle θ

Common linear transformations Shear

Composing linear transformations What if we want to scale and rotate? Answer: multiply the matrices together scale rotation scale and rotation

Questions?

Implementing transformations First approach (grayscale image) function img_out = transform_image(img_in, T) [num_rows, num_cols] = size(img_in); img_out = zeros(num_rows, num_cols); for row = 1:num_rows for col = 1:num_cols p = [col; row]; p_new = T * p; img_out(p_new(2), p_new(1)) = img_in(row, col); end

Forward mapping

How do we fix this? Answer: do the opposite Create an output image For each pixel in the output image, find the corresponding pixel in the input image Give that output pixel the same color Requires that we invert the mapping

Inverse mapping How do we invert the mapping? With linear transformations T, we invert T

Inverse mapping

Resampling Suppose we scale image by 2 T = [ 2 0 ; 0 2 ] inv(T) = Pixel (5,5) in img_out should be colored with pixel (2.5, 2.5) in img_in How do we find the intensity at (2.5, 2.5)?

Inverse mapping

Downsampling Suppose we scale image by 0.25

Downsampling

What’s going on? Aliasing can arise when you sample a continuous signal or image Occurs when the sampling rate is not high enough to capture the detail in the image Can give you the wrong signal/image—an alias

Questions?

Image credit: Steve Seitz Examples of aliasing Wagon wheel effect Moiré patterns Image credit: Steve Seitz

This image is too big to fit on the screen This image is too big to fit on the screen. How can we create a half-sized version?

Image sub-sampling 1/8 1/4 Current approach: throw away every other row and column (subsample)

Image sub-sampling 1/2 1/4 (2x zoom) 1/8 (4x zoom)

2D example Good sampling Bad sampling

Image sub-sampling What’s really going on?

Subsampling with pre-filtering Average 2x2 Average 4x4 Average 8x8 Solution: blur the image, then subsample Filter size should double for each ½ size reduction.

Subsampling with pre-filtering Average 8x8 Average 4x4 Average 2x2 Solution: blur the image, then subsample Filter size should double for each ½ size reduction.

Compare with 1/8 1/4