随便写了一个方法,没优化,运行速度有点慢。对于图像范围边界,只跟图像内部点做均值。
clear all
clc
A=imread('manuo1.jpg');
A=im2double(A);
subplot(1,2,1)
imshow(A);
[line,row]=size(A);
lines=0;
rows=0;
linee=0;
rowe=0;
temp=0;
B=[];
for i=1:1:line
for j=1:1:row
lines=i-1;
linee=i+1;
rows=j-1;
rowe=j+1;
if i==1
lines=1;
linee=2;
end
if i==line
lines=line-1;
linee=line;
end
if j==1
rows=1;
rowe=2;
end
if j==row
rows=row-1;
rowe=row;
end
temp=0;
for m=lines:1:linee
for n=rows:1:rowe
temp=temp+A(m,n);
end
end
B(i,j)=temp/((linee-lines+1)*(rowe-rows+1));
end
end
subplot(1,2,2)
imshow(B);