Computer Vision Jia-Bin Huang, Virginia Tech

Slides:



Advertisements
Similar presentations
CSCE 643 Computer Vision: Template Matching, Image Pyramids and Denoising Jinxiang Chai.
Advertisements

Motion illusion, rotating snakes. Slide credit Fei Fei Li.
Multiscale Analysis of Images Gilad Lerman Math 5467 (stealing slides from Gonzalez & Woods, and Efros)
Image Interpolation CS4670: Computer Vision Noah Snavely.
Ted Adelson’s checkerboard illusion. Motion illusion, rotating snakes.
CS 691 Computational Photography
Computational Photography CSE 590 Tamara Berg Filtering & Pyramids.
Templates, Image Pyramids, and Filter Banks Slides largely from Derek Hoeim, Univ. of Illinois.
Templates and Image Pyramids Computational Photography Derek Hoiem, University of Illinois 09/06/11.
Edge detection Goal: Identify sudden changes (discontinuities) in an image Intuitively, most semantic and shape information from the image can be encoded.
Image Filtering, Part 2: Resampling Today’s readings Forsyth & Ponce, chapters Forsyth & Ponce –
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.
Computer Vision - A Modern Approach
Lecture 2: Edge detection and resampling
Image Sampling Moire patterns
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)
Lecture 2: Image filtering
Templates, Image Pyramids, and Filter Banks Computer Vision James Hays, Brown Slides: Hoiem and others.
The Frequency Domain : Computational Photography Alexei Efros, CMU, Fall 2008 Somewhere in Cinque Terre, May 2005 Many slides borrowed from Steve.
Image Sampling Moire patterns -
CSC589 Introduction to Computer Vision Lecture 9 Sampling, Gaussian Pyramid Bei Xiao.
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.
Templates, Image Pyramids, and Filter Banks Computer Vision Derek Hoiem, University of Illinois 01/31/12.
CS559: Computer Graphics Lecture 3: Digital Image Representation Li Zhang Spring 2008.
Image Resampling CS4670: Computer Vision Noah Snavely.
Templates, Image Pyramids, and Filter Banks
Image Resampling CS4670: Computer Vision Noah Snavely.
Image Processing Xuejin Chen Ref:
Templates and Image Pyramids Computational Photography Derek Hoiem, University of Illinois 09/03/15.
Image Processing Edge detection Filtering: Noise suppresion.
Image Filtering Computer Vision CS 543 / ECE 549 University of Illinois Derek Hoiem 02/02/10.
Computer Vision Spring ,-685 Instructor: S. Narasimhan Wean 5403 T-R 3:00pm – 4:20pm.
Templates, Image Pyramids, and Filter Banks
Recap of Monday linear Filtering convolution differential filters filter types boundary conditions.
Lecture 5: Image Interpolation and Features
Brent M. Dingle, Ph.D Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin - Stout Image Processing.
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.
CSE 185 Introduction to Computer Vision Image Filtering: Spatial Domain.
Spatial Filtering (Chapter 3) CS474/674 - Prof. Bebis.
Miguel Tavares Coimbra
Image Resampling & Interpolation
Sampling, Template Matching and Pyramids
- photometric aspects of image formation gray level images
Image Sampling Moire patterns
Digital 2D Image Basic Masaki Hayashi
Image Pyramids and Applications
Edge Detection CS 678 Spring 2018.
Image Sampling Moire patterns
Edge detection Goal: Identify sudden changes (discontinuities) in an image Intuitively, most semantic and shape information from the image can be encoded.
Multiscale Analysis of Images
Sampling and Reconstruction
CSCE 643 Computer Vision: Thinking in Frequency
Samuel Cheng Slide credits: Noah Snavely
Image Processing Today’s readings For Monday
Motion illusion, rotating snakes
Filtering Part 2: Image Sampling
Image Sampling Moire patterns
JPEG Still Image Data Compression Standard
Image Resampling & Interpolation
Resampling.
Edge Detection Today’s readings Cipolla and Gee Watt,
Lecture 1: Images and image filtering
Samuel Cheng Slide credits: Noah Snavely
IT472 Digital Image Processing
Review and Importance CS 111.
Templates and Image Pyramids
Presentation transcript:

Computer Vision Jia-Bin Huang, Virginia Tech Image Pyramids and Applications Computer Vision Jia-Bin Huang, Virginia Tech Computer Vision Jia-Bin Huang, Virginia Tech Golconda, René Magritte, 1953

Administrative stuffs HW 0 posted – due Sept 10 HW 1 posted – due Sept 17

HW 0 – Basic image manipulation 1) Plot the R, G, B values along the scanline on the 250th row of the image. 2) Stack the R, G, B channels of the hokiebird image vertically. This will be an image with width of 600 pixels and height of 1116 pixels. 3) Load the input color image and swap its red and green color channels. 4) Convert the input color image to a grayscale image. 5) Take the R, G, B channels of the image. Compute an average over the three channels. Note that you may need to do the necessary typecasting (uint8 and double) to avoid overflow.

HW 0 – Basic image manipulation 6) Take the grayscale image, obtain the negative image (i.e., mapping 255 to 0 and 0 to 255). 7) First, crop the original hokie bird image into a squared image of size 372 x 372. Then, rotate the image by 90, 180, and 270 degrees and stack the four images (0, 90, 180, 270 degreess) horizontally. 8) Create another image with the same size as the hokie bird image. First, initialize this image as zero everywhere. Then, for each channel, set the pixel values as 255 when the corresponding pixel values in the hokie bird image are greater than 127. 9) Report the mean R, G, B values for those pixels marked by the mask in (8). 10) Take the grayscale image in (3). Create and initialize another image as all zeros. For each 5 x 5 window in the grayscale image, find out the maximum value and set the pixels with the maximum value in the 5x5 window as 255 in the new image. Some useful functions: title, subplot, imshow, mean, imread, imwrite, rgb2gray, find . Use help in MATLAB to learn more about these functions.

Previous class: Image Filtering Linear filtering is sum of dot product at each position Can smooth, sharpen, translate (among many other uses) Gaussian filters Low pass filters, separability, variance Attend to details: filter size, extrapolation, cropping Applications: Texture representation Noise models and nonlinear image filters 1

Previous class: Image Filtering Sometimes it makes sense to think of images and filtering in the frequency domain Fourier analysis Can be faster to filter using FFT for large images (N logN vs. N2 for auto-correlation) Images are mostly smooth Basis for compression Remember to low-pass before sampling

Spatial domain * = FFT FFT Inverse FFT = Frequency domain

Upsampling This image is too small for this screen: How can we make it 10 times as big? Simplest approach: repeat each row and column 10 times (“Nearest neighbor interpolation”)

Image interpolation Recall how a digital image is formed d = 1 in this example 1 2 3 4 5 Recall how a digital image is formed It is a discrete point-sampling of a continuous function If we could somehow reconstruct the original function, any new image could be generated, at any resolution and scale Adapted from: S. Seitz

Image interpolation Recall how a digital image is formed d = 1 in this example 1 2 3 4 5 Recall how a digital image is formed It is a discrete point-sampling of a continuous function If we could somehow reconstruct the original function, any new image could be generated, at any resolution and scale Adapted from: S. Seitz

Image interpolation What if we don’t know ? Guess an approximation: 1 d = 1 in this example 1 2 2.5 3 4 5 What if we don’t know ? Guess an approximation: Can be done in a principled way: filtering Convert to a continuous function: Reconstruct by convolution with a reconstruction filter, h Adapted from: S. Seitz

Image interpolation “Ideal” reconstruction Nearest-neighbor interpolation Linear interpolation Gaussian reconstruction Source: B. Curless

Reconstruction filters What does the 2D version of this hat function look like? performs linear interpolation (tent function) performs bilinear interpolation Often implemented without cross-correlation E.g., http://en.wikipedia.org/wiki/Bilinear_interpolation Better filters give better resampled images Bicubic is common choice Cubic reconstruction filter

Image interpolation Original image: x 10 Nearest-neighbor interpolation Bilinear interpolation Bicubic interpolation

Image interpolation Also used for resampling

Things to Remember Sometimes it makes sense to think of images and filtering in the frequency domain Fourier analysis Can be faster to filter using FFT for large images (N logN vs. N2 for auto-correlation) Images are mostly smooth Basis for compression Remember to low-pass before sampling

Today’s class Template matching Image Pyramids Compression Introduction to HW1

Template matching Goal: find in image Main challenge: What is a good similarity or distance measure between two patches? D() , ) Correlation Zero-mean correlation Sum Square Difference Normalized Cross Correlation

Matching with filters Goal: find in image Method 0: filter the image with eye patch g = filter f = image Problem: response is stronger for higher intensity What went wrong? Input Filtered Image

Matching with filters Goal: find in image Method 1: filter the image with zero-mean eye mean of template g True detections Likes bright pixels where filters are above average, dark pixels where filters are below average. Problems: response is sensitive to gain/contrast, pixels in filter that are near the mean have little effect, does not require pixel values in image to be near or proportional to values in filter. False detections Input Filtered Image (scaled) Thresholded Image

Matching with filters Goal: find in image Method 2: Sum of squared differences (SSD) True detections Problem: SSD sensitive to average intensity Input 1- sqrt(SSD) Thresholded Image

Matching with filters Can SSD be implemented with linear filters? Constant Filtering with g Filtering with box filter

What’s the potential downside of SSD? Matching with filters Goal: find in image Method 2: SSD What’s the potential downside of SSD? Problem: SSD sensitive to average intensity Input 1- sqrt(SSD)

Matching with filters Goal: find in image Method 3: Normalized cross-correlation mean template mean image patch Invariant to mean and scale of intensity Matlab: normxcorr2(template, im)

Matching with filters Goal: find in image Method 3: Normalized cross-correlation True detections Input Thresholded Image Normalized X-Correlation

Matching with filters Goal: find in image Method 3: Normalized cross-correlation True detections Input Thresholded Image Normalized X-Correlation

Q: What is the best method to use? A: Depends Zero-mean filter: fastest but not a great matcher SSD: next fastest, sensitive to overall intensity Normalized cross-correlation: slowest, invariant to local average intensity and contrast

2-mins break

Q: What if we want to find larger or smaller eyes? A: Image Pyramid

Low-Pass Filtered Image Review of Sampling Gaussian Filter Sub-sample Image Low-Pass Filtered Image Low-Res Image

Gaussian pyramid Source: Forsyth

Template Matching with Image Pyramids Input: Image, Template Match template at current scale Downsample image In practice, scale step of 1.1 to 1.2 Repeat 1-2 until image is very small Take responses above some threshold, perhaps with non-maxima suppression

Laplacian filter unit impulse Gaussian Laplacian of Gaussian Source: Lazebnik

Laplacian pyramid Source: Forsyth

Creating the Gaussian/Laplacian Pyramid Image = G1 Smooth, then downsample G2 Downsample (Smooth(G1)) Downsample (Smooth(G2)) G3 … GN = LN G1 - Smooth(Upsample(G2)) L1 L2 L3 G3 - Smooth(Upsample(G4)) G2 - Smooth(Upsample(G3)) Use same filter for smoothing in each step (e.g., Gaussian with 𝜎=2) Downsample/upsample with “nearest” interpolation

Hybrid Image in Laplacian Pyramid High frequency  Low frequency

Reconstructing image from Laplacian pyramid L1 + Smooth(Upsample(G2)) G2 = L2 + Smooth(Upsample(G3)) G3 = L3 + Smooth(Upsample(L4)) L4 L1 L2 L3 Use same filter for smoothing as in desconstruction Upsample with “nearest” interpolation Reconstruction will be lossless

Major uses of image pyramids Object detection Scale search Features Detecting stable interest points Course-to-fine registration Compression

Coarse-to-fine Image Registration Compute Gaussian pyramid Align with coarse pyramid Successively align with finer pyramids Search smaller range Why is this faster? Are we guaranteed to get the same result?

Applications: Pyramid Blending

Applications: Pyramid Blending

Pyramid Blending At low frequencies, blend slowly At high frequencies, blend quickly 1 1 1 Left pyramid Right pyramid blend

Image representation Pixels: great for spatial resolution, poor access to frequency Fourier transform: great for frequency, not for spatial info Pyramids/filter banks: balance between spatial and frequency information

Compression How is it that a 4MP image (12000KB) can be compressed to 400KB without a noticeable change?

Lossy Image Compression (JPEG) Block-based Discrete Cosine Transform (DCT) Slides: Efros

Using DCT in JPEG The first coefficient B(0,0) is the DC component, the average intensity The top-left coeffs represent low frequencies, the bottom right – high frequencies

Image compression using DCT Quantize More coarsely for high frequencies (which also tend to have smaller values) Many quantized high frequency values will be zero Encode Can decode with inverse dct Filter responses Quantization table Quantized values

JPEG Compression Summary Convert image to YCrCb Subsample color by factor of 2 People have bad resolution for color Split into blocks (8x8, typically), subtract 128 For each block Compute DCT coefficients Coarsely quantize Many high frequency components will become zero Encode (e.g., with Huffman coding) http://en.wikipedia.org/wiki/YCbCr http://en.wikipedia.org/wiki/JPEG

Lossless compression (PNG) Predict that a pixel’s value based on its upper-left neighborhood Store difference of predicted and actual value Pkzip it (DEFLATE algorithm)

Three views of image filtering Image filters in spatial domain Filter is a mathematical operation on values of each patch Smoothing, sharpening, measuring texture Image filters in the frequency domain Filtering is a way to modify the frequencies of images Denoising, sampling, image compression Templates and Image Pyramids Filtering is a way to match a template to the image Detection, coarse-to-fine registration

HW 1 – Hybrid Image Hybrid image = Low-Freq( Image A ) + Hi-Freq( Image B )

HW 1 – Image Pyramid

HW 1 – Edge Detection Derivative of Gaussian filters x-direction y-direction Derivative of Gaussian filters

Things to remember Template matching (SSD or Normxcorr2) SSD can be done with linear filters, is sensitive to overall intensity Gaussian pyramid Coarse-to-fine search, multi-scale detection Laplacian pyramid More compact image representation Can be used for compositing in graphics Compression In JPEG, coarsely quantize high frequencies

Thank you See you this Thursday Next class: Edge detection