Author: true_pk Language: python
Description: Not specified Timestamp: 2017-09-17 15:01:17 +0000
View raw paste Reply
  1. image_names = os.listdir('data/train_masks/')
  2. np.random.shuffle(image_names)
  3.  
  4. for image_name in image_names[:10]:
  5.     mask = Image.open('data/train_masks/{}'.format(image_name))
  6.     mask = np.asarray(mask)
  7.     mask_rotated = rotate(mask, angle=15)
  8.     mask_reverse_rotated = rotate(mask_rotated, -15)
  9.  
  10.     fig = plt.figure(figsize=(18, 5))
  11.     a = fig.add_subplot(1, 3, 1)
  12.     plt.imshow(mask)
  13.     a = fig.add_subplot(1, 3, 2)
  14.     plt.imshow(mask_rotated)
  15.     a = fig.add_subplot(1, 3, 3)
  16.     plt.imshow(mask_reverse_rotated)
  17.     print ('dice: ', dice_coeff(mask, mask_reverse_rotated))
View raw paste Reply