function J=gamma_filter(Img,deta)
window_size=7;
delta=deta;
p=2*delta;
K=3;
if(ndims(Img)==3)
Img=rgb2gray(Img);
end;
[height width]=size(Img);
J=zeros(height,width);
J=uint8(J);
for i=1:height
for j=1:width
total=0;
total_1=0;
count=0;
count_1=0;
for k=i-floor(window_size/2):i+floor(window_size/2)
if(k<=0 || k>height)
continue;
end;
for l=j-floor(window_size/2):j+floor(window_size/2);
if(l<=0 || l>width)
continue;
end;
if(Img(k,l)>=Img(i,j)-p && Img(k,l)<=Img(i,j)+p)
total=total+double(Img(k,l));
count=count+1;
end;
total_1=total_1+double(Img(k,l));
count_1=count_1+1;
end;
end;
if(count>K)
J(i,j)=total/count;
else
J(i,j)=total_1/count_1;
end;
end;
end;
end
實現過程較簡單,抱歉不加註釋