Evizero / Augmentor.jl

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

Add `channel_dims` argument to `CombineChannels`/`SplitChannels` #99

Open johnnychen94 opened 3 years ago

johnnychen94 commented 3 years ago

Internally, CombineChannels uses ImageCore.colorview to do the work, which requires the data layout to be CHW. When deal with deep learning frameworks, it's often the case that we need to handle HWC/WHC layout.

Previously, CombineChannels(RGB) interpret rand(3, 4, 4) as a 4x4 RGB image and errors for rand(4, 4, 3). And SplitChannels() unconditionally interpret rand(RGB, 4, 4) as 3x4x4 numerical array.

So the idea is to let CombineChannels(RGB, 3) interpret rand(4, 4, 3) as a 4x4 RGB image, and to let SplitChannels(3) interpret rand(RGB, 4, 4) as 4x4x3 numerical array.

Edit: When I opened this issue I didn't realize that PermuteDims is also an Augmentor operation; there are two very similar names in Base permutedims and PermutedDimsArray. PermuteDims is no doubt more generic than channel_dims argument proposed here. Thus this proposal is only to make things more convenient for a very specific usage; it doesn't fill any missing functionalities.