How to calculate image histogram of 32bit floating point image in OPenCV

梦想与她 提交于 2019-12-08 07:17:22

问题


I want to calculate histogram of an image hows pixels are of type 32F (32 bit floating point). What should be the parameter values of "calcHist" function for: - dims - bins - range


回答1:


Well I've done this many times. Something like so:

cv::Mat matSrc;    // this is a CV_32FC1 normalised image

int nHistSize = 65536;
float fRange[] = { 0.0f, 1.0f };
const float* fHistRange = { fRange };

cv::Mat matHist;
cv::calcHist(&matSrc, 1, 0, cv::Mat(), matHist, 1, &nHistSize, &fHistRange);

As it says in the documentation describing the source arrays:

Source arrays. They all should have the same depth, CV_8U or CV_32F , and the same size. Each of them can have an arbitrary number of channels.

So CV_32F is supported. In this situation, the range (in my example 0.0 to 1.0) is binned into the number of bins required (in my example 65536).



来源:https://stackoverflow.com/questions/26757702/how-to-calculate-image-histogram-of-32bit-floating-point-image-in-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!