直方图涉及的函数(一):
int histSize[1] ;
float hranges[2] ;
const float * ranges[1] ;
int channels[1] ;
函数:cv::calcHist()获取图像直方图
cv::calcHist(&image,
1, // histogram of 1 image only
channels, // the channel used
cv::Mat(), // no mask is used
hist, // the resulting histogram
3, // it is a 3D histogram
histSize, // number of bins
ranges // pixel value range
);
函数:cv::minMaxLoc()获取图像矩阵中的最大最小值
cv::MatND hist = getHistogram(image) ;
double maxVal = 0 ;
double minVal = 0 ;
cv::minMaxLoc(hist , &minVal , &maxVal , 0 , 0) ;//获取最大值最小值
函数:cv::LUT()修改图像像素值Look Up Table
cv::LUT(image , lookup , result) ;//lookup是掩码
函数:cv::threshold()设置图像门限值
cv::Mat thresholded ;
// cv::threshold(image , thresholded ,
// 60.0 , 255.0 , cv::THRESH_BINARY) ;//60.0为分界线小于60.0为0,大于为255只有黑白两色
cv::line(histImg , cv::Point(h , histSize[0]) ,
cv::Point(h , histSize[0] - intensity) ,
cv::Scalar::all(0)) ;//画白色的线