MATLAB: For loop stoping mid way with empty array

MATLAB: For loop stoping mid way with empty array

convolutionfor loop problem functionImage Processing Toolbox

Hi,
I’m doing a university project with images using guide.
But in my method to determin the mean of an image using a box value, my for loop stops mid way, l becomes [] and i don’t know why.
function [ imagemFinal ] = toMeanAluno( imagem, masc )
aux = idivide(int32(masc), int32(2));
contador = 0;
valor = 0;
imagemFinal = imagem;
for i = 1+aux:size(imagem,1)-aux
for j = 1+aux:size(imagem,2)-aux
for k = i-aux:masc
for l = j-aux:masc
valor = valor + imagem(k,l);
contador = contador + 1;
end;
end;
imagemFinal(i,j) = valor / contador;
valor = 0;
contador = 0;
end;
end;
end

Best Answer

  • If you want a fully manual version of convolution with no calling conv2() or imfilter(), then see the attached demo code (below these images that it creates).
  • Add a Comment

    Your email address will not be published. Required fields are marked *