Created
January 17, 2017 17:50
-
-
Save acarabott/5030cfd7f9af5f6ccd10ded1d65cc64c to your computer and use it in GitHub Desktop.
Adding alpha channel to a 3 channel openCV Mat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void createAlphaImage(const cv::Mat& mat, cv::Mat_<cv::Vec4b>& dst) | |
{ | |
std::vector<cv::Mat> matChannels; | |
cv::split(mat, matChannels); | |
// create alpha channel | |
cv::Mat alpha = matChannels.at(0) + matChannels.at(1) + matChannels.at(2); | |
matChannels.push_back(alpha); | |
cv::merge(matChannels, dst); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment