Why can't the variable "sumt" in my for loop keep on adding numbers?
Afficher commentaires plus anciens
function out = blur(m,w)
[r,c] = size(m);
out = ones(r,c)*255;
for kk= 1:c
for ll = 1:r
out(kk,ll) = finddims(m,kk,ll,w,r,c);
end
end
end
function ave = finddims(mat,x,y,w,row,col)
sumt = 0;
cou =0;
i1= x-w;
i2 = x+w;
j1 = y-w;
j2 = y+w;
if i1<1
i1 =1;
elseif i2>col
i2 = col;
end
if j1<1
j1 = 1;
elseif j2>row
j2 = row;
end
for mm= i1:i2
for nn = j1:j2
sumt = sumt + mat(nn,mm); % sum doesn't keep on adding in the loop
cou = cou+1;
end
end
ave = uint8(sumt/cou);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!