[iameshgrid] [Up] [ianormalize] | Image Information and Manipulation |
Returns an image that is the negation (i.e., inverse or involution) of the input image.
>>> c1 = Numeric.array([0, 53, 150, 255], Numeric.UnsignedInt8)
>>> print c1
[ 0 53 150 255]
>>> n1 = ianeg(c1)
>>> print n1
[255 202 105 0]
>>> c2 = Numeric.array([-129, -128, 0, 127, 128], Numeric.Int8)
>>> print c2
[ 127 -128 0 127 -128]
>>> n2 = ianeg(c2)
>>> print n2
[-127. 128. 0. -127. 128.]
def ianeg(f): from Numeric import asarray, Float f = asarray(f) if f.typecode() in ['b','???']: # (numarray implementara UnsignedInt16 e boolean) k = 2**(8*f.itemsize()) - 1 g = k - f else: # Trata os tipos com sinal g = -f.astype(Float) return g
[iameshgrid] [Up] [ianormalize] | |