imgcrop
简单的图像增强库关注随机几何裁剪。
与基于管道的扩展库不同,该库可以同时高效地执行裁剪和几何变换。
由于不提供添加高斯噪声、模糊和对比度调整等图像处理功能,
请使用其他伟大的库,如imgaug[1]、Augmentor[2]和albumentations[3]
以进一步转换此库剪切的图像。
功能简单的API,易于使用
高效;裁剪和所有几何变换同时执行(通过单个透视变换)
确保裁剪图像中的所有像素都取自原始图像内部(如果不使用边距)
安装pip install imgcrop
原料药
imgcrop.get_croperget_cropper(patch_size=128,scale=(1.0,1.0),rotate=(0,0),distort=0.0,flip=0.0,margin=0)
参数补丁大小:int,默认128输出面片大小(像素)
scale:float元组,默认值(1.0,1.0)采样比例范围
rotate:int元组,默认值(0,0)采样旋转范围(度)
扭曲:float,默认值为0.0透视变换中的失真强度(与输出图像比例之比)
flip:float,默认值0.0水平翻转概率
margin:int,默认值0裁剪原始图像时的边距
返回随机裁剪:函数
随机作物random_crop(img,points=None)->cropped_img[,output_points],src_points,m
参数img:numpy数组(单个图像)或numpy数组列表(多个图像)输入要用相同几何变换裁剪的图像
points:numpy数组,具有形状(point num,2),默认为none要用与输入图像相同的变换矩阵变换的输入点
返回cripped\u img:numpy数组或numpy数组列表)剪切输出图像
输出点:带形状的numpy数组(point num,2)输入点给定时的输出点
src_点:numpy数组定义输入图像中裁剪区域的点
m:numpy数组从输入图像到输出图像的3x3透视变换矩阵
示例python example/example.py
您可以通过参数轻松尝试不同的参数:optional arguments:
-h, --help show this help message and exit
--patch_size PATCH_SIZE
output patch image size (default: 256)
--scale SCALE SCALE scale range in sampling (default: [0.8, 1.2])
--rotate ROTATE ROTATE
rotation range in sampling (default: [-60, 60])
--distort DISTORT distortion strength for perspective transformation
(default: 0.2)
--flip FLIP horizontal flip probability (default: 0.5)
--margin MARGIN margin around original image (default: 0)parameterscropping results (input, cropped, mask, keypoints)scaling
rotation + scaling
distortion + scaling
flip + rotation
margin + scaling
all
算法
原始图像中的面片区域由四个点组成。
这些点根据变换参数进行随机变换。
然后利用这些点计算从输入图像到输出图像的变换矩阵。
最后,应用透视变换进行裁剪。
参考文献
欢迎加入QQ群-->: 979659372
推荐PyPI第三方库