Shear

Source code notebook

ShearX/ShearY can be used to shear the input image horizontally/vertically. The input to the constructor can be a scalar or a vector. In the case of a vector, the transformation will be a stochastic process.

using Augmentor
using ImageShow, ImageCore
using Random
Random.seed!(0)
img_in = testpattern(RGB, ratio=0.5)

mosaicview(
    # deterministic transformation
    augment(img_in, ShearX(20)),
    augment(img_in, ShearY(20)),

    # random transformation
    augment(img_in, ShearX(-20:20)),
    augment(img_in, ShearY(-20:20));

    fillvalue=colorant"white", nrow=2, npad=10
)

Note that the output image size will be changed after transformation, CropNative can be particalually useful to preserve the image size.

mosaicview(
    augment(img_in, ShearX(10)),
    augment(img_in, ShearX(10) |> CropNative(axes(img_in)));
    fillvalue=colorant"white", nrow=1, npad=10
)

References

Augmentor.ShearX โ€” Type
ShearX <: Augmentor.AffineOperation

Description

Shear the image horizontally for the given degree. This operation can only be performed as an affine transformation and will in general cause other operations of the pipeline to use their affine formulation as well (if they have one).

It will always perform the transformation around the center of the image. This can be particularly useful when combining the operation with CropNative.

Usage

ShearX(degree)

Arguments

  • degree : Real or AbstractVector of Real that denote the shearing angle(s) in degree. If a vector is provided, then a random element will be sampled each time the operation is applied.

See also

ShearY, CropNative, augment

Examples

using Augmentor
img = testpattern()

# shear horizontally exactly 5 degree
augment(img, ShearX(5))

# shear horizontally between 10 and 20 degree to the right
augment(img, ShearX(10:20))

# shear horizontally one of the five specified degrees
augment(img, ShearX([-10, -5, 0, 5, 10]))
source
Augmentor.ShearY โ€” Type
ShearY <: Augmentor.AffineOperation

Description

Shear the image vertically for the given degree. This operation can only be performed as an affine transformation and will in general cause other operations of the pipeline to use their affine formulation as well (if they have one).

It will always perform the transformation around the center of the image. This can be particularly useful when combining the operation with CropNative.

Usage

ShearY(degree)

Arguments

  • degree : Real or AbstractVector of Real that denote the shearing angle(s) in degree. If a vector is provided, then a random element will be sampled each time the operation is applied.

See also

ShearX, CropNative, augment

Examples

using Augmentor
img = testpattern()

# shear vertically exactly 5 degree
augment(img, ShearY(5))

# shear vertically between 10 and 20 degree upwards
augment(img, ShearY(10:20))

# shear vertically one of the five specified degrees
augment(img, ShearY([-10, -5, 0, 5, 10]))
source

This page was generated using DemoCards.jl and Literate.jl.