imadd
Add two images or add constant to image
Syntax
Description
Examples
Add Two uint8 Arrays
This example shows how to add two uint8
arrays with truncation for values that exceed 255.
X = uint8([ 255 0 75; 44 225 100]); Y = uint8([ 50 50 50; 50 50 50 ]); Z = imadd(X,Y)
Z = 2x3 uint8 matrix
255 50 125
94 255 150
Add Two Images and Specify Output Class
Read two grayscale uint8
images into the workspace.
I = imread('rice.png'); J = imread('cameraman.tif');
Add the images. Specify the output as type uint16
to avoid truncating the result.
K = imadd(I,J,'uint16');
Display the result.
imshow(K,[])
Add a Constant to an Image
Read an image into the workspace.
I = imread('rice.png');
Add a constant to the image.
J = imadd(I,50);
Display the original image and the result.
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 added to X
, specified as a numeric
or logical array of the same size and class as X
, or a
numeric scalar of type double
.
Output Arguments
Z
— Sum
numeric array
Sum, returned as a numeric array of the same size as
X
. Z
is the same class as
X
unless X
is logical, in
which case Z
is data type double
. If
X
is an integer array, elements of the output that
exceed the range of the integer type are truncated, and fractional values
are rounded.
Version History
Introduced before R2006a
See Also
imabsdiff
| imcomplement
| imdivide
| imlincomb
| immultiply
| imsubtract
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
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)