當前位置: 首頁>>代碼示例>>Python>>正文


Python misc.imrotate方法代碼示例

本文整理匯總了Python中scipy.misc.imrotate方法的典型用法代碼示例。如果您正苦於以下問題:Python misc.imrotate方法的具體用法?Python misc.imrotate怎麽用?Python misc.imrotate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.misc的用法示例。


在下文中一共展示了misc.imrotate方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: crawl_directory

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def crawl_directory(directory, augment_with_rotations=False, first_label=0):
  """Crawls data directory and returns stuff."""
  label_idx = first_label
  images = []
  labels = []
  info = []

  # traverse root directory
  for root, _, files in os.walk(directory):
    logging.info('Reading files from %s', root)

    for file_name in files:
      full_file_name = os.path.join(root, file_name)
      img = imread(full_file_name, flatten=True)
      for idx, angle in enumerate([0, 90, 180, 270]):
        if not augment_with_rotations and idx > 0:
          break

        images.append(imrotate(img, angle))
        labels.append(label_idx + idx)
        info.append(full_file_name)

    if len(files) == 20:
      label_idx += 4 if augment_with_rotations else 1
  return images, labels, info 
開發者ID:RUSH-LAB,項目名稱:LSH_Memory,代碼行數:27,代碼來源:data_utils.py

示例2: save_HR_LR

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def save_HR_LR(img, size, path, idx):
	HR_img = misc.imresize(img, size, interp='bicubic')
	HR_img = modcrop(HR_img, 4)
	rot180_img = misc.imrotate(HR_img, 180)
	x4_img = misc.imresize(HR_img, 1 / 4, interp='bicubic')
	x4_rot180_img = misc.imresize(rot180_img, 1 / 4, interp='bicubic')

	img_path = path.split('/')[-1].split('.')[0] + '_rot0_' + 'ds' + str(idx) + '.png'
	rot180img_path = path.split('/')[-1].split('.')[0] + '_rot180_' + 'ds' + str(idx) + '.png'
	x4_img_path = path.split('/')[-1].split('.')[0] + '_rot0_' + 'ds' + str(idx) + '.png'
	x4_rot180img_path = path.split('/')[-1].split('.')[0] + '_rot180_' + 'ds' + str(idx) + '.png'

	misc.imsave(save_HR_path + '/' + img_path, HR_img)
	misc.imsave(save_HR_path + '/' + rot180img_path, rot180_img)
	misc.imsave(save_LR_path + '/' + x4_img_path, x4_img)
	misc.imsave(save_LR_path + '/' + x4_rot180img_path, x4_rot180_img) 
開發者ID:Paper99,項目名稱:SRFBN_CVPR19,代碼行數:18,代碼來源:Prepare_TrainData_HR_LR.py

示例3: crawl_directory

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def crawl_directory(directory, augment_with_rotations=False,
                    first_label=0):
  """Crawls data directory and returns stuff."""
  label_idx = first_label
  images = []
  labels = []
  info = []

  # traverse root directory
  for root, _, files in os.walk(directory):
    logging.info('Reading files from %s', root)
    fileflag = 0
    for file_name in files:
      full_file_name = os.path.join(root, file_name)
      img = imread(full_file_name, flatten=True)
      for i, angle in enumerate([0, 90, 180, 270]):
        if not augment_with_rotations and i > 0:
          break

        images.append(imrotate(img, angle))
        labels.append(label_idx + i)
        info.append(full_file_name)

      fileflag = 1

    if fileflag:
      label_idx += 4 if augment_with_rotations else 1

  return images, labels, info 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:31,代碼來源:data_utils.py

示例4: random_rotate_image

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')
  
# 1: Random rotate 2: Random crop  4: Random flip  8:  Fixed image standardization  16: Flip 
開發者ID:GaoangW,項目名稱:TNT,代碼行數:7,代碼來源:facenet.py

示例5: random_rotate_image

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def random_rotate_image(image):

    logger.info(msg="random_rotate_image called")
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic')


# 1: Random rotate
# 2: Random crop
# 4: Random flip
# 8: Fixed image standardization
# 16: Flip 
開發者ID:pymit,項目名稱:Rekognition,代碼行數:14,代碼來源:facenet.py

示例6: __call__

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def __call__(self, images, intrinsics):
        if np.random.random() > 0.5:
            return images, intrinsics
        else:
            assert intrinsics is not None
            rot = np.random.uniform(0,10)
            rotated_images = [imrotate(im, rot) for im in images]

            return rotated_images, intrinsics 
開發者ID:anuragranj,項目名稱:cc,代碼行數:11,代碼來源:custom_transforms.py

示例7: random_rotate_image

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def random_rotate_image(image):
    angle = np.random.uniform(low=-10.0, high=10.0)
    return misc.imrotate(image, angle, 'bicubic') 
開發者ID:bearsprogrammer,項目名稱:real-time-deep-face-recognition,代碼行數:5,代碼來源:facenet.py

示例8: rotate_images

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def rotate_images(images, angle, image_size):
    images_list = [None] * images.shape[0]
    for i in range(images.shape[0]):
        images_list[i] = misc.imrotate(images[i,:,:,:], angle)
    images_rot = np.stack(images_list,axis=0)
    sz1 = images_rot.shape[1]/2
    sz2 = image_size/2
    images_crop = images_rot[:,(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]
    return images_crop 
開發者ID:1024210879,項目名稱:facenet-demo,代碼行數:11,代碼來源:test_invariance_on_lfw.py

示例9: __call__

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import imrotate [as 別名]
def __call__(self, sample, interval=(-10, 10)):
        image, mask, target = sample['image'], sample['mask'], sample['target']

        angle = np.random.uniform(interval[0], interval[1])

        image = imrotate(image, angle)
        mask = imrotate(mask, angle, interp='nearest', mode='F')
        target = imrotate(target, angle, interp='nearest', mode='F')

        return {'image': image, 'mask': mask, 'target': target} 
開發者ID:krematas,項目名稱:soccerontable,代碼行數:12,代碼來源:transforms.py


注:本文中的scipy.misc.imrotate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。