Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

how can i minimize this loop timing please suggest.....

1 vue (au cours des 30 derniers jours)
chirag
chirag le 28 Août 2012
Clôturé : MATLAB Answer Bot le 20 Août 2021
window=100;
wi=(window-1)/2;
temp2=0;
for k=0:row-window
for l=0:col-window
for i=1:window
for j=1:window
temp1(i,j)=double(l1(i+k,j+l));
end
end
LocalMean=mean(mean(temp1));
% LocalVar=var(var(temp1));
for i=1:window
for j=1:window
temp2=temp2+(temp1(i,j)-LocalMean)^2;
end
end
temp3(k+wi,l+wi)=temp2/(101^2);
temp2=0;
end
end
[EDITED, Jan, code formatted]

Réponses (1)

Jan
Jan le 28 Août 2012
Modifié(e) : Jan le 28 Août 2012
window = 100;
wi = ceil((window-1)/2); % CEIL is required!
c1 = 101 ^ 2;
temp3 = zeros(row - window + wi); % Pre-allocate!!!
for k = 0:row-window
for l = 0:col-window
temp1 = double(l1(1+k:window+k, 1+l:window+l);
LocalMean = sum(temp1(:)) / numel(temp1);
kk = temp1(:) - LocalMean;
temp3(k+wi,l+wi) = (kk' * kk) / c;
end
end
wi = (window-1)/2 is not an integer for window = 100. You need CEIL,m FLOOR or ROUND.

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by