用MATLAB编程实现平均滤波算法吗?
:69回复:2关注手机版
解决时间2021-01-26 22:33
提问者的女性不需要倾国倾城
2021-01-26 07:49
用MATLAB编程实现平均滤波算法吗? (采用33窗口)要求简洁明了
最佳答案
二级知识专家闪耀的男人
2021-01-26 08:52
1 ) smoothingaveragefiltermain.mclc; clear FID=fopen(Lenai.raw ); temp=fread(FID,[ 256,256 ] ); Lenaraw=uint8(temp ); subplot (1,2,1 ) imshow ) Lenaraw; title (原始图像) ) subplot (1,2,2 ) imshow ) smoothingaveragefilter ) Lenaraw,3 ); title ()自定义函数,3*3模板,按平均值过滤图像)2: smoothingaveragefilter.mfunctionreturndata=smoothingaveragefilter (arg ) returndata=Zeros(iwidth,Ilength ); totalLength=arg2*arg2; fori=13360 iwidth-arg 21 forj=1: ilength-arg 21 % temp (I,j )=average ) arg ) j:j arg2,j:j arg2); sum=0.0; forn=1: arg2fork=1: arg2sum=sum temp (in-1,j k-1 ); endendreturndata(I,j )=sum/totalLength; endend return data=uint8(return data; 结束
全部回答
一楼楮浓
2021-01-26 09:11
我随便写了方法,但是没有优化,执行速度有点慢。 对于图像范围的边界,只与图像内的点进行平均化。
clear all
clc
a=imread(manuo1.jpg );
a=im2double(a );
(1,2,1 ) )。
imshow(a );
[line,row]=size(a );
lines=0;
rows=0;
linee=0;
rowe=0;
temp=0;
b=[];
for I=1:1:线
for j=1:1:row
lines=i-1;
linee=i 1;
rows=j-1;
rowe=j 1;
if i==1
lines=1;
linee=2;
结束
if i==line
lines=line-1;
linee=line;
结束
if j==1
rows=1;
rowe=2;
结束
if j==row
rows=row-1;
rowe=row;
结束
temp=0;
for m=lines:1:linee
for n=rows:1:rowe
temp=tempa(m,n );
结束
结束
b(I,j )=temp/) (linee-lines1) * ) *(rowe-rows 1);
结束
结束
subplot (1,2,2 ) ) )。
imshow(b;
我会报警的
如果以上信息为低俗、色情、不良、暴力、侵权、违法等信息,请单击以下链接举报。
推荐信息
大家都在看