标签:函数 src code for span main key stream ubi
图像读取和处理都是按BGR通道顺序进行的
1 #include <iostream> 2 #include <opencv2/opencv.hpp> 3 #include "opencv2/highgui/highgui.hpp" 4 #include "opencv2/imgproc/imgproc.hpp" 5 6 int main(int argc, char **argv) { 7 cv::Mat src = cv::imread("/home/cv/Downloads/images/P1180141.JPG", 1); 8 cv::resize(src, src, cv::Size(src.cols / 3, src.rows / 3), cv::INTER_CUBIC); 9 cv::imshow("original_after_resize", src); 10 11 // blue channel 12 cv::Mat mytemp1(src.rows, src.cols, CV_8UC3, cv::Scalar(255, 0, 0)); 13 cv::imshow("temp test", mytemp1); 14 // green channel 15 cv::Mat mytemp2(src.rows, src.cols, CV_8UC3, cv::Scalar(0, 255, 0)); 16 cv::imshow("temp test", mytemp2); 17 // red channel 18 cv::Mat mytemp3(src.rows, src.cols, CV_8UC3, cv::Scalar(0, 0, 255)); 19 cv::imshow("temp test", mytemp3); 20 cv::waitKey(0); 21 return 0; 22 }
或者使用mixChannels函数
1 #include <opencv2/opencv.hpp> 2 #include "opencv2/highgui/highgui.hpp" 3 #include "opencv2/imgproc/imgproc.hpp" 4 5 int main(int argc, char **argv) { 6 cv::Mat src = cv::imread("/home/cv/Downloads/images/P1180141.JPG", 1); 7 cv::resize(src, src, cv::Size(src.cols / 3, src.rows / 3), cv::INTER_CUBIC); 8 for (int i = 0; i < 3; i++) { 9 cv::Mat temp_bgr(src.rows, src.cols, CV_8UC3, cv::Scalar(0, 0, 0)); 10 cv::Mat temp(src.rows, src.cols, CV_8UC1); 11 cv::Mat out[] = {temp_bgr}; 12 int from_to[] = {i, i}; 13 cv::mixChannels(&src, 1, out, 1, from_to, 1); 14 cv::imshow("single channel", temp_bgr); 15 cv::waitKey(0); 16 } 17 18 return 0; 19 }
未完待续……
标签:函数 src code for span main key stream ubi
原文地址:https://www.cnblogs.com/phillee/p/11003473.html