I am trying to make my watermark transparent with low opacity, but it seems just setting the colors to white:
This is the code I'm using which BTW I found in some website
/////////////////// Blending Images (Making Alpha) //////////////////////// int main() { Mat img, img_bgra; string img_path = "res/test.png"; img = imread(img_path); if (img.data == NULL) { cout << "Image is not loaded!" << endl; return -1; } cvtColor(img, img_bgra, ColorConversionCodes::COLOR_BGR2BGRA); vector<Mat> channels(4); split(img_bgra, channels); channels[3] = channels[3] * 0.1; merge(channels.data(), 4, img_bgra); imwrite("res/transparent.png", img_bgra); imshow("Image", img_bgra); waitKey(0); return 0; }
I want the watermark to be displayed like this:
How can I achieve that?
https://stackoverflow.com/questions/65871641/c-how-to-make-transparent-watermark-using-opencv January 24, 2021 at 10:16PM
没有评论:
发表评论