Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
chirag
chirag el 28 de Ag. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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]

Respuestas (1)

Jan
Jan el 28 de Ag. de 2012
Editada: Jan el 28 de Ag. de 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.

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by