[iarectangle] [Up] [iacrop] Image Information and Manipulation

iaroi
Cut a rectangle out of an image.

Synopsis

g = iaroi( f, p1, p2 )

Implemented in Python.

Input

f Image. Gray-scale (uint8 or uint16) or binary image (logical).

input image.

p1 Image. Gray-scale (uint8 or uint16) or binary image (logical).

indices of the coordinates at top-left.

p2 Image. Gray-scale (uint8 or uint16) or binary image (logical).

indices of the coordinates at bottom-right.

Output

g Image. Gray-scale (uint8 or uint16) or binary image (logical).

Examples

>>> f = iaread('lenina.pgm')

              
>>> iashow(f)
(256, 256) Min= 36 Max= 255 Mean=88.958 Std=46.38
>>> froi = iaroi(f, [90,70], [200,180])

              
>>> iashow(froi)
(111, 111) Min= 45 Max= 209 Mean=112.001 Std=29.94
f froi

Source Code

def iaroi(f, p1, p2):
    from Numeric import asarray, NewAxis
    f = asarray(f)
    if len(f.shape) == 1: f = f[NewAxis,:]
    g = f[p1[0]:p2[0]+1, p1[1]:p2[1]+1]
    return g
    
[iarectangle] [Up] [iacrop] http://www.python.org