Description
As a continuation of #767 I thought I'd start the process of drafting some tentative changes to the Images API to facilitate further discussion.
One aspect that we need to pin down is how we are going to design the API to support the execution of algorithms that take advantage of the GPU. The ImageFiltering
package which makes use of the ComputationalResources.jl package to dispatch to an implementation most suitable for a particular device.
exposure.jl
I'll use the exposure.jl
file as an example of how we might want to restructure our API.
That file used to export the following functions:
Exposure : `imhist`, `histeq`, `adjust_gamma`, `histmatch`, `imadjustintensity`, `imstretch`, `imcomplement`, `clahe`, `cliphist`
My intention is to introduce the following types:
abstract type AbstractHistogramOperation end
struct Equalization <: AbstractHistogramOperation end
struct Matching <: AbstractHistogramOperation end
struct Stretching <: AbstractHistogramOperation end
struct Clipping <: AbstractHistogramOperation end
struct CLAHE <: AbstractHistogramOperation end
and to have a functions
adjust_histogram(op::Equalization, params...)
adjust_histogram(op::Matching, params...)
adjust_histogram(op::Stretching, params...)
adjust_histogram(op::Clipping, params...)
adjust_histogram(op::CLAHE, params...)
I thought of adding struct GammaCorrection <: AbstractHistogramOperation
and then
adjust_histogram(op::GammaCorrections, params...)
but we could also have adjust_gamma(params...)
and I'm not sure what people would prefer here.
Additionally, we would have the build_histogram(params...)
functions. I presume that the
imadjustintensity
and imstretch
could be absorbed as sub-types of the aforementioned AbstractHistogramOperation
types.
Taking into consideration that one could envisage GPU based implementations of these algorithms, perhaps function arguments ought to follow a: what, were, how
pattern. That is, the first parameter designates which operation to dispatch on, the second parameter designates whether a CPU/GPU based implementation is desired and the remaining parameters are the standard input parameters to the function. The second parameter could by default be set to CPU (and hence optional). The remaining parameters could be keyword parameters, with the exception that we don't make the "obvious" inputs keyword parameters, i.e. the input image/images.
Since there are several .jl
files in the repository, I thought I'd open separate issues for each of the .jl
files in Images
. Hopefully that will help focus the discussion by breaking the tasks down.
Since I have already started rewriting some of the functions in exposure.jl
and extending the documentation I decided I may as well finish all of the functions in that file. The next major one that I intend to tackle soon is CLAHE. I'm aiming for a more concise implementation by leveraging the interpolations.jl
package.