2
什麼是墊的一個信道設定爲一個值,同時使其他通道的電流值的最佳方式?的OpenCV設置一個信道爲一個值C++
例如,如果我有一個4通道矩陣,出於某種原因,我需要將其中一個通道設置爲某個值,但其他通道保留其當前值,哪種操作最好?
謝謝!
什麼是墊的一個信道設定爲一個值,同時使其他通道的電流值的最佳方式?的OpenCV設置一個信道爲一個值C++
例如,如果我有一個4通道矩陣,出於某種原因,我需要將其中一個通道設置爲某個值,但其他通道保留其當前值,哪種操作最好?
謝謝!
僞代碼,您可以編寫一個函數,輸入的圖像是這樣的:
爲例如
Mat img(5,5,CV_64FC3); // declare three channels image
Mat ch1, ch2, ch3; // declare three matrices
// "channels" is a vector of 3 Mat arrays:
vector<Mat> channels(3);
// split img:
split(img, channels);
// get the channels (follow BGR order in OpenCV)
ch1 = channels[0];
ch2 = channels[1];
ch3 = channels[2];
// modify channel// then merge
merge(channels, img);
咕d樣品THX! – 2017-09-20 08:10:42