代码拉取完成,页面将自动刷新
// Example 10-2. Alternative method to combine and threshold image planes
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
void sum_rgb( const cv::Mat& src, cv::Mat& dst ) {
// Split image onto the color planes.
//
vector<cv::Mat> planes;
cv::split(src, planes);
cv::Mat b = planes[0], g = planes[1], r = planes[2];
// Accumulate separate planes, combine and threshold.
//
cv::Mat s = cv::Mat::zeros(b.size(), CV_32F);
cv::accumulate(b, s);
cv::accumulate(g, s);
cv::accumulate(r, s);
// Truncate values above 100 and rescale into dst.
//
cv::threshold( s, s, 100, 100, cv::THRESH_TRUNC );
s.convertTo(dst, b.type());
}
void help(char **argv) {
cout << "\nExample 10-2. Alternative method to combine and threshold image planes\n" << endl;
cout << "\nCall:\n" << argv[0] << " ../faces.jpg\n" << endl;
}
int main(int argc, char** argv) {
help(argv);
if(argc < 2) { cout << "specify input image" << endl; return -1; }
// Load the image from the given file name.
//
cv::Mat src = cv::imread( argv[1] ), dst;
if( src.empty() ) { cout << "can not load " << argv[1] << endl; return -1; }
sum_rgb( src, dst);
// Create a named window with the name of the file and
// show the image in the window
//
cv::imshow( argv[1], dst );
// Idle until the user hits any key.
//
cv::waitKey(0);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。