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

mmneg - Negate an image.


Synopsis
y = mmneg( f )
Input
f: Gray-scale (uint8 or uint16) or binary image (logical uint8).
Output
y: Gray-scale (uint8 or uint16) or binary image (logical uint8).
Description
mmneg returns an image y that is the negation (i.e., inverse or involution) of the image f. In the binary case, y is the complement of f.
Examples
f=uint8([255 255 0 10 20 10 0 255 255]);
y = mmneg(f)

y =
     0     0   255   245   235   245   255     0     0

Binary image:

a = mmreadgray('gear.tif');
b = mmneg(a);
mmshow(a);
mmshow(b);
image
(a)
image
(b)

Gray-scale image:

c = mmreadgray('astablet.tif');
d = mmneg(c);
mmshow(c);
mmshow(d);
image
(c)
image
(d)
Equation

equation

Algorithm
function y = mmneg_equ(f)
  if (mmisbinary(f))
    k = 1;
  elseif (isa(f,'uint8'))
    k = 255;
  else
    k = 65535;
  end
  y = k - f;
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