给你一个M文件 里面有你要的所有东西! 可以直接运行看结果的哦1
回复不知道什么上传附件,直接粘贴了哦!
%2
subplot(3,2,1);
i=imread('Fig3.20(a).jpg');
imhist(i);title('org hist');
subplot(3,2,2);
i=im2double(i);
imshow(i);title('org img');
subplot(3,2,3);
iee=histeq(i);
imhist(iee);title('hist hsit');
subplot(3,2,4);
imshow(iee);title('histed img');
r=1:255;
n=1400*r.*[r<=5]+[7000-310*r].*[r>5].*[r<=20]+[900-5*r].*[r>20].*[r<=180]+[8*r-1440].*[r>180].*[r<=225]+[3060-12*r].*[r<=255].*[r>225];
subplot(3,2,5);
ie=histeq(i,n);
ie=ie*255;
ie=uint8(ie);
imhist(ie);title('after histogram matching hist');
subplot(3,2,6);
imshow(ie);title('after histogram matching img');
figure;
subplot(3,2,1);
plot(r,n);title('2 :r ,n fuctoin');
%3
i3=imread('Fig3.24.jpg');
i3=im2double(i3);
subplot(3,2,2);
imshow(i3);title('3 :org img ');
mxy=nlfilter(i3,[3 3],@mean2);
subplot(3,2,3);
imshow(mxy);title('mean2 img');
cxy=nlfilter(i3,[3 3],@std2);
subplot(3,2,4);
imshow(cxy);title('std2 img');
subplot(3,2,5);
Mg=mean2(i3);
Dg=std2(i3);
k0=0.4, k1=0.02, k2=0.4;
e=10;
g=e*i3.*[mxy<=k0*Mg].*[cxy>=k1*Dg].*[cxy<=k2*Dg]+i3.*[mxy<=k0*Mg |cxy>=k1*Dg | cxy<=k2*Dg];
imshow(g);
%4
figure;
i4=imread('Fig5.10(a).jpg');
i4=im2double(i4);
subplot(3,2,1);
imshow(i4);title('4 :org img ');
h = fspecial('average',[3 3]); %生成一3×3邻域平均窗函数
Y = filter2(h,i4); %求邻域平均
subplot(3,2,2);
imshow(Y);title('fspecial and filter img');
YY=medfilt2(i4); %中值滤波
subplot(3,2,3);
imshow(YY);title('medfilt2 img');