Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/opencv.hpp>
- #include <vector>
- int main()
- {
- cv::Mat3b image(cv::imread("lena3.png", cv::IMREAD_COLOR));
- if (image.empty()) {
- std::cerr << "Failed to load image.";
- return -1;
- }
- cv::Mat3b roi(image(cv::Rect(64, 128, 32, 32)));
- cv::Mat3d column_color_sums;
- cv::reduce(roi, column_color_sums, 0, cv::REDUCE_SUM);
- std::vector<double> column_sums(column_color_sums.cols, 0);
- cv::transform(column_color_sums, column_sums, cv::Matx13d(1, 1, 1));
- for (auto v : column_sums) {
- std::cout << v << " ";
- }
- std::cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement