What is the problem with my noise removal function?
古いコメントを表示
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 件のコメント
David Barry
2016 年 12 月 8 日
Why not just use built-in functions? This is the beauty and power of MATLAB.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!