Evizero / Augmentor.jl

A fast image augmentation library in Julia for machine learning.
https://evizero.github.io/Augmentor.jl/
Other
137 stars 48 forks source link

Use `of_eltype` instead of convert lambda #95

Closed barucden closed 2 years ago

barucden commented 2 years ago

As suggested by @timholy in #17, this PR changes mappedarray(c->convert(T,c), img) to of_eltype(T, img). It results in MappedArray instead of ReadonlyMappedArray, and it is more descriptive too.

This PR does not deal with #17, but I can confirm that the issue seems to be fixed already (which @johnnychen94 noticed before) and can be closed:

julia> using Augmentor, Test

julia> img = testpattern();

julia> @inferred(augment(img, ConvertEltype(Gray))) |> summary # Gray{Any}
"300×400 Array{Gray,2} with eltype Gray"

julia> pl = SplitChannels() |> ConvertEltype(Gray)
2-step Augmentor.ImmutablePipeline:
 1.) Split colorant into its color channels
 2.) Convert eltype to Gray

julia> @inferred(augment(img, pl)) |> summary # Gray{N0f8}
"4×300×400 Array{Gray{N0f8},3} with eltype Gray{FixedPointNumbers.N0f8}"
barucden commented 2 years ago

Tests passed. Thanks!