1 | initial version |
You can also use mixChannels function:
cv::Mat percepUnit::applyAlpha(const cv::Mat& image, const cv::Mat& mask)
{
cv::Mat alphaImage;
cv::Mat src[] = {image, mask};
int from_to[] = {0,0, 1,1, 2,2, 3,3};
cv::mixChannels(src, 2, &alphaImage, 1, from_to, 4);
return alphaImage;
}
2 | No.2 Revision |
You can also use mixChannels function:function (it must be faster than split/merge approach, because it doesn't require additional buffers):
cv::Mat percepUnit::applyAlpha(const cv::Mat& image, const cv::Mat& mask)
{
cv::Mat alphaImage;
cv::Mat src[] = {image, mask};
int from_to[] = {0,0, 1,1, 2,2, 3,3};
cv::mixChannels(src, 2, &alphaImage, 1, from_to, 4);
return alphaImage;
}