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
实现过程较简单,抱歉不加注释
本文介绍了一种基于局部像素灰度值的Gamma滤波算法实现方法。该算法使用7x7窗口进行局部区域像素值的统计,并根据条件计算每个像素点的滤波结果。对于图像中的每一个像素点,算法首先确定其邻域内的有效像素范围,然后计算平均值作为滤波输出。此方法适用于灰度图像处理。
8万+

被折叠的 条评论
为什么被折叠?



