Function iaroi

namespace:ia636
page:iaroi

Synopse

Cut a rectangle out of an image.

  • g = iaroi(f, p1, p2)
    • g: Image.
    • f: Image. input image.
    • p1: Image. indices of the coordinates at top-left.
    • p2: Image. indices of the coordinates at bottom-right.
1. from numpy import *
2. 
3. def iaroi(f, p1, p2):
4. 
5.     f = asarray(f)
6.     if len(f.shape) == 1: f = f[newaxis,:]
7. 
8.     g = f[p1[0]:p2[0]+1, p1[1]:p2[1]+1]
9.     return g

Examples

Example 1

1. from ia636 import iaroi
2. 
3. f = iaread('lenina.pgm')
4. iashow(f)
5. froi = iaroi(f, [90,70], [200,180])
6. iashow(froi)