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

mmsubm - Subtraction of two images, with saturation.


Synopsis
y = mmsubm( 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) or binary image (logical uint8).
Description
mmsubm creates the image y by pixelwise subtraction of the image f2 from the image f1. When the subtraction of the values of two pixels is negative, 0 is taken as the result of the subtraction. When f1 and f2 are binary images, y represents the set subtraction of f2 from f1.
Examples
f=uint8([...
255   255    0   10   20   10    0   255   255]);
g=uint8([...
10     20   30   40   50   40   30    20    10]);
y1=mmsubm(f,g)

y1 =
   245   235     0     0     0     0     0   235   245
y2=mmsubm(f,uint8(100))

y2 =
   155   155     0     0     0     0     0   155   155
y3=mmsubm(uint8(100),f)

y3 =
     0     0   100    90    80    90   100     0     0

Gray scale image:

a = mmreadgray('boxdrill-C.tif');
b = mmreadgray('boxdrill-B.tif');
c = mmsubm(a,b);
mmshow(a);
mmshow(b);
mmshow(c); 
image
(a)
image
(b)
image
(c)
Equation

equation

Algorithm
function g = mmsubm_equ(f1,f2)
g = max(max(f1-f2,0));
See Also
mmaddm - Addition of two images, with saturation.
mmfreedom - Control automatic data type conversion.

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