一个用matlab实现的基于图像灰度概率分布的图像模糊增强算法
function d = directory(v)%求出当前路径上的所有文件列表
v='IM2';
d(1).name = '.';
counter = max(size(d));
dire = dir(v);
temp = size(dire,1);
for loop = 1:temp
if dire(loop).isdir == 0
counter = counter+1;
d(counter).name = fullfile(v,dire(loop).name);
end
if strcmp(dire(loop).name,'.') == 0&strcmp(dire(loop).name,'..') == 0&dire(loop).isdir == 1
I = directory(fullfile(v,dire(loop).name));
ma = max(size(d));
for ii = 2:max(size(I));
ma = ma+1;
d(ma).name = I(ii).name;
end
end
end
for num=2:counter
im=imread(d(num).name);
im=double(im);
mean=mean2(im);
=size(im);
maxGray=max(im(:));
minGray=min(im(:));
b1=(minGray+mean)/2;
b2=(maxGray+mean)/2;
for x=1:m
for y=1:n
if im(x,y)>=minGray & im(x,y)<b1
FuzzyData(x,y)=2*(((im(x,y)-minGray)/(mean-minGray))^2);
im(x,y)=im(x,y)*(FuzzyData(x,y)^2);
elseif im(x,y)>=b1 & im(x,y)<mean
FuzzyData(x,y)=1-(2*(((im(x,y)-mean)/(mean-minGray))^2));
im(x,y)=im(x,y)*(FuzzyData(x,y)^2);
elseif im(x,y)>=mean & im(x,y)<b2
FuzzyData(x,y)=1-2*(((im(x,y)-mean)/(maxGray-mean))^2);
im(x,y)=im(x,y)*(FuzzyData(x,y)^2);
elseif im(x,y)>=b2 & im(x,y)<maxGray
FuzzyData(x,y)=2*(((im(x,y)-mean)/(maxGray-mean))^2);
im(x,y)=im(x,y)*(FuzzyData(x,y)^2);
end
end
end
f=fullfile('F:\ExperimentResult\IM2Result1',d(num).name);
csvwrite(f,im);
end
%csvread
页:
[1]