实验3 绘制图像直方图、直方图像均衡化操作

1.读入一幅自己拍摄的照片,分别用 imhist、bar、stem 及 plot 四种方法绘制对应的直方图,在同一个窗口内分成四个子窗口来分别显示,注上文字标题。

f=imread('test4-1.jpg');
f1=rgb2gray(f);
subplot(221),imhist(f1,25),title('imhist');
h=imhist(f1,25);
subplot(222),bar(h);title('bar');
[count,x]=imhist(f1,25);
subplot(223),stem(x,count);title('stem');
subplot(224),plot(h);title('plot');


2.在同一坐标内绘制四条曲线,正弦曲线、余弦曲线以及两个函数定义的曲线。

x=0:pi/100:2*pi;
y1=sin(x);
y2=cos(x);
y3=0.2*exp(-0.5*x).*cos(4*pi*x);
y4=2*exp(-0.5*x).*cos(pi*x);
subplot(2,1,1);
plot(x,y1,'r-o');hold on;
plot(x,y2,'b:+');hold on;
plot(x,y3,'c--d');hold on;
plot(x,y4,'g-.s');hold off;
title(' hold on 图形保持');
subplot(2,1,2);
plot(x,y1,'r-o',x,y2,'b:+',x,y3,'c--d',x,y4,'g-.s');
title('plot(x1,y1,x2,y2,……)格式');


3. 读入图像 pout.tif,并进行直方图均衡化操作,在同一个窗口内分别显示原图、原图直方图、均衡化之后的图、均衡化后的直方图

I=imread('test4-3.tif');
J=histeq(I);
subplot(2,2,1),imshow(I);title('原图');
subplot(2,2,2),imhist(I);title('原图直方图');
subplot(2,2,3),imshow(J);title('原图均衡化');
subplot(2,2,4),imhist(J);title('均衡化直方图');


4.读入图像 pout.tif 及三幅自己拍摄的图像,分别用三个自己拍摄的图像规定化读入图像 pout.tif 的直方图,对比规定化之后图像效果

f=imread('test4-3.tif');
X1=imread('test4-4.jpg');
f1=rgb2gray(X1);
f2=histeq(f,imhist(f1));
subplot(3,2,1),imshow(f);
subplot(3,2,2),imhist(f);
subplot(3,2,3),imshow(X1);
subplot(3,2,4),imhist(f1);
subplot(3,2,5),imshow(f2);
subplot(3,2,6),imhist(f2);
  • 0
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值