当前位置: 首页>>代码示例>>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;未经允许,请勿转载。