# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# immultiply

Multiply two images or multiply image by constant

## Syntax

```Z = immultiply(X,Y) ```

## Description

`Z = immultiply(X,Y)` multiplies each element in array `X` by the corresponding element in array `Y` and returns the product in the corresponding element of the output array `Z`.

If `X` and `Y` are real numeric arrays with the same size and class, then `Z` has the same size and class as `X`. If `X` is a numeric array and `Y` is a scalar double, then `Z` has the same size and class as `X`.

If `X` is logical and `Y` is numeric, then `Z` has the same size and class as `Y`. If `X` is numeric and `Y` is logical, then `Z` has the same size and class as `X`.

`immultiply` computes each element of `Z` individually in double-precision floating point. If `X` is an integer array, then elements of `Z` exceeding the range of the integer type are truncated, and fractional values are rounded.

If `X` and `Y` are numeric arrays of the same size and class, you can use the expression `X.*Y` instead of `immultiply`.

## Examples

collapse all

Read a grayscale image into the workspace, then convert the image to `uint8`.

```I = imread('moon.tif'); I16 = uint16(I);```

Multiply the image by itself. Note that `immultiply` converts the class of the image from `uint8` to `uint16` before performing the multiplication to avoid truncating the results.

`J = immultiply(I16,I16);`

Show the original image and the processed image.

`imshow(I)`

```figure imshow(J)```

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.

`imshow(I)`

```figure imshow(J)```