include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(){
Mat pic = imread("/Users/leung/Documents/imgs/lena.jpg");
Mat pic_half,hsvchannels[3],hsv;
pyrDown(pic, pic_half);
cvtColor(pic_half, hsv, COLOR_BGR2HSV);
split(hsv, hsvchannels);
imshow("b", hsvchannels[0]);
imshow("g", hsvchannels[1]);
imshow("r", hsvchannels[2]);
waitKey();
return 0;
}
分解通道彩色显示
include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(){
Mat img = imread("/Users/leung/Documents/imgs/lena.jpg");
//用于之后彩色的b通道
Mat b_color;
vector<Mat> bchannel;
split(img, bchannel);
//另外两个通道置0;
bchannel[1] = Scalar(0);
bchannel[2] = Scalar(0);
//合并三个通道
merge(bchannel, b_color);
imshow("b", bchannel);
waitKey();
return 0;
}