Image Augmentor(图片旋转+加噪声)

Image Augmentor

https://github.com/codebox/image_augmentor

This is a simple data augmentation tool for image files, intended for use with machine learning data sets. The tool scans a directory containing image files, and generates new images by performing a specified set of augmentation operations on each file that it finds. This process multiplies the number of training examples that can be used when developing a neural network, and should significantly improve the resulting network's performance, particularly when the number of training examples is relatively small.

Run the utility from the command-line as follows:

python main.py <image dir> <transform1> <transform2> ...

The <image dir> argument should be the path to a directory containing the image files to be augmented. The utility will search the directory recursively for files with any of the following extensions: jpg, jpeg, bmp, png.

The transform arguments determine what types of augmentation operations will be performed, using the codes listed in the table below:

CodeDescriptionExample Values
fliphHorizontal Flipfliph
flipvVertical Flipflipv
noiseAdds random noise to the imagenoise_0.01,noise_0.5
rotRotates the image by the specified amountrot_90,rot_-45
transShifts the pixels of the image by the specified amounts in the x and y directionstrans_20_10,trans_-10_0
zoomZooms into the specified region of the image, performing stretching/shrinking as necessaryzoom_0_0_20_20,zoom_-10_-20_10_10
blurBlurs the image by the specified amountblur_1.5

Each transform argument results in one additional output image being generated for each input image. An argument may consist of one or more augmentation operations. Multiple operations within a single argument must be separated by commas, and the order in which the operations are performed will match the order in which they are specified within the argument.

Examples

Produce 2 output images for each input image, one of which is flipped horizontally, and one of which is flipped vertically:

python main.py ./my_images fliph flipv

Produce 1 output image for each input image, by first rotating the image by 90° and then flipping it horizontally:

python main.py ./my_images rot_90,fliph

Operations

Horizontal Flip

Mirrors the image around a vertical line running through its center

python main.py ./my_images fliph

Original Image       Flipped Image

Vertical Flip

Mirrors the image around a horizontal line running through its center

python main.py ./my_images flipv

Original Image       Flipped Image

Noise

Adds random noise to the image. The amount of noise to be added is specified by a floating-point numeric value that is included in the transform argument, the numeric value must be greater than 0.

python main.py ./my_images noise_0.01 noise_0.02 noise_0.05

Original Image       Noisy Image       Noisy Image       Noisy Image

Rotate

Rotates the image. The angle of rotation is specified by a integer value that is included in the transform argument

python main.py ./my_images rot_90 rot_180 rot_-90

Original Image       Rotated Image       Rotated Image       Rotated Image

Translate

Performs a translation on the image. The size of the translation in the x and y directions are specified by integer values that are included in the transform argument

python main.py ./my_images trans_20_20 trans_0_100

Original Image       Translated Image       Translated Image

Zoom/Stretch

Zooms in (or out) to a particular area of the image. The top-left and bottom-right coordinates of the target region are specified by integer values included in the transform argument. By specifying a target region with an aspect ratio that differs from that of the source image, stretching transformations can be performed.

python main.py ./my_images zoom_150_0_300_150 zoom_0_50_300_150 zoom_200_0_300_300

Original Image       Zoomed Image       Stretched Image       Stretched Image

Blur

Blurs the image. The amount of blurring is specified by a floating-point value included in the transform argument.

python main.py ./my_images blur_1.0 blur_2.0 blur_4.0

Original Image       Blurred Image       Blurred Image       Blurred Image

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值