What is the problem with my noise removal function?
Ältere Kommentare anzeigen
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 6x6 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;
end
end
1 Kommentar
David Barry
am 8 Dez. 2016
Why not just use built-in functions? This is the beauty and power of MATLAB.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!