<<

Image Sampling and Resizing

Yao Wang Polytechnic Institute of NYU, Brooklyn, NY 11201

With contribution from Zhu Liu Partly based on A. K. Jain, Fundamentals of Processing Lecture Outline

• Introduction • Ny qu ist sampling and theorem • Common sampling and interpolation filters • Sampling rate conversion of discrete images (image resizing)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 2 Illustration of Image Sampling and Interpolation

dx=dy=2mm

16 mm dx=dy=1mm

How to choose dx, dy to reach a good trade off between accuracy and cost of Yao Wang, NYU-Poly storage, transmission,EL5123: Samplingprocessing? and Resizing 3 Uniform Sampling • f(x,y) represents the original continuous image, fs(m,n) the sampled image, and fˆ(x, y) the reconstructed image. • Uniform sampling

fs (m,n)  f (mx,ny), m  0,..., M 1;n  0,..., N 1. – ∆x and ∆y are vertical and horizontal sampling intervals. fs,x=1/∆x, fs,y=1/ ∆y are vertical and horizontal sampling frequencies.

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 4 Image Sampling as Product with Impulse Train M 1 N 1 • Periodic impulse p(x, y)   (x  m x , y  n y ) sequence m0 n0 ~ M 1 N 1 f s (x, y)  f (x, y) p(x, y)   f (m x ,n y ) (x  m x , y  n y ) m0 n0 MN11   fs (m,n) (x  m x , y  n y ) mn00 m = 0 1 ∆x p(x,y) …

M - 1

∆y y x n= 0 1 2 N-1

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 5 of Impulse Train  • 1D 1 p(t)   (t  nt)  P(u)   (u  nfs ) m,n t n 1 where f  s t

 • 2D

1 p(x, y)   (x  mx, y  ny)  P(u,v)   (u  mfs,x ,v  nfs, y ) m,n xy m,n 1 1 where f  , f  s,x x s, y y

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 6 Interpretation of Sampling • Sampling is equivalent to multiplication of the original with a sampling pulse sequence. fs (x, y)  f (x, y) p(x, y) where p(x, y)   (x  mx, y  ny) m,n • IfIn frequency d omai n

Fs (u,v)  F(u,v) P(u,v) 1 1 P(u,v)   (u  mfs,x ,v  nf s, y )  Fs (u,v)   F(u  mfs,x ,v  nfs, y ) xy m,n xy m,n 1 1 where f  , f  s,x x s, y y

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 7 Frequency Domain Interpppgretation of Sampling in 1D

Original signal

The spectrum of the Sampling sampled signal impulse train includes the original spectrum and its aliases (copies) shifted

to k fs , k=+/- 1,2,3,… SldilSampled signal

fs > 2fm When fs< 2fm , aliases overlap with the original spectrum -> Sampled signal artifact fs < 2fm (Aliasing effect)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 8 Sampling of 1D Sinusoid

Sampling above

s=3m>s0

Reconstructed =oriiigina l

Sampling under Nyquist rate

s=1.5m<s0

Reconstructed != original

Aliasing: The reconstructed sinusoid has a lower frequency than the original!

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 9 Frequency Domain Interpretation of Sampling in 2D • The sampled signal contains replicas of the original spectrum shifted by multiples of sampling frequencies. u u fs,x

fs,x>2fm,x fmxm,x fs,y>2fm,y v f v m,y fs,y

Original spectrum F(u, v) Sampled spectrum Fs(u, v)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 10 Illustration of Aliasing Phenomenon

u u

fm,x fs,x fsxs,x<2fm,x fs,y<2fm,y

v fs,y v fm,y

Original spectrum F(u,v) Sampppled spectrum Fs(()u,v)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 11 Nyquist Sampling Rate

• Nyquist sampling rate – To be able to preserve the original signal in the sampled signals, these aliasing components should not overlap with the original one. This requires that the sampling

frequency fs,x, fs,y must be at least twice of the highest frequency of the signal, known as Nyquist sampling rate. • Interpolation – Remove all the aliasing components

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 12 Nyquist Sampling and Reconstruction Theorem

• A band-limited image with highest frequencies at fm,x, fm,y can be reconstructed perfectly from its samples,

provided that the sampling frequencies satisfy: fs,x >2fm,x, fs,y>2fm,y • The reconstruction can be accomplished by the ideal

low-pass filter with cutoff frequency at fc,x = fs,x/2, fc,y = fs,y/2, with magnitude ∆x∆y.   fs,x fs, y xy | u | ,| v | sin fs,x x sin fs, y y H (u,v)    h(x, y)   2 2 f x f y  0 otherwise s,x s, y • The interpolated image sin f (x m x) sinf (y  my) ˆ  s,x   s, y f (x, y)   fs (m,n) mn fs,x (x  mx) fs, y (y  my)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 13 Applying Nyquist Theorem

• Two issues – The signals are not bandlimited.

• A filter with cutoff frequency fc=fs/2 needs to be applied before sampling. This is called prefilter or sampling filter. – The is not realizable. • Shorter, finite length filters are usually used in practice for bo th pre filter and i nt erpol ati on filter. • A general paradigm

B C Interpolation Prefilter D A (postfilter)

Sampling pulse fs

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 14 Non-ideal Sampling and Interpolation Aliased Pre-filtered Aliased Component Signal Component

f -fs 0 s

Non-ideal Aliasing Interpolation filter

Non ideal prefiltering causes Aliasing Non ideal interpolation filter causes Imaggging

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 15   Sampling a Sinusoidal Signal  1 f (x, y)  cos(4 x  2 y)  F(u,v)  (u  2,v 1)  (u  2,v 1) 2

SldtSampled at ∆x=∆y=1/3 fs,x=fs,y=3

Original Spectrum Sampled Spectrum v v

3 3 (-2,1) (-2,1)

-3 3 u -3 3 u (2,-1) Ideal -3 (2,-1) -3 interpolation filter Original pulse Replicated pulse  ˆ f (x, y)  cos(2 x  2y) Replication center

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 16 Sampling in 2D: Sampling a 2D Sinusoidal Pattern

f(x,y)=sin(2*π*(3x+y)) f(x,y)=sin(2*π*(3x+y)) Sampling: dx=0. 01, dy=0.01 Sampling: dx=0.2,dy=0.2 Satisfying Nyquist rate (Displayed with replication) f =3, f =1 x,max y,max Sampling at a rate lower than Nyquist rate fs,x=100>6, fs,y=100>2

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 17 A Simple Prefilter – Averaging Filter

• Each sampling value is the mean value of the original continuous function in a rectangular region of dimension ∆x and ∆y, i.e: n 1 f (m,n)  f (x, y)dxdy s xy  m (x, y)Dm,n where

Dm,n  (m 1/ 2)x  x  (m 1/ 2)x,(n 1/ 2)y  y  (n 1/ 2)y

The equivalent prefilter is   1  | x | x / 2,| y | y / 2 sin xu sin yv h(x, y)  xy  H (u,v)  xy xu yv  0 otherwise

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 18 How good is the averaging Filter?

• Look at its frequency response, how far is it from the ideal low pass filter

Ideal low pass filter with cutoff at fs/2

Averaging filter

-f f 2fs -3fs -2fs s s 3fs

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 19 Reconstruction of continuous image from Samples • The interpolation problem • Interpretation as weighted average of sample values • Interpretation as filtering • What filter should we use? – Ideal interpolation filter: remove the replicated spectrum using ideal low-pass filter with cutoff frequency at fs/2 (the )

sinf ( y  ny) ˆ sinfs,x (x  mx) s,y f (x, y)   fs (m,n) mn fs,x (x  mx) fs,y ( y  ny)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 20 Interpretation as a weighted average of sample values

• The value of a function at arbitrary point (x, y) is estimated from a weighted sum of its sample values in the neighborhood of ([x/ ∆x], [y/∆y]): – Let h(x,y; m,n) specifies the weight assigned to sample m,n, when determining the image value at x,y ˆ f (x, y)   h(x, y;m,n) fs (m,n) m,n

H(x;8) H(x;7) x H(x;9)

H(x;6) H(x;10)

H(x;5)

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 n Yao Wang, NYU-Poly EL5123: Sampling and Resizing 21 Desirable Properties of the Weight Function • The weighting function h(x,y;m,n) should depend only on distance between (x,y) and the spatial location of (m,n), iei.e. h(x, y;m,n)  h(x  mx, y  ny). • Should be a decreasing function of the distance – Higher weight for nearby samples • Should be an even function of the distance – Le ft nei g hbor and ri g ht nei ghb or o f same dist ance h ave th e same weight – h1(x)=h1(-x) • Generally Separable: – h2(x,y)=h1(x) h1(y) • To retain the original sample values, should have – h(0, 0)=1, h(m xnx,ny)=0

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 22 Interpretation as Filtering

ˆ • The weighted f (x, y)   h(x  mx, y  ny) fs (m,n) m,n average operation is  ~  equivalent to filtering f s (x, y)   fs (m,n) (x  mx, y  ny)    m,n  fs(x,y) with h(x,y) ~   h(x, y) f (x, y) • Usually, h(xyx,y)is) is s  ~   h(x  , y  ) f ( , )d d separable h(x,y) =  s    hx(x)hy(y)  h(x  , y  ) f (m,n) (  mx,  ny)dd   s • To retain the original m,n   f (m,n) h(x  , y  ) (  mx,  ny)dd sample values,  s  m,n should have   fs (m,n)h(x  mx, y  ny) – h(0,0)=1, m,n h(mx,ny)=0 ˆ ~  f (x, y)  h(x, y) f s (x, y) – Nyquist filter

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 23 A Simple Interpolation Filter: Sample-And-Hold (pixel replication) • The interpolated value at a point is obtained from that of its nearest sample ˆ f (x, y)  fs (m,n) (m 1/ 2)x  x  (m 1/ 2)x,(n 1/ 2)y  y  (n 1/ 2)y • Corresponding interpolation filter is 1  x / 2  x  x / 2,y / 2  y  y / 2 h(x, y)   n  0 otherwise

(m-1/2)∆x m 0th order interpolation filter (m+1/2)∆x

(n-1/2)∆y (n+1/2)∆y

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 24 Bilinear Filter

f1 f (m,n) (m,n+1) f a 0 b Step 1:

a f (q1)  (1 a) f (m,n)  af (m 1,n) 01a f (q2 )  (1 a) f (m,n 1)  af (m 1,n 1) q q 1 p 2 Step 2 : fa  (1 a) f0  af1 f ( p)  (1 b) f (q1)  bf (q2 )

1D Linear interpolation (m+1,n) (m+1,n+1)

2D bilinear interpolation

Corresponding interpolation filter  | x | | y | 1 1   x  x  x,y  y  y h(x, y)   x  y   0 otherwise

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 25 Which filter is better?

• Recall what happened in the frequency domain when we sample an image • Ideal filter: ½ band ideal low pass filter • Quantitatively we can evaluate how far is the filter from the ideal filter • But we should also look at visual artifacts

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 26 Frequency Domain Interpretation of Sampling in 2D • The sampled signal contains replicas of the original spectrum shifted by multiples of sampling frequencies. u u fs,x

fs,x>2fm,x fmxm,x fs,y>2fm,y v f v m,y fs,y

Original spectrum F(u, v) Sampled spectrum Fs(u, v)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 27 Ideal Interpolation Filter

• The ideal interpolation filter should be a low-pass filter

with cutoff frequency at fc,x = fs,x/2, fc,y = fs,y/2, with magnitude ∆x∆y   fs,x fs, y xy | u | ,| v | sin fs,x x sinfs, y y H (u,v)    h(x, y)   2 2 f x f y  0 otherwise s,x s, y

The sinc filter

• The interpolated image Weight function h(x,y;m,n)

sin f (x m x) sinf (y  ny) ˆ  s,x   s, y f (x, y)   fs (m,n) mn fs,x (x  mx) fs, y (y  ny)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 28 Comparison of Different Interpolation Filters

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 29 Image Resizing

• Image resizing: – Enlarge or reduce the image size (number of ) – Equivalent to • First reconstruct the continuous image from samples • Then Resamppgle the image at a different sam pgpling rate – Can be done w/o reconstructing the continuous image explicitly • Image down-sampling (resample at a lower rate) – Spatial domain view – Frequency domain view: need for prefilter • Image up-sampling (resample at a higher rate) – Spatial domain view – Different interpolation filters • Nearest neighbor, Bilinear, Bicubic

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 30 Image Down-Sampling

• Example: – reduce a 512x512 image to 256x256 = factor of 2 downsampling in both horizontal and vertical directions – In general, we can down-sample by an arbitrary factor in the horizontal and vertical directions • How should we obtain the smaller image ?

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 31 Down Sampling by a Factor of Two

8x8 Image 4x4 Image

• Without Pre -filtering (simple approach)

fd (m,n)  f (2m,2n) • Averaging Filter

fd (m,n)  [ f (2m,2n)  f (2m,2n 1)  f (2m 1,2n)  f (2m 1,2n 1)]/ 4

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 32 Problem of Simple Approach

• Aliasing if the effective sampling rate is below the Nyquist sample rate = 2 * highest frequency in the original continuous signal • We need to prefilter the signal before down- sampling • Ideally the prefilter should be a low-pass filter with a cut-off frequency half of the new sampling rate. – In digital frequency of the original sampled image, the cutoff frequency is ¼. • In practice , we may use simple averaging filter

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 33 Down Sampling by a Factor of K

ˆ f(m,n) f (m,n) fd(m,n) Hs ↓K

Pre-filtering Down-sampling

ˆ fd (m,n)  f (Km, Kn)

For factor of K down sampling, the prefilter should be low pass filter with cutoff at fs/(2K), if fs is the original sampling frequency

ItIn terms of fdiitlf digital frequency, th e cut tffhoff should ldb1/(2K) be 1/(2K)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 34 Example: Image Down-Sample

Without prefiltering

With prefiltering (no aliasing, but blurring!)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 35 Down-Sampling Using Matlab

• Without prefiltering – If f(,) is an MxN image, down-sampling by a factor of K can be done simply by >> g=f(1:K:M,1:K:N) • With ppgrefiltering – First convolve the image with a desired filter • Low pass filter with digital cutoff frequency 1/(2K) – In matlab, 1/2 is normalized to 1 – Then subsample >> h=fir1(N, 1/K) %design a lowpass filter with cutoff at 1/K. >> fp=conv2(f,h) >> g=fp(1:K:M,1:K:N)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 36 Image Up-Sampling

• Produce a larger image from a smaller one – Eg. 512x512 -> 1024x1024 – MllMore generally we may up-samplble by an ar bitrary fac tor L • Questions: – How should we generate a larger image? – Does the enlarged image carry more information? • Connection with interpolation of a continuous image from discrete image – First interpolate to continuous image, then sampling at a higher sampling rate, L*fs – Can be realized with the same interpolation filter, but only evaluate at x=mx’, y=ny’, x’=x/L, y’=y/L – Ideally using the sinc filter!  sin f (x m x) sinf (y  my) ˆ  s,x   s, y f (x, y)   fs (m,n) mn fs,x (x  mx) fs, y (y  my)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 37 Example: Factor of 2 Up-Sampling

(m,n) (m,n+1) (2m,2n) (2m,2n+1)

(2m+1, 2n) (2m+1, 2n+1)

(m+1,n) (m+1,n+1)

Green samples are retained in the interpolated image; Orange samples are estimated from surrounding samples.

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 38 Nearest Neighbor Interpolation (pixel replication)

(m, n) (m, n+1)

b

(m’/M,n’/M) a

(m+1,n) (m+1,n+1)

O[m’,n’] (the resized image) takes the value of the sample nearest to (m’/M,n’/M) in I[m,n] (the original image): O[m',n'] = I[(int) (m + 05)0.5), (int) (n + 0. 5)], m = m'/M, n = n' /M.

Also known as pixel replication: each original pixel is replaced by MxM pixels of the sample value Equivalent to using the sample-and-hold interpolation filter.

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 39 Special Case: M=2

(m,n) (m,n+1) (2m,2n) (2m,2n+1)

(2m+1, 2n) (2m+1, 2n+1)

(m+1,n) (m+1,n+1)

Nearest Neighbor: O[2m,2n]=I[m,n] O[2m,2n+1]= I[m,n] O[2m+1,2n]= I[m,n] O[2m+1,2n+1]= I[m,n]

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 40 Bilinear Interpolation

(m,n) (m,n+1)

b

(m’/M,n’/M) a

(m+1,n) (m+1,n+1)

• O(m’,n ’) takes a weighted average of 4 samples nearest to (m’ /M,n’/M) in I(m,n).

• Direct interpolation: each new sample takes 4 multiplications: O[m’,n’]=(1-a)*(1-b)*I[m,n]+a*(1-b)*I[m,n+1]+(1-a)*b*I[m+1,n]+a*b*I[m+1,n+1]

• Separable interpolation: i) interpolate along each row y: F[m,n’]=(1-a)*I[m,n]+a*I[m,n+1] ii) interpolate along each column x’: O[m’,n’]=(1-b)*F[m’,n]+b*F[m’+1,n]

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 41 Special Case: M=2

(m,n) (m,n+1) (2m,2n) (2m,2n+1)

(2m+1, 2n) (2m+1, 2n+1)

(m+1,n) (m+1,n+1)

Bilinear Interpolation: O[2m,2n]=I[m,n] O[2m,2n+1]=(I[m,n]+I[m,n+1])/2 O[2m+1,2n]=(I[m,n]+I[m+1,n])/2 O[2m+1,2n+1]=(I[m,n]+I[m,n+1]+I[m+1,n]+I[m+1,n+1])/4

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 42

(m-1,n) (m-1,n+1)

(m,n-1) (m,n) (m,n+1) (m,n+2)

b

(m’/M,n’/M) a

(m+1,n-1)(m+1,n) (m+1,n+1) (m+1,n+2)

(m+2,n) (m+2,n+1)

• O(’O(m’,n’) ’)iit is interpo ltdflated from 16 samp les nearesttt to ( m’/M ,n’/M) ’/M)i in I( m,n) . • Direct interpolation: each new sample takes 16 multiplications • Separable interpolation: i) interpolate along each row y: I[m,n]->F[m,n’] (from 4 samples) ii) i n terpol a te al ong eac h co lumn x ’: F[m,n ’]-> O[m’ ,n’] (f rom 4 sampl es)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 43 Interpolation Formula

(m-1,n-1) (m-1,n) (m-1,n+1) (m-1,n+2)

(m,n -1) (m, n) (m, n+1) (m, n+2)

b

F((,m’,n-1) F(m’,n) F(m’,n+1) F(m’,n+2) a (m’/M,n’/M) (m+1,n-1)(m+1,n) (m+1,n+1) (m+1,n+2)

((,)m+2,n) ((,)m+2,n+1)

(m+2,n-1) (m+2,n+2)

F[m',n]  b(1 b)2 I[m 1,n]  (1 2b2  b3 )I[m,n]  b(1 b  b2 )I[m 1,n]  b2 (1 b)I[m  2,n], m' m' where m  (int) ,b   m M M O[m',n']  a(1 a)2 F[m',n 1]  (1 2a2  a3 )F[m',n]  a(1 a  a2 )F[m',n 1]  a2 (1 a)F[m',n  2], n' n' where n  (int) ,a   n M M

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 44 Special Case: M=2

(m-1,n) (m-1,n+1) (2m,2n) (2m,2n+1)

(m,n-1) (m,n) (m,n+1) (m,n+2)

(2m,2n+1) (2m+1, 2n) (2m+1, 2n+1)

(m+1,n-1)(m+1,n) (m+1,n+1) (m+1,n+2)

(m+2,n) (m+2,n+1)

Bicubic interpolation in Horizontal direction

F[2m,2n]=I[m,n] F[2m,2n+1]= -(1/8)I[m,n-1]+(5/8)I[m,n]+(5/8)I[m,n+1]-(1/8)I(m,n+2)

Same operation then repeats in vertical direction

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 45 Comparison of Interpolation Methods

Resize_peak.m

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 46 Up-Sampled from w/o Prefiltering

Nearest Original neighbor

Bilinear Bicubic

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 47 Up-Sampled from with Prefiltering

Nearest Original neighbor

Bilinear Bicubic

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 48 Matlab for Image Resizing

[img]=imread('fruit.jpg','jpg'); %downsampling without prefiltering img 1= imres ize (img, 0. 5, 'nearest '); % with different filters: img2rep=imresize(img1,2,'nearest'); img 2lin= imres ize (img 1, 2, 'bilinear '); img2cubic=imresize(img1,2,'bicubic');

%down sampling with filtering img1=imresize(img,0.5,'bilinear',11); %upsampling with different filters img2rep=imresize(img1, 2,'nearest' ); img2lin=imresize(img1,2,'bilinear'); img2cubic=imresize(img1,2,'bicubic');

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 49 Filtering View: Up Sampling by a Factor of K

~ f(m,n) f (m,n) fu(m,n) ↑K Hi

Zero-padding Post-filtering

~  f (m / K,n / K) if m,n are mullltiple of K f (m,n)    0 otherwise ~ fu (m,n)   h(k,l) f (m  k,n  l) k,l Ideally H should be a low pass filter with cutoff at 1/2K in digital frequency, or fs/2K in continuous frequency

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 50 Homework (1)

1. Consider a 1D signal f(t) = sin(4πt). Illustrate the original and the sampled signal f(n) obtained with a sampling interval ∆t = 1/3. Draw on the same figure the interpolated signal from the sampled one using the sample- and-hold and the linear interpolation filter, respectively. Explain the observed phenomenon based on both the Nyquist sampling theorem as well as physical interpretation. What is the largest sampling interval that can be used to avoid aliasing? 2. Consider a function f(x, y ) = cos2π(4x + 2y) sampled with a sampling period of ∆x = ∆y = ∆ = 1/6 or sampling frequency fs = 1/∆ = 6. a) Assume that it is reconstructed with an ideal low-pass filter with cut-off frequency fcx = fcy = 1/2fs. Illustrate the spectra of the original, sampled, and reconstructed signals. Give the spatial domain function representation of the reconstructed signal. Is the result as expected? b) If the has the following impulse response: 1   / 2  x, y   / 2 h(x, y)    0 otherwise

Illustrate the spectra of the reconstructed signal in the range -fs ≤ u,v ≤ fs. Give a spatial domain function representation of the reconstructed signal if the reconstruction filter is band-limited to (-fs ≤ u,v ≤ fs). ((,i.e., this filter remains the same for the frequency range -fs ≤ u,v ≤ fs, and is set to 0 outsize this range.)

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 51 Homework(2)

3. ( Assignment) Write your own program or programs which can: a) Down sample an image by a factor of 2, with and without using the averaging filter; b) Up-sample the previously down-sampldiled images by a fac tor o f2f 2, us ing the p ixe l rep litilication and bilinear interpolation methods, respectively. You should have a total of 4 interpolated images, with different combination of down-sampling and interpolation methods. Your program could either di rectl y di sp lay on screen the processe d images dur ing program execution, or save the processed images as computer files for display after program execution. Run your program with the image Barbara. Comment on the quality of the down/up sample d images o bta ine d w ith different meth od s. Note: you should not use the ”imresize” function in Matlab to do this assignment. But you are encouraged to compare results of yypgour program with ”resize”.

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 52 Reading

• R. Gonzalez, “,” Section 2.4 • AKA.K. Jain, “Fundamentals of Digital Image Processing,” Section 4.1-4.4

Yao Wang, NYU-Poly EL5123: Sampling and Resizing 53