Digital Image Processing - Practice Assignment 5 | ECE 533, Assignments of Digital Signal Processing

Material Type: Assignment; Class: Digital Image Processing; Subject: Electrical & Computer Engineer; University: University of New Mexico; Term: Spring 2008;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-g5k
koofers-user-g5k 🇺🇸

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Digital Image Processing ECE 533
Assignment 5
Due date: April 1, in class
Department of Electrical and Computing Engineering,University of New Mexico.
Professor Majeed Hayat, [email protected]
March 17, 2008
Frequency Domain Design
1. Let fbe the (192 to 319)×(192 to 319) block of Lena1. Note that fis a 128 ×128
image. Generate and display f.
2. The image fis passed through a filter with DFT H(u, v), u, v = 0,1, . . . , 127. Partial
information on His given in Fig. 1. Determine Hand check that h, the inverse
DFT of H, is real. Which property of Hcaused hto be real?
3. Using the frequency domain analysis, compute the output gof the filter habove.
Display g. (Note: Perform adequate zero padding.)
4. Compare fand gand characterize the filter H.
5. Repeat (3) and (4) for H2= 1 H.
1Download the file Lena.tif from http://www.ece.unm.edu/~jpezoa/tmp
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Digital Image Processing - Practice Assignment 5 | ECE 533 and more Assignments Digital Signal Processing in PDF only on Docsity!

Digital Image Processing ECE 533

Assignment 5

Due date: April 1, in class

Department of Electrical and Computing Engineering, University of New Mexico.

Professor Majeed Hayat, [email protected]

March 17, 2008

Frequency Domain Design

  1. Let f be the (192 to 319)×(192 to 319) block of Lena^1. Note that f is a 128 × 128 image. Generate and display f.
  2. The image f is passed through a filter with DFT H(u, v), u, v = 0, 1 ,... , 127. Partial information on H is given in Fig. 1. Determine H and check that h, the inverse DFT of H, is real. Which property of H caused h to be real?
  3. Using the frequency domain analysis, compute the output g of the filter h above. Display g. (Note: Perform adequate zero padding.)
  4. Compare f and g and characterize the filter H.
  5. Repeat (3) and (4) for H 2 = 1 − H. (^1) Download the file Lena.tif from http://www.ece.unm.edu/~jpezoa/tmp

m = 0...... m = 31... m = 64 m = 127 n = 127 1 1 1 0 ... 1 1 1 0 ... 1 1 1 0 n = 97 1 1 1 0 ... 0 0 0 0 ... 0 0 0 0 n = 64 0 0 0 0 0 ... 0 0 0 0 0 ... 0 0 0 0 0 n = 31 1 1 1 1 0 0 ... 1 1 1 1 0 0 ... 1 1 1 1 0 0 n = 0 1 1 1 1 0 0 m = 0...... m = 31... m = 64 m = 127 Figure 1: Partial information about H(u, v).

  1. Compute the (9 × 9) mask ˜h(m, n) (m, n = 0, 1 ,... , 8) for which ∑^127 u=

∑^127

v=

| H˜(u, v) − H(u, v)|^2

is minimized, where H˜ is the 128 × 128 DFT of ˜h.

  1. Let ˜g be the output of the filter ˜h when the input is f. Display ˜g and compare it with g in (3).
  2. Explain precisely the reason for performing zero padding in (3).

% II and IV quadrant C0v=[34 7 6; 156 124 7; 21 71 7; 63 32 6; 19 32 2]; for k=1:size(C0v,1) C0=C0v(k,1:2); % distance to (1,1) D=C0-[1 1]; R=C0v(k,3); IdxX=(C0(1)-R):(C0(1)+R); IdxY=(C0(2)-R):(C0(2)+R); FILTER(IdxX,IdxY)=CreateShapes(’circle’,R); % use the distance C0=[M N]-D; IdxX=(C0(1)-R):(C0(1)+R); IdxY=(C0(2)-R):(C0(2)+R); FILTER(IdxX,IdxY)=CreateShapes(’circle’,R); end % I and III quadrant C0v=[7 292 6; ]; for k=1:size(C0v,1) C0=C0v(k,1:2); % distance to (1,N) D=C0-[1 N]; R=C0v(k,3); IdxX=(C0(1)-R):(C0(1)+R); IdxY=(C0(2)-R):(C0(2)+R); FILTER(IdxX,IdxY)=CreateShapes(’circle’,R); % use the distance C0=[M 1]-D; IdxX=(C0(1)-R):(C0(1)+R); IdxY=(C0(2)-R):(C0(2)+R);

FILTER(IdxX,IdxY)=CreateShapes(’circle’,R); end IMGFILTERED=FILTER.IMG; MAGIMGFILTERED=10log10(abs(IMGFILTERED).^2+eps); ImgFiltered=ifft2(ifftshift(IMGFILTERED));

Min=min(min(ImgFiltered)); Max=max(max(ImgFiltered)); % NOTE: SOME VERSIONS OF MATLAB CAN PRODUCE APPROXIMATION ERRORS AND/OR % VERY SMALL COMPLEX PARTS AFTER TAKING THE IFFT. IF THIS IS YOUR CASE % TAKE abs(ImgFiltered). THIS CODE WAS TESTED USING MATLAB 7.1 AND NO % abs WAS REQUIRED, HOWEVER IN MATLAB 6.5 IT WAS NEEDED. ImgFiltered=(ImgFiltered-Min)/(Max-Min);

PlotImages(ImgFiltered,MAGIMGFILTERED,kf); kf=kf+1;

% Go back to 16 colors % Create the 16 partitions C=linspace(0,1,17); ImgFiltered16c=zeros(M,N); % Loop over the partitions and assign a value according to the partition for i=1:(length(C)-1) ImgFiltered16c=ImgFiltered16c+... C(i+1)double( (C(i)<=ImgFiltered) & (ImgFiltered<C(i+1)) ); end IMGFILTERED16C=fftshift(fft2(ImgFiltered16c)/(MN)); MAGIMGFILTERED16C=10*log10(abs(IMGFILTERED16C).^2);

% Show image, histogram and FFT-2D PlotImages(ImgFiltered16c,MAGIMGFILTERED16C,kf); kf=kf+1;

figure(kf); kf=kf+1; imshow(Img,[]); figure(kf);kf=kf+1; imshow(ImgFiltered,[]); figure(kf);kf=kf+1; imshow(ImgFiltered16c,[]);

where L ≤ N. Finally, suppose that the degraded image g is given by

g(m, n) = h(m, n) ⊗ f (m, n) + η(m, n), m, n, = 0, 1 ,... , N − 1. (1)

Assume that q(m, n) is an 128 × 128 Laplacian filter defined as

q(m, n) =

− 1 , (m, n) = {(0, 1), (1, 0), (2, 1), (1, 2)} 1 , (m, n) = (1, 1) 0 , otherwise

Determine the restoration filter Hr (u, v), in the frequency domain, that minimizes

∑^127 m=

∑^127

n=

|(q ⊗ fˆ )(m, n)|^2

subject to the constraint

∑^127 m=

∑^127

n=

|(h ⊗ fˆ )(m, n) − g(m, n)|^2 = (128)^2 ση ,

where fˆ (m, n) = (hr ⊗ g)(m, n) is the restored image, ση = E [η(m, n)^2 ], h(m, n) is the blurring filter, and hr = F −^1 {Hr (u, v)}.

  1. Display the restored image. Give your actual choice of the constraint parameter γ and the corresponding error in achieving the constraint equation.
  2. Explain the significance of the minimization and the constraint.

(Hint: See equation (5.9-4) in Gonzalez and Woods, 2002.)

Problem 3.

Consider a linear, position invariant image degradation system with impulse response h(x − α, y − β) = exp{−(x − α)^2 − (y − β)^2 }. Suppose that the input to the system is an image consisting of a line of infinitesimal width located at x = a, and modeled by f (x, y) = δ(x − a). Assuming no noise, what is the output image g(x, y)?

Problem 4.

Image blurring caused by long-term exposure to atmospheric turbulence can be modeled by the transfer function H(u, v) = exp{−(u^2 +v^2 )/(2σ^2 )}. Assume negligible noise. What is the equation of the Wiener filter you would use to restore an image blurred by this type of degradation?

Problem 5.

Assume that the model in Fig. 5.1 of your textbook is linear and position-invariant and show that the power spectrum of the output is given by |G(u, v)|^2 = |H(u, v)|^2 |F (u, v)|^2 + |N (u, v)|^2. Refer to equations (5.5-17) and (4.6-18) in the textbook.

Problem 6.

In 1974, Cannon suggested a restoration filter R(u, v) satisfying the condition | Fˆ (u, v)|^2 = |R(u, v)|^2 |G(u, v)|^2 and based on the premise of forcing the power spectrum of the restored image, | Fˆ (u, v)|^2 , to equal the power spectrum of the original image, |F (u, v)|^2.

  1. Find R(u, v) in terms of |F (u, v)|^2 , |H(u, v)|^2 , and |N (u, v)|^2. (Hint: Refer to Fig. 5.1 and equation (5.5-17) of your textbook, and to the previous problem.)
  2. Use your previous result to state a result in the form of equation (5.8-2) of the textbook.