马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
- 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);
- [m,n]=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
复制代码 |