movis.imgproc.alpha_composite#
- movis.imgproc.alpha_composite(bg_image: ndarray, fg_image: ndarray, position: tuple[int, int] = (0, 0), opacity: float = 1.0, blending_mode: str | BlendingMode = BlendingMode.NORMAL, matte_mode: MatteMode = MatteMode.NONE) ndarray [source]#
Perform alpha compositing of two images (with alpha channels).
This function asserts that both the background and foreground images have 4 channels (RGBA) and
dtype=numpy.uint8
. If the background image is not writeable, a copy will be made.- Args:
- bg_image:
The background image as a 3D numpy array of shape
(height, width, 4)
. The image should have 4 channels (RGBA), withdtype=numpy.uint8
.- fg_image:
the foreground image as a 3D numpy array of shape
(height, width, 4)
. The image should have 4 channels (RGBA), withdtype=numpy.uint8
.- position:
The x, y coordinates indicating where the top-left corner of the foreground image should be placed on the background image. Default is
(0, 0)
.- opacity:
The opacity level of the foreground image, between 0.0 and 1.0. Default is 1.0.
- blending_mode:
The blending mode used for compositing the two images. Available modes are defined in the
BlendingMode
enum. Default isBlendingMode.NORMAL
. Note that the blending mode can also be specified as a string.- matte_mode:
The mode used for handling the matte channel. Available modes are defined in the
MatteMode
enum (NONE
,ALPHA
, andLUMINANCE
). Default isMatteMode.NONE
. Note that the matte mode can also be specified as a string.
- Returns:
The composited image as a 3D numpy array of shape
(height, width, 4)
withdtype=numpy.uint8
.