matlab_数字图像处理代码

%%%%%% 求对比度%%%%%%

clear;

clc;

[filename,pathname]=uigetfile({'*jpg;*.bmp;*.jpeg'},'load?image'); fpath=fullfile(pathname,filename);

A=imread(fpath);

figure(1);

imshow(A);

title('原图像')

img=rgb2gray(A);

figure(2);

imshow(img);

title('灰度后的');

img1=imnoise(img,'salt & pepper',0.05); %加入椒盐躁声

figure(3);

imshow(img1);

title('椒盐后的图像');

%%% K近邻域滤椒盐噪声%%% 3*3

%%% 找出与f(i,j)相近的像素值这里利用做差排序找出AAAA1=img1;

AAAA1=double(AAAA1);

%%%得到椒盐噪声图像

[m,n]=size(AAAA1);

for i=2:m-1

for j=2:n-1

ASD1=[AAAA1(i-1,j-1) AAAA1(i-1,j) AAAA1(i-1,j+1) ...

AAAA1(i,j-1) AAAA1(i,j) AAAA1(i,j+1) ...

AAAA1(i+1,j-1) AAAA1(i+1,j) AAAA1(i+1,j+1)];

aa=ASD1; %%随机设定的一个数组

b=AAAA1(i,j); %%取参照值

a=aa(:); %%将给定数组化为一维的

相关推荐
相关主题
热门推荐