Function ianeg

namespace:ia636
page:ianeg

Synopse

Negate an image.

  • g = ianeg(f)
    • g: Image.
    • f: Image. Set initial.
01. from numpy import *
02. 
03. def ianeg(f):
04. 
05.     f = asarray(f)
06.     if f.dtype in ['b','uint8','???']: # (numarray implementara uint16 e boolean)
07.         k = 2**(8*f.itemsize) - 1
08.         g = k - f
09.     else: # Trata os tipos com sinal
10.         g = -f.astype(float)
11.     return g

Description

Returns an image that is the negation (i.e., inverse or involution) of the input image.

Examples

Example 1

01. from ia636 import ianeg
02. 
03. c1 = array([0, 53, 150, 255], uint8)
04. print c1
05. n1 = ianeg(c1)
06. print n1
07. c2 = array([-129, -128, 0, 127, 128], int8)
08. print c2
09. n2 = ianeg(c2)
10. print n2
[  0  53 150 255]
[255 202 105   0]
[ 127 -128    0  127 -128]
[128 383 255 128 383]

Equation