Augmentation
This file contains 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
#standard deviation for noise to be added in the image | |
sigma=0.155 | |
#add random noise to the image | |
noisyRandom = random_noise(image,var=sigma**2) | |
plt.imshow(noisyRandom) | |
plt.title('Random Noise') |
This file contains 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
#blur the image | |
blurred = gaussian(image,sigma=1,multichannel=True) | |
plt.imshow(blurred) | |
plt.title('Blurred Image') |
This file contains 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
#flip image left-to-right | |
flipLR = np.fliplr(image) | |
plt.imshow(flipLR) | |
plt.title('Left to Right Flipped') |
This file contains 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
#flip image up-to-down | |
flipUD = np.flipud(image) | |
plt.imshow(flipUD) | |
plt.title('Up Down Flipped') |
This file contains 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
print('Rotated Image') | |
#rotating the image by 45 degrees | |
rotated = rotate(image, angle=45, mode = 'wrap') | |
#plot the rotated image | |
io.imshow(rotated) |
This file contains 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
#apply shift operation | |
transform = AffineTransform(translation=(25,25)) | |
wrapShift = warp(image,transform,mode='wrap') | |
plt.imshow(wrapShift) | |
plt.title('Wrap Shift') |
This file contains 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
# importing all the required libraries | |
import warnings | |
warnings.filterwarnings('ignore') | |
import numpy as np | |
import skimage.io as io | |
from skimage.transform import rotate, AffineTransform, warp | |
from skimage.util import random_noise | |
from skimage.filters import gaussian | |
import matplotlib.pyplot as plt | |
% matplotlib inline |
This file contains 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
# reading the image using its path | |
image = io.imread('emergency_vs_non-emergency_dataset/images/0.jpg') | |
# shape of the image | |
print(image.shape) | |
# displaying the image | |
io.imshow(image) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment