def rotate_im(im, theta):
    grid = getGrid([28, 28])
    grid = rotate_grid_2D(grid, theta)
    grid += 13.5
    data = linear_interpolation_2D(im, grid)
    data = np.reshape(data, [28, 28])
    return data.astype('float32')
Exemplo n.º 2
0
def random_rotation(data):
    rot = np.random.rand() * 360  # Random rotation
    grid = getGrid([80, 80])
    grid = rotate_grid_2D(grid, rot)
    grid += 39.5
    data = linear_interpolation_2D(data, grid)
    data = np.reshape(data, [80, 80])
    data = data / float(np.max(data))
    return data.astype('float32')
Exemplo n.º 3
0
def random_rotation(data, width = 28, height = 28, channels = 3):
    rot = np.random.rand() * 360  # Random rotation
    grid = getGrid([width, height])
    grid = rotate_grid_2D(grid, rot)
    grid += 13.5
    if len(data.shape) > 1:
        data = linear_interpolation_2D(data, grid)
        data = np.reshape(data, [width, height, channels])
    print('data.shape ', data.shape, 'data[0].shape', data[0].shape,
          'data[:,:,0].shape', data[:,:,0].shape)
    data[:, :, 0] = data[:, :, 0] / float(np.max(data[:, :, 0]))
    data[:, :, 1] = data[:, :, 1] / float(np.max(data[:, :, 1]))
    data[:, :, 2] = data[:, :, 2] / float(np.max(data[:, :, 2]))
    return data.astype('float32')
Exemplo n.º 4
0
def rotate_im(im, theta, width=28, height=28, channels=3):
    grid = getGrid([width, height])
    grid = rotate_grid_2D(grid, theta)
    grid += 13.5
    print('rotate_im: im.shape ', im.shape)
    data = linear_interpolation_2D(im.T, grid)
    print('rotate_im: data.shape ', data.shape)
    data = np.reshape(data, [width, height, channels])
    #print('data.shape ', data.shape, 'data[0].shape', data[0].shape,
    #      'data[:,:,0].shape', data[:, :, 0].shape)
    #data[:, :, 0] = data[:, :, 0] / float(np.max(data[:, :, 0]))
    #data[:, :, 1] = data[:, :, 1] / float(np.max(data[:, :, 1]))
    #data[:, :, 2] = data[:, :, 2] / float(np.max(data[:, :, 2]))
    return data.T.astype('float32')