I am just trying to make an example to go off of to clean up gaussian noise from a picture without using the built in functions. My function should be replacing all the numbers not on the edges of my 6×6 matrix but it is only replacing the the (2,2) number. What am I doing wrong?
a = [1 2 3 4 5 6; 1 2 3 5 7 6; 3 4 5 6 7 8; 4 5 6 7 8 9; 1 2 3 1 2 3; 1 4 5 6 7 8];kernel = (1/16).*[1 2 1;2 4 2;1 2 1];[row,col]= size(a);ii= 1; jj= 3; mm= 1; kk= 3; tt= 2; yy= 2;for row = a(ii:jj) for col = a(mm:kk) result = a(ii:jj,mm:kk).* kernel; b= mean2(result); a(tt,yy)= b; mm= mm+1; kk= kk+1; tt= tt+1; if kk> col break; end end ii= ii+1; jj= jj+1; yy= yy+1; if jj> row break; endend
Best Answer