opencv之通道分離和合並
阿新 • • 發佈:2019-01-12
opencv之通道分離和合並
- 通道分離
void split(const Mat& src, Mat* mvbegin);
void split(InputArray m, OutputArrayOfArrays mv);
- 通道合併
void merge(const Mat* mv, size_t count, OutputArray dst);
void merge(InputArrayOfArrays mv, OutputArray dst);
- 例項
#include <opencv2/core.hpp> #include <opencv2/highgui.hpp> std::string image_name = "/home/liuzhiyang/test/color_image.png"; cv::Mat color_image; color_image = cv::imread(image_name, cv::IMREAD_COLOR); std::vector<cv::Mat> v_channel; cv::Mat blue_channel, green_channel, red_channel; cv::split(color_image, v_channel); blue_channel = v_channel.at(0); green_channel = v_channel.at(1); blue_channel = v_channel.at(2); cv::Mat merge_image; cv::merge(v_channel, merge_image);