-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rebuild operation docs with DemoCards
- Loading branch information
1 parent
75b4818
commit 7ed7c55
Showing
52 changed files
with
697 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
build/ | ||
site/ | ||
src/generated/* | ||
/Manifest.toml | ||
src/democards | ||
/Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"title": "Affine Transformations", | ||
"order": [ | ||
"flip.jl", | ||
"rotate.jl", | ||
"shear.jl", | ||
"scale.jl", | ||
"resize.jl", | ||
"zoom.jl" | ||
], | ||
"description": "A sizeable amount of the provided operations fall under the category of **affine transformations**. As such, they can be described using what is known as an [affine map](https://en.wikipedia.org/wiki/Affine_transformation), which are inherently compose-able if chained together. However, utilizing such a affine formulation requires (costly) interpolation, which may not always be needed to achieve the desired effect. For that reason do some of the operations below also provide a special purpose implementation to produce their specified result. Those are usually preferred over the affine formulation if sensible considering the complete pipeline." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# --- | ||
# title: Flip | ||
# cover: flip.gif | ||
# description: flip the input image horizontally or vertically | ||
# --- | ||
|
||
# [`FlipX`](@ref)/[`FlipY`](@ref) can be used to flip the input image horizontally/vertically. | ||
|
||
using Augmentor | ||
using ImageShow, ImageCore | ||
|
||
img_in = testpattern(RGB, ratio=0.5) | ||
|
||
mosaicview( | ||
img_in, | ||
augment(img_in, FlipX()), | ||
augment(img_in, FlipY()); | ||
fillvalue=colorant"white", nrow=1, npad=10 | ||
) | ||
|
||
# To perform a random flip, you can also pass the probablity to the constructor. For example, `FlipX(0.5)` | ||
# flips the image with half chance. | ||
|
||
# ## References | ||
|
||
#md # ```@docs | ||
#md # FlipX | ||
#md # FlipY | ||
#md # ``` | ||
|
||
|
||
## save covers #src | ||
using ImageMagick #src | ||
using FileIO #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Either(FlipX(), FlipY()), 4) #src | ||
ImageMagick.save("flip.gif", cover; fps=1) #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# --- | ||
# title: Resize | ||
# cover: resize.gif | ||
# --- | ||
|
||
# Set the static size of the image | ||
|
||
using Augmentor | ||
using ImageShow, ImageCore | ||
|
||
img_in = testpattern(RGB, ratio=0.5) | ||
|
||
mosaicview( | ||
img_in, | ||
augment(img_in, Resize(240, 320)); | ||
fillvalue=colorant"white", nrow=1, npad=10 | ||
) | ||
|
||
|
||
# ## References | ||
|
||
#md # ```@docs | ||
#md # Resize | ||
#md # ``` | ||
|
||
## save covers #src | ||
using ImageMagick #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Resize(240, 320), 2) #src | ||
ImageMagick.save("resize.gif", cover; fps=1) #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# --- | ||
# title: Rotate | ||
# cover: rotate.gif | ||
# description: rotate image anticlockwise | ||
# --- | ||
|
||
# The type [`Rotate`](@ref) defines a generic anticlockwise rotation operation around the center | ||
# of the image. It is also possible to pass some abstract vector to the constructor, in which case | ||
# Augmentor will randomly sample one of its elements every time the operation is applied. | ||
|
||
using Augmentor | ||
using ImageShow, ImageCore | ||
using Random | ||
Random.seed!(0) | ||
|
||
img_in = testpattern(RGB, ratio=0.5) | ||
mosaicview( | ||
img_in, | ||
|
||
## deterministic rotation | ||
augment(img_in, Rotate(45)), | ||
|
||
## random rotation | ||
augment(img_in, Rotate(-45:45)); | ||
fillvalue=colorant"white", nrow=1, npad=10 | ||
) | ||
|
||
# Note that the output image size will be changed after rotation, [`CropNative`](@ref) can be particalually | ||
# useful to preserve the image size. | ||
|
||
mosaicview( | ||
augment(img_in, Rotate(45)), | ||
augment(img_in, Rotate(45) |> CropNative(axes(img_in))); | ||
nrow=1, npad=10 | ||
) | ||
|
||
# Rotation by some special degree (e.g.,90, 180 and 270) can be handled more efficiently without interpolation. | ||
# Compared to `Rotate(90)`, it is recommended to use [`Rotate90`](@ref) when possible. [`Rotate180`](@ref) and | ||
# [`Rotate270`](@ref) are available, too. | ||
|
||
# ## References | ||
|
||
#md # ```@docs | ||
#md # Rotate | ||
#md # Rotate90 | ||
#md # Rotate180 | ||
#md # Rotate270 | ||
#md # ``` | ||
|
||
## save covers #src | ||
using ImageMagick #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Rotate(-20:20), 5) #src | ||
ImageMagick.save("rotate.gif", cover; fps=1) #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# --- | ||
# title: Scale | ||
# cover: scale.gif | ||
# --- | ||
|
||
# Relatively resizing image | ||
|
||
using Augmentor | ||
using ImageShow, ImageCore | ||
using Random | ||
|
||
# In the case that only a single scale factor is specified, the | ||
# operation will assume that the intention is to scale all | ||
# dimensions uniformly by that factor. | ||
|
||
img_in = testpattern(RGB, ratio=0.5) | ||
|
||
mosaicview( | ||
img_in, | ||
augment(img_in, Scale(0.8)), | ||
augment(img_in, Scale(0.8, 1)); | ||
|
||
fillvalue=colorant"white", nrow=1, npad=10 | ||
) | ||
|
||
# It is also possible to pass some abstract vector(s) to the | ||
# constructor, in which case Augmentor will randomly sample one of | ||
# its elements every time the operation is applied. | ||
|
||
Random.seed!(1337) | ||
img_out = [augment(img_in, Scale(0.9:0.05:1.2)) for _ in 1:4] | ||
mosaicview(img_out...; fillvalue=colorant"white", nrow=2) | ||
|
||
# ## References | ||
|
||
#md # ```@docs | ||
#md # Scale | ||
#md # ``` | ||
|
||
## save covers #src | ||
using ImageMagick #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Scale(0.9:0.1:1.5), 5) #src | ||
ImageMagick.save("scale.gif", cover; fps=1) #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# --- | ||
# title: Shear | ||
# cover: shear.gif | ||
# description: shear the input image horizontally or vertically | ||
# --- | ||
|
||
# [`ShearX`](@ref)/[`ShearY`](@ref) 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`](@ref) 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 | ||
|
||
#md # ```@docs | ||
#md # ShearX | ||
#md # ShearY | ||
#md # ``` | ||
|
||
## save covers #src | ||
using ImageMagick #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Either(ShearX(-10:10), ShearY(-10:10)), 5) #src | ||
ImageMagick.save("shear.gif", cover; fps=1) #src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# --- | ||
# title: Zoom | ||
# cover: zoom.gif | ||
# --- | ||
|
||
# Scale without resize | ||
|
||
using Augmentor | ||
using ImageShow, ImageCore | ||
using Random | ||
|
||
# In the case that only a single Zoom factor is specified, the | ||
# operation will assume that the intention is to Zoom all | ||
# dimensions uniformly by that factor. | ||
|
||
img_in = testpattern(RGB, ratio=0.5) | ||
|
||
mosaicview( | ||
img_in, | ||
augment(img_in, Zoom(1.3)), | ||
augment(img_in, Zoom(1.3, 1)); | ||
fillvalue=colorant"white", nrow=1, npad=10 | ||
) | ||
|
||
# It is also possible to pass some abstract vector(s) to the | ||
# constructor, in which case Augmentor will randomly sample one of | ||
# its elements every time the operation is applied. | ||
|
||
Random.seed!(1337) | ||
img_out = [augment(img_in, Zoom(0.9:0.05:1.2)) for _ in 1:4] | ||
|
||
mosaicview(img_out...; nrow=2) | ||
|
||
# ## References | ||
|
||
#md # ```@docs | ||
#md # Zoom | ||
#md # ``` | ||
|
||
## save covers #src | ||
using ImageMagick #src | ||
include(joinpath("..", "assets", "utilities.jl")) #src | ||
cover = make_gif(testpattern(RGB, ratio=0.5), Zoom(0.9:0.1:1.5), 5) #src | ||
ImageMagick.save("zoom.gif", cover; fps=1) #src |
Oops, something went wrong.