Last active
March 3, 2018 17:22
-
-
Save tomahim/51b4c58f3ad3b76b323289371ba6e94f to your computer and use it in GitHub Desktop.
Simple image transformation with scikit-image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from scipy import ndarray | |
import skimage as sk | |
from skimage import transform | |
from skimage import util | |
def random_rotation(image_array: ndarray): | |
# pick a random degree of rotation between 25% on the left and 25% on the right | |
random_degree = random.uniform(-25, 25) | |
return sk.transform.rotate(image_array, random_degree) | |
def random_noise(image_array: ndarray): | |
# add random noise to the image | |
return sk.util.random_noise(image_array) | |
def horizontal_flip(image_array: ndarray): | |
# horizontal flip doesn't need skimage, it's easy as flipping the image array of pixels ! | |
return image_array[:, ::-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment