[mmislesseq] [Up] [mmtoggle] Operations

mmneg
Negate an image.

Synopsis

y = mmneg( f )

Implemented in Python.

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])

              
>>> print mmneg(f)
[  0   0 255 245 235 245 255   0   0]
>>> print mmneg(uint8([0, 1]))
[255 254]
>>> print mmneg(int32([0, 1]))
[ 0 -1]
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

Source Code

def mmneg(f):
    y = mmlimits(f)[0] + mmlimits(f)[1] - f
    y = y.astype(f.typecode())
    return y
    

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.
[mmislesseq] [Up] [mmtoggle] Python