[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] SDC Morphology Toolbox V1.1 15Jan02

mmaddm - Addition of two images, with saturation.


Synopsis
y = mmaddm( f1, f2 )
Input
f1: Gray-scale (uint8 or uint16) or binary image (logical uint8).
f2: Gray-scale (uint8 or uint16) or binary image (logical uint8). Or constant.
 
Obs: f1, f2 must have the same data type.
Output
y: Gray-scale (uint8 or uint16) image.
Description
mmaddm creates the image y by pixelwise addition of images f1 and f2. When the addition of the values of two pixels saturates the image data type considered, the greatest value of this type is taken as the result of the addition.
Examples
f=uint8([255   255    0   10    0   255   250]);
g=uint8([ 0    40   80   140  250    10    30]);
y1=mmaddm(f,g)

y1 =
   255   255    80   150   250   255   255
y2=mmaddm(g,uint8(100))

y2 =
   100   140   180   240   255   110   130
a = imread('keyb.tif');
b = mmaddm(a,128);
Warning: Converting image from scalar to uint8.
mmshow(a);
mmshow(b); 
image
(a)
image
(b)
Equation

equation

Algorithm
function y = mmaddm_equ(f1,f2)
if (mmisbinary(f1) & mmisbinary(f2))
   k = 1;
elseif (isa(f1,'uint8') | isa(f2,'uint8'))
   k = 255;
else
   k = 65535;
end
y = min(min(f1+f2,k));
See Also
mmfreedom - Control automatic data type conversion.
mmsubm - Subtraction of two images, with saturation.

[Top] [Up] [Prev] [Next] [Up] [Basic Concepts] [Demonstrations] [Functions] Valid XHTML 1.0!
Copyright (c) 1998-2002 by SDC Information Systems