一维均值滤波算法matlab,用MATLAB编程实现均值滤波算法?
用MATLAB編程實現均值濾波算法?
關注:69??答案:2??手機版
解決時間 2021-01-26 22:33
提問者女人不需要傾國傾城
2021-01-26 07:49
用MATLAB編程實現均值濾波算法? (采用3×3的窗口) 要求簡潔 明了
最佳答案
二級知識專家閃光的男人
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.mfunction returnData=smoothingAverageFilter(arg,arg2)[Iwidth,Ilength]=size(arg);temp=double(arg);returnData=zeros(Iwidth,Ilength);totalLength=arg2*arg2;for i=1:Iwidth-arg2+1 for j=1:Ilength-arg2+1 % temp(i,j)=average(arg(i:i+arg2,j:j+arg2)); sum=0.0; for n=1:arg2 for k=1:arg2 sum=sum+temp(i+n-1,j+k-1); end end returnData(i,j)=sum/totalLength; endendreturnData=uint8(returnData);end
全部回答
1樓椥揂濃
2021-01-26 09:11
隨便寫了一個方法,沒優化,運行速度有點慢。對于圖像范圍邊界,只跟圖像內部點做均值。
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);
我要舉報
如以上信息為低俗、色情、不良、暴力、侵權、涉及違法等信息,可以點下面鏈接進行舉報!
推薦資訊
大家都在看
總結
以上是生活随笔為你收集整理的一维均值滤波算法matlab,用MATLAB编程实现均值滤波算法?的全部內容,希望文章能夠幫你解決所遇到的問題。