def region_from_segment ( image , segment ) : x , y , w , h = segment return image [ y : y + h , x : x + w ]
overlay segmentation onto image linux python
given a segment ( rectangle ) and an image returns it s corresponding subimage
def region_from_segment(image, segment):
    """given a segment (rectangle) and an image, returns it's corresponding subimage"""
    x, y, w, h = segment
    return image[y:y + h, x:x + w]