Image.blend#
- Image.blend(image2: Image, alpha: float, beta: float | None = None, gamma: float = 0, dtype: str | None = None) Self[source]#
Image blending
- Parameters:
- Raises:
ValueError – images are not same size
ValueError – images are of different type
- Returns:
blended image
- Return type:
The resulting image isn a linear blend of the two input images
selfandimage2according to:\[\mathbf{Y} = \alpha \mathbf{X}_1 + \beta \mathbf{X}_2 + \gamma\]Examples
>>> from machinevisiontoolbox import Image >>> img1 = Image.Constant(4, size=3) >>> img2 = Image([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> img1.blend(img2, 0.5, 2).A array([[ 4, 6, 8], [10, 12, 14], [16, 18, 20]], dtype=uint8)
Note
For
uint8images the result may be saturated. To avoid this specifydtype='float'and the result will be a floating point image.For a multiplane image each plane is processed independently.
Important
Uses OpenCV function
cv2.addWeightedwhich accepts multiple-channel, CV_8U, CV_16U, CV_16S, CV_32F or CV_64F images.See also