To make faster the implemented algorithm
9 views (last 30 days)
I implemented a small algorithm which is very slow and take many hours to generate results.
Although algorithm's output is perfect, can you please guide me to make algorithm faster using filter2 or conv2?
I need to use faster function for these two loops given in the script attached.
function EB = EB_Fast2D(Image, F)
k = 64; % size of patch/window
% F = 100;
n = length(Image); % image is 2D data
F = (-0.5:1/n:0.5-1/n)*F;
dc = zeros(size(Image));
for j= 1: size(Image,2)
for i = k+1:size(Image,1)-k
A = Image(:,j);
A1 = zeros(size(Image,1),1);
A1(i-k : i+k) = A(i-k:i+k); %
sig_fft = fftshift(fft(A1, size(A1,1)));
sum_Ap = cumsum(abs(sig_fft).^2);
sum_Am = wrev(cumsum(wrev(abs(sig_fft).^2)));
[val,idx] = min(abs(sum_Ap - sum_Am));
dc(i,j) = F(idx);
EB = (0.5/F).* dc;