Skip to content

Instantly share code, notes, and snippets.

@berkayakcay
Created December 3, 2016 15:36
Show Gist options
  • Save berkayakcay/fb4e6ca77fb0572c606126b4af95581e to your computer and use it in GitHub Desktop.
Save berkayakcay/fb4e6ca77fb0572c606126b4af95581e to your computer and use it in GitHub Desktop.
%{ Filters
% near 2 | 4 | 6
%
% mean
% (4,4) (4,5) (4,6)
% (5,4) (5,5) (5,6)
% (6,4) (6,5) (6,6)
%
% %}
function SI = meanFilter(I)
[R,C] = size(I);
SI = uint8(zeros(R,C));
for r=1:R
for c=1:C
total = 0.0;
counter = 0;
for i=-1:1
for j=-1:1
if(((r+i)>0) && ((c+j)>0) && ((r+i)<=R) && ((c+j)<=C))
total = total + double(I(r+i,c+j));
counter = counter + 1;
end
end
end
SI(r,c)= total/counter;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment