Multiply two images or multiply image by constant
Multiply an Image by Itself
Read a grayscale image into the workspace, then convert the image to
I = imread('moon.tif'); I16 = uint16(I);
Multiply the image by itself. Note that
immultiply converts the class of the image from
uint16 before performing the multiplication to avoid truncating the results.
J = immultiply(I16,I16);
Show the original image and the processed image.
Scale an Image by a Constant Factor
Read an image into the workspace.
I = imread('moon.tif');
Scale each value of the image by a constant factor of 0.5.
J = immultiply(I,0.5);
Display the original image and the processed image.
X — First array
numeric array | logical array
First array, specified as a numeric array or logical array of any dimension.
Y — Second array
numeric scalar | numeric array | logical array
Second array to be multiplied with
X, specified as a
numeric scalar, numeric array, or logical array.
Xis numeric, then the size and class of
Ycan have one of the following values:
Yis the same size and class as
Yis the same size as
Xand is logical.
Yis a scalar of type
Xis logical, then
Ymust have the same size as
Ycan be any class.
Z — Product
Product, returned as a numeric array.
immultiply computes each element of
Z individually in double-precision floating point.
Y is an integer array,
then elements of
Z exceeding the range of the integer
type are truncated, and fractional values are rounded.
Introduced before R2006a