隨便寫了一個方法,沒最佳化,執行速度有點慢。對於影象範圍邊界,只跟影象內部點做均值。
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;
if j==1
rows=1;
rowe=2;
if j==row
rows=row-1;
rowe=row;
for m=lines:1:linee
for n=rows:1:rowe
temp=temp+A(m,n);
B(i,j)=temp/((linee-lines+1)*(rowe-rows+1));
subplot(1,2,2)
imshow(B);
隨便寫了一個方法,沒最佳化,執行速度有點慢。對於影象範圍邊界,只跟影象內部點做均值。
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);