【VC++、OpenCV3.4】直方图以及相关

直方图均衡化是提升图像对比度的有效方法,通过改变原始图像的直方图分布,扩大灰度值动态范围。OpenCV中的实现涉及8位单通道图像,通过统计像素值频率构建直方图。直方图比较包括相关性、卡方、十字交叉和巴氏距离四种方法,用于衡量图像相似度。
摘要由CSDN通过智能技术生成

直方图(Histogram)均衡化:是一种体改图像对比度的方法,拉伸图像灰度值范围。

/*
The algorithm normalizes the brightness and increases the contrast of the image.

@param src Source 8-bit single channel image.
@param dst Destination image of the same size and type as src .
 */
CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );

src必须是8位的单通道图像。

直方图均衡化思想:把原始图像的直方图变为均匀分布的的形式,这样就增加了像素灰度值的动态范围,从而达到了增强图像的整体对比度的效果。

直方图本身:

直方图是对一幅图像中出现的所有像素值的频次统计。将统计结果话在坐标系中,x横坐标代表像素值,y纵坐标代表的是对应像素值出现的次数。

除了对图像像素值的直方图,还有图像梯度、每个像素的角度、等一切图像的属性值,我们都可以建立直方图。但是,图像像素的直方图是最常见的。

直方图有几个属性:

dims:表示维度,对灰度图像来说只有一个通道,则dims=1;

bins:表示在维度中子区域大小划分,bins=256,划分为256个级别;

range:表示值的范围,灰度值范围为[0~255]之间。

相关API:

/*
@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same
size. Each of them can have an arbitrary number of channels.
@param nimages Number of source images.
@param channels List of the dims channels used to compute the histogram. The first array channels
are numerated from 0 to images[0].channels()-1 , the second array channels are counted from
images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.
@param mask Optional mask. If the matrix is not empty, it must be an 8-bit array of the same size
as images[i] . The non-zero mask elements mark the array elements counted in the histogram.
@
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值