-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidft2.m
20 lines (18 loc) · 1.03 KB
/
idft2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function [recovImg] = idft2(dftImg)
% got from Project 2 - question 2 again
[M N ch] = size(dftImg);
if ch>1
recovImg(:,:,1) = (1/numel(dftImg(:,:,1))).*real(conj(dft2(conj(dftImg(:,:,1)))));
recovImg(:,:,2) = (1/numel(dftImg(:,:,2))).*real(conj(dft2(conj(dftImg(:,:,2)))));
recovImg(:,:,3) = (1/numel(dftImg(:,:,3))).*real(conj(dft2(conj(dftImg(:,:,3)))));
% recovImg(:,:,1) = ifft2(dftImg(:,:,1));
% recovImg(:,:,2) = ifft2(dftImg(:,:,2));
% recovImg(:,:,3) = ifft2(dftImg(:,:,3));
recovImg(:,:,1) = (recovImg(:,:,1)-min(recovImg(:,:,1)))./(max(recovImg(:,:,1))-min(recovImg(:,:,1)));
recovImg(:,:,2) = (recovImg(:,:,2)-min(recovImg(:,:,2)))./(max(recovImg(:,:,2))-min(recovImg(:,:,2)));
recovImg(:,:,3) = (recovImg(:,:,3)-min(recovImg(:,:,3)))./(max(recovImg(:,:,3))-min(recovImg(:,:,3)));
else
recovImg = (1/numel(dftImg)).*real(conj(dft2(conj(dftImg))));
recovImg = (recovImg-min(recovImg(:)))./(max(recovImg(:))-min(recovImg(:)));
end
end