CropRatio

Source code notebook

Crop centered window to fit given aspect ratio

using Augmentor
using ImageShow, ImageCore

img_in = testpattern(RGB, ratio=0.5)
img_out = augment(img_in, CropRatio()) # crop out a square window

mosaicview(img_in, img_out; nrow=1)

RCropRatio is a random version that randomly choose a crop center – not necessarily the center of the input image.

augment(img_in, RCropRatio())

Reference

Augmentor.CropRatioType
CropRatio <: Augmentor.ImageOperation

Description

Crops out the biggest area around the center of the given image such that the output image satisfies the specified aspect ratio (i.e. width divided by height).

For example the operation CropRatio(1) would denote a crop for the biggest square around the center of the image.

For randomly placed crops take a look at RCropRatio.

Usage

CropRatio(ratio)

CropRatio(; ratio = 1)

Arguments

  • ratio::Number : Optional. A number denoting the aspect ratio. For example specifying ratio=16/9 would denote a 16:9 aspect ratio. Defaults to 1, which describes a square crop.

See also

RCropRatio, CropSize, Crop, CropNative, augment

Examples

using Augmentor
img = testpattern()

# crop biggest square around the image center
augment(img, CropRatio(1))
source
Augmentor.RCropRatioType
RCropRatio <: Augmentor.ImageOperation

Description

Crops out the biggest possible area at some random position of the given image, such that the output image satisfies the specified aspect ratio (i.e. width divided by height).

For example the operation RCropRatio(1) would denote a crop for the biggest possible square. If there is more than one such square, then one will be selected at random.

Usage

RCropRatio(ratio)

RCropRatio(; ratio = 1)

Arguments

  • ratio::Number : Optional. A number denoting the aspect ratio. For example specifying ratio=16/9 would denote a 16:9 aspect ratio. Defaults to 1, which describes a square crop.

See also

RCropSize, CropRatio, CropSize, Crop, CropNative, augment

Examples

using Augmentor
img = testpattern()

# crop a randomly placed square of maxmimum size
augment(img, RCropRatio(1))
source

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