Advertisement
dan-masek

Untitled

May 3rd, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <opencv2/opencv.hpp>
  2. #include <vector>
  3.  
  4. int main()
  5. {
  6.     cv::Mat3b image(cv::imread("lena3.png", cv::IMREAD_COLOR));
  7.     if (image.empty()) {
  8.         std::cerr << "Failed to load image.";
  9.         return -1;
  10.     }
  11.  
  12.     cv::Mat3b roi(image(cv::Rect(64, 128, 32, 32)));
  13.  
  14.     cv::Mat3d column_color_sums;
  15.     cv::reduce(roi, column_color_sums, 0, cv::REDUCE_SUM);
  16.  
  17.     std::vector<double> column_sums(column_color_sums.cols, 0);
  18.     cv::transform(column_color_sums, column_sums, cv::Matx13d(1, 1, 1));
  19.  
  20.     for (auto v : column_sums) {
  21.         std::cout << v << " ";
  22.     }
  23.     std::cout << "\n";
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement