[mmconcat] [Up] [mmmaxleveltype] Image Information and Manipulation

mmlimits
Get the possible minimum and maximum of an image.

Synopsis

y = mmlimits( f )

Implemented in Python.

Input

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

Output

y Image

Vector, the first element is the infimum, the second, the supremum.

Description

The possible minimum and the possible maximum of an image depend on its data type. These values are important to compute many morphological operators (for instance, negate of an image). The output is a vector, where the first element is the possible minimum and the second, the possible maximum.

Examples

>>> print mmlimits(mmbinary([0, 1, 0]))
[0 1]
>>> print mmlimits(uint8([0, 1, 2]))
[  0 255]

Source Code

def mmlimits(f):
    from Numeric import array
    code = f.typecode()
    if   code == '1': y=array([0,1])
    elif code == 'b': y=array([0,255])
    elif code == 'w': y=array([0,65535])
    elif code == 'i': y=array([-2147483647,2147483647])
    else:
        assert 0,'Does not accept this typecode:'+code
    return y
    

See also

mmneg Negate an image.
mmdatatype Return the image datatype string
[mmconcat] [Up] [mmmaxleveltype] Python