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!