数字图像处理实验作业及代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

数字图像处理—实验一

源程序:

a=imread('rice.png');

figure,imshow(a),title('原图');axis on;

a=double(a)/256;

figure,imhist(a),title('原直方图');axis on;

r=[0:0.001:1];

s1=[r<0.35].*r*0.3+[r<=0.65].*[r>=0.35].*(0.105+2.6333*(r-0.35))+[r>0.65].*( 1+0.3*(r-1));

s2=[r<=0.5].*(r.^5)*15.9744+[r>0.5].*((r-0.5).^0.2+0.12);

a1=[a<0.35].*a*0.3+[a<=0.65].*[a>=0.35].*(0.105+2.6333*(a-0.35))+[a>0.65].* (1+0.3*(a-1));

a2=[a<=0.5].*(a.^5)*15.9744+[a>0.5].*((a-0.5).^0.2+0.12);

figure,imshow(a1),title('改后一');axis on;

figure,imhist(a1),title('改后直方图一');axis on;

figure,plot(r,s1),title('变换函数一');axis on;

figure,imshow(a2),title('改后二');axis on;

figure,imhist(a2),title('改后直方图二');axis on;

figure,plot(r,s2),title('变换函数二');axis on;

imwrite(a1,'改后rice 一.jpg');

imwrite(a2,'改后rice 二.jpg');

b=imread('kids.tif');

figure,imshow(b),title('原图');axis on;

b=double(b)/256;

figure,imhist(b);title('原直方图');axis on;

s1=r.^0.6;

s2=r.^0.4;

s3=r.^0.3;

b1=imadjust(b,[],[],0.6);

b2=imadjust(b,[],[],0.4);

b3=imadjust(b,[],[],0.3);

figure,imshow(b1),title('改后一');axis on;

figure,imhist(b1),title('改后直方图一');axis on;

figure,plot(r,s1),title('变换函数一');axis on;

figure,imshow(b2),title('改后二');axis on;

figure,imhist(b2),title('改后直方图二');axis on;

figure,plot(r,s2),title('变换函数二');axis on;

figure,imshow(b3),title('改后三');axis on;

figure,imhist(b3),title('改后直方图三');axis on;

figure,plot(r,s3),title('变换函数三');axis on;

imwrite(b1,'改后kids 一.jpg');

imwrite(b2,'改后kids 二.jpg');

imwrite(b3,'改后kids 三.jpg');

c=imread('circuit.tif');

figure,imshow(c),title('原图');axis on;

c=double(c)/256;

figure,imhist(c),title('原直方图');axis on;

s=1-r;

c=1-c;

figure,imshow(c),title('变换后');axis on;

figure,imhist(c),title('变换后直方图');axis on;

figure,plot(r,s),title('变换函数');axis on;

imwrite(c,'改后circuit.jpg');

d=imread('rice.png');

figure,imshow(d),title('原图');axis on;

d=double(d)/256;

figure,imhist(d),title('原直方图');axis on;

r=[0:0.001:1];

s=[r<=0.4].*[r>=0.2]*0.6;

d=[d<=0.4].*[d>=0.2]*0.6+[d>0.4].*d+[d<0.2].*d;

figure,imshow(d),title('变换后');axis on;

figure,imhist(d),title('变换后直方图');axis on;

figure,plot(r,s),title('变换函数');axis on;

imwrite(d,'第二次改后rice.jpg');

e=imread('Picture.jpg');

e=e(:,:,1);

e=im2double(e);

figure,imshow(e),title('原图');axis on;

figure,imhist(e),title('原直方图');axis on;

r=[0:0.001:1];

s=[r<0.3].*r*1.1+[r>0.65].*r*0.8+[r>=0.3].*[r<=0.65].*(0.11+r*1.5); e=[e<0.3].*e*1.1+[e>0.65].*e*0.8+[e>=0.3].*[e<=0.65].*(0.11+e*1.5); figure,imshow(e),title('变换后');axis on;

figure,imhist(e),title('变换后直方图');axis on;

figure,plot(r,s),title('变换函数');axis on;

imwrite(e,'改后Picture.jpg');

处理前后图像:

相关文档
最新文档