Github: https://github.com/aleju/imgaug
imgaug
このPythonライブラリは、機械学習プロジェクトの画像を増やすのに役立ちます。 これは、入力画像のセットを、少し大きく変更された新しいセットに変換します。
特徴:
- 利用可能なほとんどの標準的な拡張技術。
- テクニックは、イメージとイメージのキーポイント/ランドマークの両方に適用できます。
- 実験開始時に一度増強シーケンスを定義し、それを何度も適用します。
- 各画像を-45〜45度の値で回転するか、または各画像を正規分布N(0、5.0)からサンプリングした値で回転させるなど、各補強の確率的な確率的範囲を定義します。
- さまざまなバッチの画像を正確に同じように拡大するために、確率的な範囲をすべて確定的な値に簡単に変換します。 (例えば、イメージとそれぞれのヒートマップ。イメージが回転している場合は、ヒートマップをまったく同じ量だけ回転させたい)
- 必要に応じて、バックグラウンドプロセスで拡張を実行し、実験のパフォーマンスを向上させます。
ドキュメンテーション:
- http://imgaug.readthedocs.io/en/latest/source/examples_basics.html – ライブラリを使用するための簡単なサンプルコード。
- http://imgaug.readthedocs.io/en/latest/source/augmenters.html – 各拡張手法のサンプルコード。
- http://imgaug.readthedocs.io/en/latest/source/modules.html – API
- このREADMEにはさらに多くの例があります。 さらに以下を参照してください。
下の画像は、ほとんどの拡大手法の例を示しています(a, b)
形式で書かれた値(a, b)
a <= x <= b
)の範囲から値がランダムに選択されたことを意味します。
要件とインストール
必要なパッケージ:
- 6
- 貧弱
- サイキー
- scikit-image(
pip install -U scikit-image
) - OpenCV(すなわち
cv2
)
OpenCVは手動でインストールする必要があります。 他のパッケージは自動的にインストールされます。
インストールするには、 sudo pip install imgaug
ます。 そのバージョンは時代遅れかもしれません。 githubから常に最新のバージョンを入手するにはsudo pip install git+https://github.com/aleju/imgaug
。 あるいは、 git clone https://github.com/aleju/imgaug
からリポジトリをダウンロードし、 python setup.py sdist && sudo pip install dist/imgaug-0.2.5.tar.gz
を使用してインストールできます。
ライブラリをsudo pip uninstall imgaug
、 sudo pip uninstall imgaug
実行してsudo pip uninstall imgaug
。
ライブラリは現在python2.7でのみテストされていますが、python3でも実行するようにコードが記述されています。
例
標準的な機械学習の状況。 画像のバッチを訓練し、作物、水平フリップ( “Fliplr”)、ガウスのぼかしで各バッチを増強する:
from imgaug import augmenters as iaa
seq = iaa.Sequential([
iaa.Crop(px=(0, 16)), # crop images from each side by 0 to 16px (randomly chosen)
iaa.Fliplr(0.5), # horizontally flip 50% of the images
iaa.GaussianBlur(sigma=(0, 3.0)) # blur images with a sigma of 0 to 3.0
])
for batch_idx in range(1000):
# 'images' should be either a 4D numpy array of shape (N, height, width, channels)
# or a list of 3D numpy arrays, each having shape (height, width, channels).
# Grayscale images must have shape (height, width, 1) each.
# All images must have numpy's dtype uint8. Values are expected to be in
# range 0-255.
images = load_batch(batch_idx)
images_aug = seq.augment_images(images)
train_on_images(images_aug)
画像に重い補強を適用する(このREADMEの最上部に画像を作成するために使用):
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
# random example images
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
# Sometimes(0.5, ...) applies the given augmenter in 50% of all cases,
# e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second image.
sometimes = lambda aug: iaa.Sometimes(0.5, aug)
# Define our sequence of augmentation steps that will be applied to every image
# All augmenters with per_channel=0.5 will sample one value _per image_
# in 50% of all cases. In all other cases they will sample new values
# _per channel_.
seq = iaa.Sequential(
[
# apply the following augmenters to most images
iaa.Fliplr(0.5), # horizontally flip 50% of all images
iaa.Flipud(0.2), # vertically flip 20% of all images
# crop images by -5% to 10% of their height/width
sometimes(iaa.CropAndPad(
percent=(-0.05, 0.1),
pad_mode=ia.ALL,
pad_cval=(0, 255)
)),
sometimes(iaa.Affine(
scale={"x": (0.8, 1.2), "y": (0.8, 1.2)}, # scale images to 80-120% of their size, individually per axis
translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)}, # translate by -20 to +20 percent (per axis)
rotate=(-45, 45), # rotate by -45 to +45 degrees
shear=(-16, 16), # shear by -16 to +16 degrees
order=[0, 1], # use nearest neighbour or bilinear interpolation (fast)
cval=(0, 255), # if mode is constant, use a cval between 0 and 255
mode=ia.ALL # use any of scikit-image's warping modes (see 2nd image from the top for examples)
)),
# execute 0 to 5 of the following (less important) augmenters per image
# don't execute all of them, as that would often be way too strong
iaa.SomeOf((0, 5),
[
sometimes(iaa.Superpixels(p_replace=(0, 1.0), n_segments=(20, 200))), # convert images into their superpixel representation
iaa.OneOf([
iaa.GaussianBlur((0, 3.0)), # blur images with a sigma between 0 and 3.0
iaa.AverageBlur(k=(2, 7)), # blur image using local means with kernel sizes between 2 and 7
iaa.MedianBlur(k=(3, 11)), # blur image using local medians with kernel sizes between 2 and 7
]),
iaa.Sharpen(alpha=(0, 1.0), lightness=(0.75, 1.5)), # sharpen images
iaa.Emboss(alpha=(0, 1.0), strength=(0, 2.0)), # emboss images
# search either for all edges or for directed edges,
# blend the result with the original image using a blobby mask
iaa.SimplexNoiseAlpha(iaa.OneOf([
iaa.EdgeDetect(alpha=(0.5, 1.0)),
iaa.DirectedEdgeDetect(alpha=(0.5, 1.0), direction=(0.0, 1.0)),
])),
iaa.AdditiveGaussianNoise(loc=0, scale=(0.0, 0.05*255), per_channel=0.5), # add gaussian noise to images
iaa.OneOf([
iaa.Dropout((0.01, 0.1), per_channel=0.5), # randomly remove up to 10% of the pixels
iaa.CoarseDropout((0.03, 0.15), size_percent=(0.02, 0.05), per_channel=0.2),
]),
iaa.Invert(0.05, per_channel=True), # invert color channels
iaa.Add((-10, 10), per_channel=0.5), # change brightness of images (by -10 to 10 of original value)
iaa.AddToHueAndSaturation((-20, 20)), # change hue and saturation
# either change the brightness of the whole image (sometimes
# per channel) or change the brightness of subareas
iaa.OneOf([
iaa.Multiply((0.5, 1.5), per_channel=0.5),
iaa.FrequencyNoiseAlpha(
exponent=(-4, 0),
first=iaa.Multiply((0.5, 1.5), per_channel=True),
second=iaa.ContrastNormalization((0.5, 2.0))
)
]),
iaa.ContrastNormalization((0.5, 2.0), per_channel=0.5), # improve or worsen the contrast
iaa.Grayscale(alpha=(0.0, 1.0)),
sometimes(iaa.ElasticTransformation(alpha=(0.5, 3.5), sigma=0.25)), # move pixels locally around (with random strengths)
sometimes(iaa.PiecewiseAffine(scale=(0.01, 0.05))), # sometimes move parts of the image around
sometimes(iaa.PerspectiveTransform(scale=(0.01, 0.1)))
],
random_order=True
)
],
random_order=True
)
images_aug = seq.augment_images(images)
増強シーケンスのサンプル結果をすばやく表示:
from imgaug import augmenters as iaa
import numpy as np
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
seq = iaa.Sequential([iaa.Fliplr(0.5), iaa.GaussianBlur((0, 3.0))])
# show an image with 8*8 augmented versions of image 0
seq.show_grid(images[0], cols=8, rows=8)
# Show an image with 8*8 augmented versions of image 0 and 8*8 augmented
# versions of image 1. The identical augmentations will be applied to
# image 0 and 1.
seq.show_grid([images[0], images[1]], cols=8, rows=8)
正確に同じ方法で2つのバッチの画像を増やします (たとえば、両方のバッチで水平方向に1番目、2番目および5番目の画像を反転しますが、3番目および4番目の画像は変更しないでください)。
from imgaug import augmenters as iaa
# Standard scenario: You have N RGB-images and additionally 21 heatmaps per image.
# You want to augment each image and its heatmaps identically.
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
heatmaps = np.random.randint(0, 255, (16, 128, 128, 21), dtype=np.uint8)
seq = iaa.Sequential([iaa.GaussianBlur((0, 3.0)), iaa.Affine(translate_px={"x": (-40, 40)})])
# Convert the stochastic sequence of augmenters to a deterministic one.
# The deterministic sequence will always apply the exactly same effects to the images.
seq_det = seq.to_deterministic() # call this for each batch again, NOT only once at the start
images_aug = seq_det.augment_images(images)
heatmaps_aug = seq_det.augment_images(heatmaps)
これらの画像上に画像と ランドマーク/キーポイントを追加する:
import imgaug as ia
from imgaug import augmenters as iaa
from scipy import misc
import random
import numpy as np
images = np.random.randint(0, 50, (4, 128, 128, 3), dtype=np.uint8)
# Generate random keypoints.
# The augmenters expect a list of imgaug.KeypointsOnImage.
keypoints_on_images = []
for image in images:
height, width = image.shape[0:2]
keypoints = []
for _ in range(4):
x = random.randint(0, width-1)
y = random.randint(0, height-1)
keypoints.append(ia.Keypoint(x=x, y=y))
keypoints_on_images.append(ia.KeypointsOnImage(keypoints, shape=image.shape))
seq = iaa.Sequential([iaa.GaussianBlur((0, 3.0)), iaa.Affine(scale=(0.5, 0.7))])
seq_det = seq.to_deterministic() # call this for each batch again, NOT only once at the start
# augment keypoints and images
images_aug = seq_det.augment_images(images)
keypoints_aug = seq_det.augment_keypoints(keypoints_on_images)
# Example code to show each image and print the new keypoints coordinates
for img_idx, (image_before, image_after, keypoints_before, keypoints_after) in enumerate(zip(images, images_aug, keypoints_on_images, keypoints_aug)):
image_before = keypoints_before.draw_on_image(image_before)
image_after = keypoints_after.draw_on_image(image_after)
misc.imshow(np.concatenate((image_before, image_after), axis=1)) # before and after
for kp_idx, keypoint in enumerate(keypoints_after.keypoints):
keypoint_old = keypoints_on_images[img_idx].keypoints[kp_idx]
x_old, y_old = keypoint_old.x, keypoint_old.y
x_new, y_new = keypoint.x, keypoint.y
print("[Keypoints for image #%d] before aug: x=%d y=%d | after aug: x=%d y=%d" % (img_idx, x_old, y_old, x_new, y_new))
単一の機能強化を画像に適用する:
from imgaug import augmenters as iaa
import numpy as np
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
flipper = iaa.Fliplr(1.0) # always horizontally flip each input image
images[0] = flipper.augment_image(images[0]) # horizontally flip image 0
vflipper = iaa.Flipud(0.9) # vertically flip each input image with 90% probability
images[1] = vflipper.augment_image(images[1]) # probably vertically flip image 1
blurer = iaa.GaussianBlur(3.0)
images[2] = blurer.augment_image(images[2]) # blur image 2 by a sigma of 3.0
images[3] = blurer.augment_image(images[3]) # blur image 3 by a sigma of 3.0 too
translater = iaa.Affine(translate_px={"x": -16}) # move each input image by 16px to the left
images[4] = translater.augment_image(images[4]) # move image 4 to the left
scaler = iaa.Affine(scale={"y": (0.8, 1.2)}) # scale each input image to 80-120% on the y axis
images[5] = scaler.augment_image(images[5]) # scale image 5 by 80-120% on the y axis
特定の画像チャンネルのみにオーグメンターを適用する:
from imgaug import augmenters as iaa
import numpy as np
# fake RGB images
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
# add a random value from the range (-30, 30) to the first two channels of
# input images (e.g. to the R and G channels)
aug = iaa.WithChannels(
channels=[0, 1],
children=iaa.Add((-30, 30))
)
images_aug = aug.augment_images(images)
それぞれのオーグメンタの確率的パラメータに対して、より珍しい分布を使用することができます。
from imgaug import augmenters as iaa
from imgaug import parameters as iap
import numpy as np
images = np.random.randint(0, 255, (16, 128, 128, 3), dtype=np.uint8)
# Blur by a value sigma which is sampled from a uniform distribution
# of range 0.1 <= x < 3.0.
# The convenience shortcut for this is: iaa.GaussianBlur((0.1, 3.0))
blurer = iaa.GaussianBlur(iap.Uniform(0.1, 3.0))
images_aug = blurer.augment_images(images)
# Blur by a value sigma which is sampled from a normal distribution N(1.0, 0.1),
# i.e. sample a value that is usually around 1.0.
# Clip the resulting value so that it never gets below 0.1 or above 3.0.
blurer = iaa.GaussianBlur(iap.Clip(iap.Normal(1.0, 0.1), 0.1, 3.0))
images_aug = blurer.augment_images(images)
# Same again, but this time the mean of the normal distribution is not constant,
# but comes itself from a uniform distribution between 0.5 and 1.5.
blurer = iaa.GaussianBlur(iap.Clip(iap.Normal(iap.Uniform(0.5, 1.5), 0.1), 0.1, 3.0))
images_aug = blurer.augment_images(images)
# Use for sigma one of exactly three allowed values: 0.5, 1.0 or 1.5.
blurer = iaa.GaussianBlur(iap.Choice([0.5, 1.0, 1.5]))
images_aug = blurer.augment_images(images)
# Sample sigma from a discrete uniform distribution of range 1 <= sigma <= 5,
# i.e. sigma will have any of the following values: 1, 2, 3, 4, 5.
blurer = iaa.GaussianBlur(iap.DiscreteUniform(1, 5))
images_aug = blurer.augment_images(images)
すでに定義された順序でオグメンタを動的に非アクティブにすることができます 。
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
# images and heatmaps, just arrays filled with value 30
images = np.ones((16, 128, 128, 3), dtype=np.uint8) * 30
heatmaps = np.ones((16, 128, 128, 21), dtype=np.uint8) * 30
# add vertical lines to see the effect of flip
images[:, 16:128-16, 120:124, :] = 120
heatmaps[:, 16:128-16, 120:124, :] = 120
seq = iaa.Sequential([
iaa.Fliplr(0.5, name="Flipper"),
iaa.GaussianBlur((0, 3.0), name="GaussianBlur"),
iaa.Dropout(0.02, name="Dropout"),
iaa.AdditiveGaussianNoise(scale=0.01*255, name="MyLittleNoise"),
iaa.AdditiveGaussianNoise(loc=32, scale=0.0001*255, name="SomeOtherNoise"),
iaa.Affine(translate_px={"x": (-40, 40)}, name="Affine")
])
# change the activated augmenters for heatmaps,
# we only want to execute horizontal flip, affine transformation and one of
# the gaussian noises
def activator_heatmaps(images, augmenter, parents, default):
if augmenter.name in ["GaussianBlur", "Dropout", "MyLittleNoise"]:
return False
else:
# default value for all other augmenters
return default
hooks_heatmaps = ia.HooksImages(activator=activator_heatmaps)
seq_det = seq.to_deterministic() # call this for each batch again, NOT only once at the start
images_aug = seq_det.augment_images(images)
heatmaps_aug = seq_det.augment_images(heatmaps, hooks=hooks_heatmaps)
イメージは、 batches
がイメージバッチのリストまたはimgaug.KeypointsOnImage
バッチ/リストのリストまたはimgaug.KeypointsOnImage
リストであると予想されるメソッドaugment_batches(batches, background=True)
を使用して、 バックグラウンドプロセスで拡張することができます。 次の例は、バックグラウンドで画像バッチのリストを補強します。
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
from skimage import data
# Number of batches and batch size for this example
nb_batches = 10
batch_size = 32
# Example augmentation sequence to run in the background
augseq = iaa.Sequential([
iaa.Fliplr(0.5),
iaa.CoarseDropout(p=0.1, size_percent=0.1)
])
# For simplicity, we use the same image here many times
astronaut = data.astronaut()
astronaut = ia.imresize_single_image(astronaut, (64, 64))
# Make batches out of the example image (here: 10 batches, each 32 times
# the example image)
batches = []
for _ in range(nb_batches):
batches.append(
np.array(
[astronaut for _ in range(batch_size)],
dtype=np.uint8
)
)
# Show the augmented images.
# Note that augment_batches() returns a generator.
for images_aug in augseq.augment_batches(batches, background=True):
misc.imshow(ia.draw_grid(images_aug, cols=8))
イメージは、さらに柔軟性を提供するimgaug.BackgroundAugmenter
クラスとimgaug.BackgroundAugmenter
クラスを使用してバックグラウンドプロセスで拡張することもできます。 ( augment_batches()
はこれらを囲むラッパーです)。これらのクラスを使用することは、同時に読み込みたくない画像がたくさんある場合には便利です。
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
from skimage import data
# Example augmentation sequence to run in the background.
augseq = iaa.Sequential([
iaa.Fliplr(0.5),
iaa.CoarseDropout(p=0.1, size_percent=0.1)
])
# A generator that loads batches from the hard drive.
def load_batches():
# Here, load 10 batches of size 4 each.
# You can also load an infinite amount of batches, if you don't train
# in epochs.
batch_size = 4
nb_batches = 10
# Here, for simplicity we just always use the same image.
astronaut = data.astronaut()
astronaut = ia.imresize_single_image(astronaut, (64, 64))
for i in range(nb_batches):
# A list containing all images of the batch.
batch_images = []
# A list containing IDs of images in the batch. This is not necessary
# for the background augmentation and here just used to showcase that
# you can transfer additional information.
batch_data = []
# Add some images to the batch.
for b in range(batch_size):
batch_images.append(astronaut)
batch_data.append((i, b))
# Create the batch object to send to the background processes.
batch = ia.Batch(
images=np.array(batch_images, dtype=np.uint8),
data=batch_data
)
yield batch
# background augmentation consists of two components:
# (1) BatchLoader, which runs in a Thread and calls repeatedly a user-defined
# function (here: load_batches) to load batches (optionally with keypoints
# and additional information) and sends them to a queue of batches.
# (2) BackgroundAugmenter, which runs several background processes (on other
# CPU cores). Each process takes batches from the queue defined by (1),
# augments images/keypoints and sends them to another queue.
# The main process can then read augmented batches from the queue defined
# by (2).
batch_loader = ia.BatchLoader(load_batches)
bg_augmenter = ia.BackgroundAugmenter(batch_loader, augseq)
# Run until load_batches() returns nothing anymore. This also allows infinite
# training.
while True:
print("Next batch...")
batch = bg_augmenter.get_batch()
if batch is None:
print("Finished epoch.")
break
images_aug = batch.images_aug
print("Image IDs: ", batch.data)
misc.imshow(np.hstack(list(images_aug)))
batch_loader.terminate()
bg_augmenter.terminate()
オーグメンター一覧
使用可能なオーグメンターのリストは次のとおりです。 以下の変数の大部分は範囲として設定することができます。例えば、 A=(0.0, 1.0)
画像ごとに0と1.0の間のランダム値をサンプリングします。
増強 | 説明 |
---|---|
シーケンシャル(C、R) | 子オーギュメンタC リストを取得し、その順序で画像に適用します。 R がtrueの場合(デフォルト:false)、順序はランダムです(バッチごとに1回選択されます)。 |
SomeOf(N、C、R) | オーグメンターC リストからN ランダムに選択されたオーグメンターを各画像に適用します。 オーグメンターは画像ごとに選択されます。 R はSequential と同じです。 1から3を選ぶために、 N は範囲(例えば(1, 3) にすることができます。 |
OneOf(C) | SomeOf(1, C) と同じです。 |
時には(P、C、D) | 子オーグメントC を使用して確率P 画像を拡大し、そうでなければD 使用する。 D がNoneの場合、すべての画像のP %のみがC 使用して拡張されます。 |
色空間(T、F、C) | 画像を色空間F (デフォルト:RGB)から色空間T に変換し、拡張子C を適用してからF 変換します。 |
WithChannels(H、C) | 各画像チャンネルH (例えば、RGB画像の赤と緑について[0,1] から選択し、子オーグメントC をこれらのチャンネルに適用し、結果を元の画像に戻す。 |
Noop() | 何もしない。 (検証/テストに役立ちます) |
ラムダ(I、K) | ラムダ関数I を画像に適用し、 K をキーポイントI 適用します。 |
AssertLambda(I、K) | ラムダ関数I とキーポイントを使ってK を介して画像をチェックし、どちらかがfalseを返すとエラーが発生します。 |
AssertShape(S) | 入力画像が形状S ない場合にエラーを発生させます。 |
スケール(S、I) | イメージをサイズS にサイズ変更します。 HxW を形作るすべてのイメージのサイズを変更するには、 S={"height":H, "width":W} を使用するのがHxW です。 H とW は浮動小数点数です(例:元のサイズの50% にサイズ変更)。 H またはW は片側の新しいサイズのみを定義し、それに対応して反対側のサイズを変更する"keep-aspect-ratio" に"keep-aspect-ratio" にすることができます。 I は使用する補間法です(デフォルト: cubic )。 |
CropAndPad(PX、PC、PM、PCV、KS) | 画像の上/右/下/左のPX ピクセルまたはPC パーセントを切り取りまたはパッディングします。 負の値を指定するとクロッピングが発生し、パディングが正の値になります。 PM はパッドモードを定義します(たとえば、追加されたすべてのピクセルに均一な色を使用します)。 PCV がPM=constant 場合、 PCV は追加されたピクセルの色を制御します。 KS がtrue(デフォルト)の場合、結果のイメージは元のサイズにリサイズされます。 |
パッド(PX、PC、PM、PCV、KS) | CropAndPad()のショートカット。ピクセルを追加するだけです。 PX とPC は正の値のみが許されます。 |
作物(PX、PC、KS) | CropAndPad()のショートカット。ピクセルだけを切り抜きます。 正の値のみがPX とPC 使用できます(例:5の場合、5ピクセルが切り捨てられます)。 |
Fliplr(P) | 確率P 画像を水平に反転させる。 |
Flipud(P) | 確率P 画像を垂直方向に反転させる。 |
スーパーピクセル(P、N、M) | (最大)解像度MでN個のスーパーピクセルを生成し、元のサイズにリサイズします。 その後、元の画像内のすべてのスーパーピクセルエリアのP %がスーパーピクセルに置き換えられます。 (1-P)パーセントは変わらないままである。 |
ChangeColorspace(T、F、A) | 色空間F からT 画像を変換し、アルファA を使用して元の画像とミックスします。 グレースケールは3チャンネルのままです。 (十分にテストされていない増強剤は、自己の責任で使用してください。) |
グレースケール(A、F) | 色空間F(デフォルト:RGB)の画像をグレースケールに変換し、アルファA を使用して元の画像とミックスします。 |
GaussianBlur(S) | サイズS ガウスカーネルを使用して画像をぼかします。 |
AverageBlur(K) | サイズK 単純な平均化カーネルを使用して画像をぼかします。 |
MedianBlur(K) | サイズK ネイバーフッド以上のメジアンを使用して画像をぼかします。 |
BilateralBlur(D、SC、SS) | 距離D (カーネルサイズなど)のバイラテラルフィルタを使用して画像をぼかします。 SC は色空間における(影響)距離に対するシグマであり、 SS は空間距離に対するシグマである。 |
コンボルブ(M) | ラムダ関数である可能性がある行列M でイメージを変換します。 |
シャープ(A、L) | 明るさL (低い値は暗い画像になります)で各画像に鮮鋭化カーネルを実行します。 アルファA を使用して結果を元の画像とミックスします。 |
エンボス(A、S) | エンボスカーネルを強度S 各画像上で走らせる。 アルファA を使用して結果を元の画像とミックスします。 |
EdgeDetect(A) | 各画像にエッジ検出カーネルを実行します。 アルファA を使用して結果を元の画像とミックスします。 |
DirectedEdgeDetect(A、D) | 方向性エッジ検出カーネルを各画像上で実行し、方向D からそれぞれを検出する(デフォルト:画像ごとに選択される0〜360度のランダムな方向)。 アルファA を使用して結果を元の画像とミックスします。 |
加算(V、PCH) | 各画像に値V を加えます。 PCH が真の場合、サンプリングされた値はチャンネルごとに異なる場合があります。 |
AddElementwise(V、PCH) | 各ピクセルに値V を加算します。 PCH が真の場合、サンプリングされた値はチャネル(およびピクセル)ごとに異なる場合があります。 |
AddToHueAndSaturation(V、PCH、F、C) | HSV空間の各ピクセルに値V を追加します(つまり、色相と彩度を変更します)。 色空間FからHSV(デフォルトはF = RGB)に変換されます。 増強する前にチャネルCを選択します(デフォルトはC = [0,1])。 PCH が真の場合、サンプリングされた値はチャンネルごとに異なる場合があります。 |
AdditiveGaussianNoise(L、S、PCH) | 白色/ガウスノイズをピクセル単位で画像に追加します。 ノイズは正規分布N(L,S) 由来します。 PCH が真の場合、サンプリングされた値はチャネル(およびピクセル)ごとに異なる場合があります。 |
乗算(V、PCH) | 各画像を値V で乗算し、より暗い/明るい画像に導きます。 PCH が真の場合、サンプリングされた値はチャンネルごとに異なる場合があります。 |
MultiplyElementwise(V、PCH) | 各ピクセルに値V 乗算し、より暗く/明るいピクセルに導きます。 PCH が真の場合、サンプリングされた値はチャネル(およびピクセル)ごとに異なる場合があります。 |
ドロップアウト(P、PCH) | 確率P ピクセルをゼロに設定します。 PCH が真であれば、チャネルは異なって扱われ、そうでなければ全ピクセルはゼロに設定される。 |
粗ドローアウト(P、SPX、SPC、PCH) | Dropout と同様に、画素サイズSPX または相対サイズSPC を有するより粗い/より小さい画像からゼロに設定される画素の位置をサンプリングする。 つまり、 SPC 値が小さい場合、粗いマップは小さく、大きな四角形がドロップされます。 |
反転(P、PCH) | 確率P 画像内のすべてのピクセルを反転します。つまり、(1-pixel_value)に設定します。 PCH が真の場合、各チャンネルは個別に扱われます(一部のチャンネルのみが反転します)。 |
コントラスト正規化(S、PCH) | ピクセル値を128に近づけるかまたは128に近づけることによって、画像のコントラストを変更します。方向と強さはS で定義します。 PCH が真に設定されている場合、プロセスはおそらく異なるS でチャネルごとに発生します。 |
アフィン(S、TPX、TPC、R、SH、O、M、CVAL) | 画像にアフィン変換を適用します。 S (> 1 =ズームイン、<1 =ズームアウト)でスケールし、 TPX ピクセルまたはTPC パーセントで変換し、 R 度で回転し、 SH 度でシアーします。 補間はオーダーO (0または1が良好で速い)で起こります。 結果のイメージに領域が表示されることがありますが、元のイメージには対応する領域がありません。 M は、これらをどのように扱うかを定義します。 M='constant' 場合、 CVAL は領域を埋める定数値を定義します。 |
ピースワイズアフィン(S、R、C、O、M、CVAL) | 画像上に点の規則的なグリッドを配置します。 グリッドにはR 行とC 列があります。 次に、点(およびその周辺の画像領域)を正規分布N(0、 S )からのサンプルである量だけ移動させ、強度の異なる局所的歪みをもたらす。 O 、 M およびCVAL は、 Affine とCVAL に定義される。 |
PerspectiveTransform(S、KS) | ランダムな4点透視変換を画像に適用します(これは、高度なクロッピングのようなものです)。 各点は、シグマS 用いた正規分布から得られる画像コーナーからのランダムな距離を有する。 KS がTrue(デフォルト)に設定されている場合、各画像は元のサイズにリサイズされます。 |
弾性変形(S、SM) | 歪みフィールドに基づいて各ピクセルを個別に移動します。 SM は歪み場の滑らかさとS 強度を定義します。 |
アルファ(F、A、B、PCH) | オーグメンターA とB 独立に使用して画像を拡大し、アルファF を使用して結果をオーバーレイします。 A とB デフォルトでは提供されていない場合は何もしません。 たとえばAlpha(0.9, A) 使用して画像を補強するためにAlpha(0.9, A) を使用し、その結果を元の画像の10%( A 前)に保ちます。 PCH がtrueに設定されている場合、プロセスはチャネルごとに異なるF ( A とB が画像ごとに1回計算される)で発生します。 |
AlphaElementwise(F、A、B、PCH) | Alpha と同じですが、 F からサンプリングされた連続マスク(値0.0〜1.0)を使用してピクセル単位でブレンドを実行します。 PCH がtrueに設定されている場合、プロセスはピクセル単位とチャネル単位の両方で行われます。 |
SimplexNoiseAlpha(A、B、PCH、SM、UP、I、AGG、SIG、SIGT) | Alpha と似ていますが、マスクを使用してオーグメンターA とB 結果をブレンドします。 マスクはシンプレックスノイズからサンプリングされます。シンプレックスノイズはブロブビーである傾向があります。 マスクはI 回の反復で収集され(デフォルトは1〜3)、各反復は集約メソッドAGG (デフォルトの最大値、つまりピクセルごとのすべての反復からの最大値)を使用して結合されます。 各マスクは、最大解像度SM (デフォルトは2〜16ピクセル)で低解像度空間でサンプリングされ、方法UP (デフォルト:線形または立方体または最近傍アップサンプリング)を使用して画像サイズにアップスケールされます。 SIG が真の場合、 SIGT マスクにシグモイドがマスクに適用され、ブロブの値が0.0または1.0に近い値になります。 |
FrequencyNoiseAlpha(E、A、B、PCH、SM、UP、I、AGG、SIG、SIGT) | SimplexNoiseAlpha に似ていますが、周波数領域からノイズマスクを生成します。 指数E は、周波数成分を増減するために使用されます。 値を大きくすると、高周波成分が顕著になります。 -4から4の範囲の値を使用します。約-2の雲のようなパターンが生成されます。 |