我正在学习图像去噪和Pytorch.I。我想要从单个图像生成的突发图像。例如,我有一张图片,然后从其中随机裁剪出特定大小的补丁。然后,我想在上面添加一个1或2个像素的移位,以获得一个具有微小差异的新图像。我能做些什么?使用PIL中的一些技术还是其他技术更好?
发布于 2019-04-27 18:12:29
您应该使用transforms
来为您的问题做一些图像增强。
当我读到你的评论时,你可以限制translate = (a, b)
在两个维度上做一些微小的随机变化。
import torchvision.transforms as transforms
transform = transforms.RandomAffine(degrees, translate=None, scale=None, shear=None, resample=False, fillcolor=0)
img = PIL.Image.open('path/img')
new_img = transform(img)
如果您还想执行更多像Crop
这样的转换,可以使用transforms.Compose
将所有transform
分组到一个大的transform
中。这是您的reference
https://stackoverflow.com/questions/55881517
复制