def keras(self, img):
     return keras.apply_affine_transform(img, theta=45, channel_axis=2, fill_mode='reflect')
 def keras(self, img):
     return keras.apply_affine_transform(img, theta=45, tx=50, ty=50, zx=0.5, zy=0.5, fill_mode='reflect')
def random_rotate(img, mask, rotate_limit=(-20, 20), u=0.5):
    if np.random.random() < u:
        theta = np.random.uniform(rotate_limit[0], rotate_limit[1])
        img = image.apply_affine_transform(img, theta=theta)
        mask = image.apply_affine_transform(mask, theta=theta)
    return img, mask
def shift(x, wshift, hshift, row_axis=0, col_axis=1, channel_axis=2, fill_mode='nearest', cval=0.):
    h, w = x.shape[row_axis], x.shape[col_axis]
    tx = hshift * h
    ty = wshift * w
    x = image.apply_affine_transform(x, ty=ty, tx=tx)
    return x
Exemple #5
0
 def keras(self, img):
     img = keras.apply_affine_transform(img,
                                        theta=45,
                                        channel_axis=2,
                                        fill_mode="reflect")
     return np.ascontiguousarray(img)
 def keras(self, img):
     return keras.apply_affine_transform(img,
                                         theta=45,
                                         channel_axis=2,
                                         fill_mode='reflect')
Exemple #7
0
def random_shear(img, intensity_range=(-0.5, 0.5), u=0.5):
    if np.random.random() < u:
        sh = np.random.uniform(-intensity_range[0], intensity_range[1])
        img = image.apply_affine_transform(img, shear=sh)
    return img
Exemple #8
0
 def keras(self, img):
     return keras.apply_affine_transform(img, theta=45, tx=50, ty=50, zx=0.5, zy=0.5, fill_mode='reflect')
Exemple #9
0
def random_zoom(img, mask, zoom_range=(0.8, 1), u=0.5):
    if np.random.random() < u:
        zx, zy = np.random.uniform(zoom_range[0], zoom_range[1], 2)
        img = image.apply_affine_transform(img, zx=zx, zy=zy)
        mask = image.apply_affine_transform(mask, zx=zx, zy=zy)
    return img, mask
Exemple #10
0
 def keras(self, img):
     img = keras.apply_affine_transform(img, theta=45, tx=50, ty=50, zx=0.5, zy=0.5, fill_mode="reflect")
     return np.ascontiguousarray(img)
 ]
 if len(arr.shape) != 3 or arr.shape[2] != 3:
     continue
 transform_parameters = img_gen.get_random_transform(
     arr.shape, seed=attr_count_crop[key])
 res = img_gen.random_transform(arr, seed=attr_count_crop[key])
 x = np.zeros((h, w, 3))
 x[int(bbox[1] * h):int(bbox[3] * h) - 1,
   int(bbox[0] * w):int(bbox[2] * w) - 1, 0] = 100
 x = apply_affine_transform(
     x,
     transform_parameters.get('theta', 0),
     transform_parameters.get('tx', 0),
     transform_parameters.get('ty', 0),
     transform_parameters.get('shear', 0),
     transform_parameters.get('zx', 1),
     transform_parameters.get('zy', 1),
     row_axis=0,
     col_axis=1,
     channel_axis=2,
     fill_mode='nearest',
     cval=0.)
 if transform_parameters.get('flip_horizontal', False):
     x = flip_axis(x, 1)
 if transform_parameters.get('flip_vertical', False):
     x = flip_axis(x, 0)
 x = x[:, :, 0]
 arr_h = np.max(x, axis=1)
 arr_w = np.max(x, axis=0)
 i = 0
 while (i < h and arr_h[i] < 1e-14):