程序内容描述如下:
1.显示图像的直方图
2.直方图均衡化用于增强图像的对比度,并显示直方图均衡化前后的图像与图像的直方图
程序代码如下:
%Part 1
h=imread('cameraman.tif');
subplot(1,2,1),imshow(h);
subplot(1,2,2),imhist(h),
grid on,
ylabel('pixel count');
%Part 2
h=imread('cameraman.tif');
subplot(1,6,1),imshow(h);
g=histeq(h,40:60);
j=imadjust(h,[0.3,0.7],[]);
subplot(1,6,2),imshow(g);
subplot(1,6,5),imhist(g);
subplot(1,6,3),imshow(j);
subplot(1,6,6),imhist(j);
subplot(1,6,4),imhist(h),
grid on,
ylabel('pixel count');
程序原理如下:
part1,使用imread函数读取电脑磁盘中的图像cameraman.tif,使用函数imshow在图像窗口中显示图像,然后使用函数imhist获取图像的直方图并在图像窗口中显示。
part2, 分别使用函数histeq和函数imadjust来均衡图像cameraman.tif的直方图,以增强图像对比度。我们使用函数imshow在图像窗口中显示原始图像、由函数histeq处理的图像和由函数imadjust处理的图像,然后使用函数imhist在图像窗口中显示三幅图像的直方图。
程序运行结果如下:
part1:
图1:图像cameraman.tif及其直方图
part2:
图2:原始图像、增强对比度后的图像以及每幅图像的直方图
看到这里的小伙伴别忘了点个赞再走哦!
关注博主学习更多数字图像处理知识!