Image Processing Toolbox | ![]() ![]() |
Multiplying Images
To multiply two images, use the immultiply
function. immultiply
does an element-by-element multiplication (.*
) of each corresponding pixel in a pair of input images and returns the product of these multiplications in the corresponding pixel in an output image.
Image multiplication by a constant, referred to as scaling, is a common image processing operation. When used with a scaling factor greater than one, scaling brightens an image; a factor less than one darkens an image. Scaling generally produces a much more natural brightening/darkening effect than simply adding an offset to the pixels, since it preserves the relative contrast of the image better. For example, this code scales an image by a constant factor.
Handling Overflow
Multiplication of uint8
images very often results in overflow. The immultiply
function truncates values that overflow the data type to the maximum value. To avoid truncation, convert uint8
images to a larger data type, such as uint16
, before performing multiplication.
![]() | Subtracting Images | Dividing Images | ![]() |