图像增强(2) 直方图增强(matlab)

直方图增强

imhist():

数字图像中每一灰度级与该灰度级出现的频数之间的关系

imhist(I,n):
I:灰度图像;
n:灰度级数目。
imhist(X,map):
X:绘制索引图像X的直方图;
map:颜色映射表。

灰度图像:

>> I=imread('E:\persional\matlab\images\ba.tif');
>> figure,
>> subplot(121),imshow(I);
>> subplot(122),imhist(I);

在这里插入图片描述
RGB图像:

>> I=imread('E:\persional\matlab\images\ad1.tif');
>> figure,
>> subplot(141),imshow(I);
>> subplot(142),imhist(I(:,:,1));%计算R
>> subplot(143),imhist(I(:,:,2));%计算G
>> subplot(144),imhist(I(:,:,3));%计算B

在这里插入图片描述
彩色图像的HSV分量直方图:

>> I=imread('E:\persional\matlab\images\ad2.tif');
>> J = rgb2hsv(I);
>> figure,
>> subplot(141),imshow(I);
>> subplot(142),imhist(J(:,:,1));%计算H
>> subplot(143),imhist(J(:,:,2));%计算S
>> subplot(144),imhist(J(:,:,3));%计算V

在这里插入图片描述

直方图均衡化

利用灰度变换自动调节图像对比度质量的方法

histeq()

J = histeq(I,n):
I:灰度图像;
n:灰度级数目。

>> I=imread('E:\persional\matlab\images\ba.tif');
>> J = histeq(I);
>> figure,
>> subplot(221),imshow(I);
>> subplot(222),imshow(J);
>> subplot(223),imhist(I,64);
>> subplot(224),imhist(J,64);

在这里插入图片描述

直方图规定化

直方图均衡化所产生所产生的直方图是近似均匀的,但有时候为了图像中某些灰度级加以增强,从而得到特定的直方图图像。

histeq()

J = histeq(I,hgram):
I:原始图像;
hgram:整数向量,表示希望直方图形状,向量越短,直方图越接近希望的直方图。

扫描二维码关注公众号,回复: 15368584 查看本文章
>> I=imread('E:\persional\matlab\images\ba.tif');
>> hgram = ones(1,256);
>> J = histeq(I,hgram);
>> figure,
>> subplot(121),imshow(J);
>> subplot(122),imhist(J);

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_56260304/article/details/127341599