C++ opencv efficiently implements transparent masks and boundaries

To do this, I’ve used Python Matplotlib, as shown below, but it’s very slow.
C++ OpenCV can effectively implement transparent masks and boundaries?
thank you

and, what is the problem, behind your question ?
what kind of task are you trying to solve, here ?