- 代码
#include <iostream>
#include <opencv2/opencv.hpp>
#include <vector>
using namespace cv;
using namespace std;
int main()
{
Mat image = imread("house.jpg");
imshow("原图", image);
int n_image = 1;
int dims = 1;
MatND b_hist, g_hist, r_hist;
const int hist_size[]{
256 };
const float range[]{
0, 255};
const float *ranges[]{
range};
const int channel_b[]{
0};
calcHist(&image, 1, channel_b, Mat(), b_hist, dims, hist_size, ranges, true, false);
double b_max_value;
minMaxLoc(b_hist, nullptr