本文整理汇总了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
示例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)
示例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
示例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
示例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
示例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
示例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')
示例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
示例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}