Example #1
0
def process_image(x):
    org_region = di.get_largest_region(x)
    rr1, cc1   = di.get_bbox_center(org_region.bbox)
    rotated_x  = di.rotate_largest_region(x)
    _x         = cc1 - x.shape[1]/2
    _y         = rr1 - x.shape[0]/2
    cc2, rr2   = di.point_rotate(_x, _y, -org_region.orientation)
    rr2       += rotated_x.shape[0]/2
    cc2       += rotated_x.shape[1]/2
    cropped    = di.crop_around_centroid(rotated_x, rr2, cc2)
    return cropped
Example #2
0
 def update_cropped_image_data(self):
     x = self.image_data.arrays.get('im')[:, :, 0]
     org_region = get_largest_region(x)
     rr1, cc1 = get_bbox_center(org_region.bbox)
     rotated_x = rotate_largest_region(x)
     _x = cc1 - x.shape[1] / 2
     _y = rr1 - x.shape[0] / 2
     cc2, rr2 = point_rotate(_x, _y, -org_region.orientation)
     rr2 += rotated_x.shape[0] / 2
     cc2 += rotated_x.shape[1] / 2
     cropped = crop_around_centroid(rotated_x, rr2, cc2)
     self.cropped_image_data.set_data('im', cropped)
Example #3
0
 def _cropped_image_data_default(self):
     x = self.image_data.arrays.get('im')[:, :, 0]
     org_region = get_largest_region(x)
     rr1, cc1 = get_bbox_center(org_region.bbox)
     rotated_x = rotate_largest_region(x)
     _x = cc1 - x.shape[1] / 2
     _y = rr1 - x.shape[0] / 2
     cc2, rr2 = point_rotate(_x, _y, -org_region.orientation)
     rr2 += rotated_x.shape[0] / 2
     cc2 += rotated_x.shape[1] / 2
     cropped = crop_around_centroid(rotated_x, rr2, cc2)
     apd = ArrayPlotData(im=cropped)
     return apd