# immultiply

Multiply two images or multiply image by constant

## Syntax

## Description

## Examples

### Multiply an Image by Itself

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)

### 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.

imshow(I)

figure imshow(J)

## Input Arguments

`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.

If

`X`

is numeric, then the size and class of`Y`

can have one of the following values:`Y`

is the same size and class as`X`

.`Y`

is the same size as`X`

and is logical.`Y`

is a scalar of type`double`

.

If

`X`

is logical, then`Y`

must have the same size as`X`

.`Y`

can be any class.

## Output Arguments

`Z`

— Product

numeric array

Product, returned as a numeric array.

`immultiply`

computes each element of
`Z`

individually in double-precision floating point.
If `X`

or `Y`

is an integer array,
then elements of `Z`

exceeding the range of the integer
type are truncated, and fractional values are rounded.

## Tips

## Version History

**Introduced before R2006a**

## See Also

`imabsdiff`

| `imadd`

| `imcomplement`

| `imdivide`

| `imlincomb`

| `imsubtract`

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)