MCPcopy Create free account
hub / github.com/boostorg/compute / showHistogramWindow

Function showHistogramWindow

example/opencv_histogram.cpp:71–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69);
70
71inline void showHistogramWindow(cv::Mat &b_hist, cv::Mat &g_hist, cv::Mat &r_hist,
72 std::string window_name)
73{
74 // Draw the histograms for B, G and R
75 int hist_w = 1024;
76 int hist_h = 768;
77 int bin_w = cvRound((double)hist_w/histSize);
78
79 cv::Mat histImage(hist_h, hist_w, CV_8UC3, cv::Scalar(0,0,0));
80
81 // Normalize the result to [ 0, histImage.rows ]
82 cv::normalize(b_hist, b_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat());
83 cv::normalize(g_hist, g_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat());
84 cv::normalize(r_hist, r_hist, 0, histImage.rows, cv::NORM_MINMAX, -1, cv::Mat());
85
86 // Draw for each channel
87 for (int i = 1; i < histSize; i++ )
88 {
89 cv::line(histImage,
90 cv::Point(bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1))),
91 cv::Point(bin_w*(i), hist_h - cvRound(b_hist.at<float>(i))),
92 cv::Scalar(255, 0, 0),
93 2,
94 8,
95 0);
96
97 cv::line(histImage,
98 cv::Point(bin_w*(i-1), hist_h - cvRound(g_hist.at<float>(i-1))),
99 cv::Point(bin_w*(i), hist_h - cvRound(g_hist.at<float>(i))),
100 cv::Scalar(0, 255, 0),
101 2,
102 8,
103 0);
104
105 cv::line(histImage,
106 cv::Point( bin_w*(i-1), hist_h - cvRound(r_hist.at<float>(i-1))),
107 cv::Point( bin_w*(i), hist_h - cvRound(r_hist.at<float>(i)) ),
108 cv::Scalar( 0, 0, 255),
109 2,
110 8,
111 0);
112 }
113
114 // Display
115 cv::namedWindow(window_name, CV_WINDOW_AUTOSIZE );
116 cv::imshow(window_name, histImage );
117}
118
119//Get the device context
120//Create GPU array/vector

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected