Computer Vision News - May 2020
3 Summary i g ug 25 import imageio import numpy as np import imgaug as ia import imgaug.augmenters as iaa from imgaug.augmentables.segmaps import SegmentationMapsOnImage import matplotlib.pyplot as plt from PIL import Image import PIL ia.seed( 1 ) # Initialize augmentation types seq = iaa.Sequential([ iaa.Sometimes( 0.7 , iaa.Fliplr( 0.5 )), iaa.Sometimes( 0.6 , iaa.Affine( scale = {"x": ( 0.8 , 1.2 ), "y": ( 0.8 , 1.2 )}, rotate = (- 5 , 5 ) ) ) ]) filenames = ["image1","image2","image3","image4","image5","image6"] plt.figure(figsize=[ 14 , 10 ]) plt.subplots_adjust(wspace = 0.5 ) count = 0 for i in filenames: im = np.asarray(Image.open(i + ".jpg")) original_im = im gt = np.asarray(Image.open(i+"_mask.png")) segmap = np.argmax(gt, axis= 2 ) segmap = segmap.astype(np.int32) segmap = SegmentationMapsOnImage(segmap,shape=im.shape) im,gt = seq(image=im,segmentation_maps=segmap) gt = gt.get_arr().astype(float) plt.subplot( 3 ,len(filenames),count+ 1 ) implot = plt.imshow(original_im) plt.subplot( 3 ,len(filenames),count+ 1 +len(filenames)) imgplot = plt.imshow(im) plt.subplot( 3 ,len(filenames),count+ 1 +len(filenames)* 2 ) imgplot = plt.imshow(gt) count+= 1 plt.show()
Made with FlippingBook
RkJQdWJsaXNoZXIy NTc3NzU=