




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Digital Image Processing; Subject: Electrical & Computer Engineer; University: University of New Mexico; Term: Spring 2008;
Typology: Assignments
1 / 8
This page cannot be seen from the preview
Don't miss anything!





Professor Majeed Hayat, [email protected]
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).
v=
| H˜(u, v) − H(u, v)|^2
is minimized, where H˜ is the 128 × 128 DFT of ˜h.
% 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=
n=
|(q ⊗ fˆ )(m, n)|^2
subject to the constraint
∑^127 m=
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)}.
(Hint: See equation (5.9-4) in Gonzalez and Woods, 2002.)
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)?
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?
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.
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.