最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

matlab 均值滤波(原创)

来源:动视网 责编:小OO 时间:2025-09-26 23:57:54
文档

matlab 均值滤波(原创)

clearall;closeall;P=input('inputpicturedata:');d=size(P);if(d(3)>1)P=rgb2gray(P);endchoice=1;while(choice~=0)P=imnoise(P,'salt&pepper',0.02);subplot(221);imshow(P);title('加入椒盐噪声后的图像');P=double(P);[mn]=size(P);g=zeros(m,n);m1=m+2;n1=n+2;PP=zeros(m1,n
推荐度:
导读clearall;closeall;P=input('inputpicturedata:');d=size(P);if(d(3)>1)P=rgb2gray(P);endchoice=1;while(choice~=0)P=imnoise(P,'salt&pepper',0.02);subplot(221);imshow(P);title('加入椒盐噪声后的图像');P=double(P);[mn]=size(P);g=zeros(m,n);m1=m+2;n1=n+2;PP=zeros(m1,n
clear all;

close all;

P=input('input picture data:');

d=size(P);

if(d(3)>1)

    P=rgb2gray(P);

end

choice=1;

while(choice~=0) 

P=imnoise(P,'salt & pepper',0.02);

subplot(221);imshow(P);

title('加入椒盐噪声后的图像');

P=double(P);

[m n]=size(P);

g=zeros(m,n);

 m1=m+2;

    n1=n+2;

PP=zeros(m1,n1);

for i=2:m1-1

    for j=2:n1-1

        PP(i,j)=P(i-1,j-1);

    end

end        

PP(1,2:n1-1)=P(2,1:n);

PP(m1,2:n1-1)=P(m-1,1:n);

PP(1:m1,1)=PP(1:m1,3);

PP(1:m1,n1)=PP(1:m1,n1-2);

disp('-----------------------------------------------');

disp('                 主菜单                 ');

disp('The Number of Ngeighbourhood-Averageing Method ');

disp('         4、 4邻域平均                 ');

disp('         8、 8邻域平均,不考虑点本身亮度        ');

disp('         9、 8邻域平均,考虑点本身亮度          ');

disp('----------------------------------------------');

choice=input('Please input the number of method:(4,8,9),0表示结束\\n')

switch (choice)

    case 4

        for i=2:m1-1

            for j=2:n1-1

                g(i,j)=(PP(i-1,j)+PP(i+1,j)+PP(i,j-1)+PP(i,j+1))/4;

            end

        end

        g=uint8(g);

        subplot(222);imshow(g);

        title('经4邻域平均去噪后的图片');

    case 8

        for i=2:m1-1

            for j=2:n1-1

                g(i,j)=(PP(i-1,j-1)+PP(i-1,j)+PP(i-1,j+1)+PP(i,j-1)+PP(i,j+1)+PP(i+1,j-1)+PP(i+1,j)+PP(i+1,j+1))/8;

            end

        end

        g=uint8(g);

        subplot(223);imshow(g);

        title('经8邻域平均,不考虑点本身亮度去噪后的图片');

    case 9

        for i=2:m1-1

            for j=2:n1-1

                g(i,j)=(PP(i-1,j-1)+PP(i-1,j)+PP(i-1,j+1)+PP(i,j-1)+PP(i,j)+PP(i,j+1)+PP(i+1,j-1)+PP(i+1,j)+PP(i+1,j+1))/9;

            end

        end

        g=uint8(g);

        subplot(224);imshow(g);

        title('经8邻域平均,考虑点本身亮度去噪后的图片');

        otherwise

        disp('error')

end

  choice=input('是否继续?(1/0):'); 

  P=uint8(P);

end

文档

matlab 均值滤波(原创)

clearall;closeall;P=input('inputpicturedata:');d=size(P);if(d(3)>1)P=rgb2gray(P);endchoice=1;while(choice~=0)P=imnoise(P,'salt&pepper',0.02);subplot(221);imshow(P);title('加入椒盐噪声后的图像');P=double(P);[mn]=size(P);g=zeros(m,n);m1=m+2;n1=n+2;PP=zeros(m1,n
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top