1. Construct a matrix f that is
similar to the function f(m,n) in the example in “Definition of Fourier
Transform” on page 9-3. Remember that f(m,n) is equal to 1 within the
rectangular region and 0 elsewhere. Use a binary image to represent f(m,n).
f = zeros(30,30);
f(5:24,13:17) = 1;
imshow(f,'InitialMagnification','fit')
2. Compute and visualize the
30-by-30 DFT of f with these commands. Fourier
Transform
F = fft2(f);
F2 = log(abs(F));
imshow(F2,[-1 5],'InitialMagnification','fit'); colormap(jet); colorbar
3. To obtain a finer sampling of the Fourier transform,
add zero padding to f when computing its DFT. The zero padding and DFT
computation can beperformed in a single step with this command.
4 The zero-frequency coefficient, however, is still
displayed in the upper left corner rather than the center. You can fix this
problem by using the function fftshift, which swaps the quadrants of F so that the
zero-frequency coefficient is in the center.
bw = imread('text.png');
a = bw(32:45,88:98);
imshow(bw);
figure, imshow(a);
C = real(ifft2(fft2(bw) .* fft2(rot90(a,2),256,256)));
figure, imshow(C,[])
>> I = imread('cameraman.tif');
I = im2double(I);
T = dctmtx(8);
dct = @(x)T * x * T';
B = blkproc(I,[8 8],dct);
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];
B2 = blkproc(B,[8 8],@(x)mask.* x);
invdct = @(x)T' * x * T;
I2 = blkproc(B2,[8 8],invdct);
imshow(I), figure, imshow(I2)
Download disini
No comments:
Post a Comment