[mmis] [Up] [mmtoggle] Operations

mmneg
Negate an image.

Synopsis

function y = mmneg ( f )

Input

f Image Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image

Output

y Image Unsigned gray-scale (uint8 or uint16), signed (int32) or binary image

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
mmneg(uint8([0, 1]))
ans =
  255  254
Binary image:
a = mmreadgray('gear.tif');
b = mmneg(a);
mmshow(a); 
mmshow(b);
a b
Gray-scale image:
c = mmreadgray('astablet.tif');
d = mmneg(c);
mmshow(c); 
mmshow(d);
c d

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.
mmlimits Get the possible minimum and maximum of an image.
[mmis] [Up] [mmtoggle]