420 likes | 555 Views
10/12/06. ELE 488 Fall 2006 Image Processing and Transmission (10-12-06). Re-sampling and Re-sizing 1D 2D, sinc interpolation nearest neighbor, bilinear, bicubic, . . . Geometric Transformation translation rotation scaling Affine.
E N D
10/12/06 ELE 488 Fall 2006Image Processing and Transmission (10-12-06) • Re-sampling and Re-sizing • 1D 2D, sinc interpolation • nearest neighbor, bilinear, bicubic, . . . • Geometric Transformation • translation • rotation • scaling • Affine
Lower sampling rate Aliasing? Integer Subsampling by M (=2)
Gaussian Blur (.5,1) followed by subsampling by 2 ,4 subsampling by 2 subsampling by 4
1 D – Increasing Sampling Rate by L Use LPF (stopband edge ωc = π/M) to remove “image”.
Resizing from M x N down to I x J y x M x N grid I x J grid Image value at red pixels known. To determine value at green pixels. (Interpolation)
2-D Interpolation Problem Image value at red pixels known To determine value at green pixels Interpolation In Theory – sinc interpolation at new grid points, NOT practical Approximate reconstruction with reduced computation
Nearest Neighbor Interpolation (mc,nc): closest red pixel to (x,y), to be interpolated Simple, Fast, but… Note: indexing from 0
Bilinear Interpolation Use 4 nearest neighbors of (i,j) to interpolate the image value at (x,y)
Bilinear Interpolation: final equations More computation than nearest neighbor Better accuracy Still fast More complex interpolations
Resizing from I x J up to M x N M x N grid I x J grid
2-D Interpolation Problem Given image value at green pixels, to determine image value at red pixels. Same 2-D interpolation problem. Use same interpolation methods: sinc, nearest neighbor, bilinear, . . .
Example nearest neighbor bilinear
Second interpolation original First interpolation Reduced Complexity Interpolation only an Approximation If possible, always interpolate directly from the original image.
Photos: P. Ramadge Spatially warp one image so that it best matches the other image. What is the correct warp?
Photos: Ingrid Daubechies, Mosaic: R. Radke –5/01 What is the correct warp?
Registration Using Affine Transformation translation, rotation, scaling, shearing
Registration Using Projective Transformation Add: tilting
Geometric Image Transformations Scale Rotation Projective Polynomial Shear Affine 2D image 2D image
Interpolation • From red pixels to green pixels • Have discussed: • Sinc interpolation • Nearest Neighbor • Bilinear
y’ y x’ x Geometric Mapping • Two cartesian coordinate systems: (x,y) and (x’,y’) • Forward Mapping (x’,y’) = h(x,y) • Map locations on input image plane to output image plane • Reverse or Inverse Mapping (x,y) = h-1(x’,y’) • Map locations on the output image plane back onto the input image plane
y’ y x’ x Translation (Rigid Body Transformations) Translate image by Translation changes the origin of the Cartesian coordinate system, not the appearance of the image. Translation preserves length & angle..
(x’, y’) (x, y) Rotation (Rigid Body Transformations) Rotate image counterclockwise by y’ x’ Transformation preserves length & angle.
y n (0,0) (m,n) m x Coordinate System on the Input Image w = (x, y)Tcoordinates of pixel at (m,n) (x,y) ↔ (m,n) wt: x-y coordinates of pixel (0,0) Inverting this expression coordinates in the sample grid for the given w and wt Not necessarily integers Index from 0!
y’ n’ (0,0) (m’,n’) m’ x’ Coordinate System on the Output Image w’ = (x’, y’)Tcoordinates of pixel at (m’,n’) w’t: x’-y’ coordinates of pixel (0,0) Inverting this expression Index from 0! Given w’ and wt’, this is the (non integer) coordinates in the sample grid
Inverse Mapping of the Pixel Values y’ y x’ x w (m’,n’) Start from the grid coordinates of each pixel in the output image, find the cartesian coordinates w’, map these back onto input image cartesian coordinates w, then find the noninteger grid coordinates of this point on the input image. (Not necessarily integers need to interpolate)
Final Step: Interpolation Use NN, bilinear or … interpolation to estimate the value of the input image at the indicated point. This is the value at the (m’,n’) pixel in the output image.
Special Case: Affine Transformation Linear transformation and translation: h(w) = Hw + z = w’ Hence: translation of origin of the x-y coordinate system from the (0,0) pixel in units of pixels. translation of the origin of the x’-y’ coordinate system from the (0,0) pixel in units of pixels. translation introduced by h in units of pixels.
Affine Transformation Note: By measuring all translations in units of pixels, Δ no longer appears explicitly in the equation.
(m,n) (m’,n’) Example: Rotation about the image center y’ ? y x’ x
Rotation example continued Rotation is an affine transformation with no translation term. For rotation about the image center: and:
Scaling Uniform scaling: (preserve angle and shape) Differential scaling: Scaling is an affine transformation.
Example of 3rd Order Polynomial Warping clear; clf P=[0 1; -1 0]; Pinv=[0 -1; 1 0]; I=im2double(imread('apple.jpg')); [M,N,P]=size(I); D=2/M; L=100; wt=D*[-(N+1)/2 (M+1)/2]'; wpt=D*[-(L+1) (L+1)]'; Mp=2*L+1;Np=2*L+1; a=[0 0.5 0 0.3]; b=[0 0 0.5 0.3]; for i=1:1:Mp for j=1:1:Np wp=D*P*[i-1 j-1]' + wpt; w(1)=a(1)+a(2)*wp(1)+a(3)*wp(2)+a(4)*wp(1)^3; w(2)=b(1)+b(2)*wp(1)+b(3)*wp(2)+b(4)*wp(2)^3; kh=Pinv*(w'-wt)/D + [1 1]'; [m n]=round(kh); % nearest neighbor interp. if (m>=1)&(m<=M)&(n>=1)&(n<=N) oJ(i,j,:)=I(m,n,:); else oJ(i,j,:)=[0.25 0.25 0.25]; end end end figure(2); imshow(oJ); Title(‘Transformed Image’)
Example of Polynomial Spatial Warping Images: Pratt, Digital Image Processing, 2nd Ed.
Δ – a scaling factor In general (not necessarily affine), • where • Δ disappears from the expression at the expense of selecting a • different warping function. • For affine h, Δdoes not play a role. • For nonlinear h it is a convenient scaling factor – selecting an • appropriate value for Δ can simplify the selection of h.