IIUC this package provides a pixel version of the deprecated ColorizedArray. Now I can see that this is a useful concept in fluorophore imaging. Compared to defining the Color subtypes manually for every combination, the benefit of this ColorMixture concept is to provide a user-friendly interface to design a new color type, which is great.
But fluorophore image is not the only field that has this concept; this can be generalized to hyperspectral imaging where there can be as many channels as the hardware supports.
Thus I'm wondering if we can 1) separate this concept into a standalone package, e.g., MixedColors.jl, and, 2) generalize this concept and allow the user library (e.g., FluorophoreColors) to define its domain-specific color types.
A draft type design for this can be:
MixedColors.jl
struct MixedColorInfo{CS, F}
cs::CS
to_rgb::F
end
struct MixedColor{T,N,INFO} <: Color{T,N}
channels::NTuple{N,T}
end
User library:
# FluorophoreColors.jl
_to_rgb(channels, cs) = sum(map(*, channels, cs))
const _FRGB_INFO = MixedColorInfo(cs, _to_rgb)
const FRGB{T,N} = MixedColor{T,N,_FRGB_INFO}
# with other Fluorophore-specific definitions, e.g., loading the definition from csv file.
...
I believe the parametrization trick on values Cs (instead of types typeof(Cs)) works because the types of fluorephore colors are limited and RGB{N0f8} is internally tuple of integers. Thus here I extend it to a struct, but I'm not sure if parametrization on the function to_rgb works reliably; I guess it works because we also have things like map(::typeof(+), ...) usage.
IIUC this package provides a pixel version of the deprecated ColorizedArray. Now I can see that this is a useful concept in fluorophore imaging. Compared to defining the
Colorsubtypes manually for every combination, the benefit of thisColorMixtureconcept is to provide a user-friendly interface to design a new color type, which is great.But fluorophore image is not the only field that has this concept; this can be generalized to hyperspectral imaging where there can be as many channels as the hardware supports.
Thus I'm wondering if we can 1) separate this concept into a standalone package, e.g., MixedColors.jl, and, 2) generalize this concept and allow the user library (e.g., FluorophoreColors) to define its domain-specific color types.
A draft type design for this can be:
MixedColors.jl
User library:
I believe the parametrization trick on values
Cs(instead of typestypeof(Cs)) works because the types of fluorephore colors are limited andRGB{N0f8}is internally tuple of integers. Thus here I extend it to astruct, but I'm not sure if parametrization on the functionto_rgbworks reliably; I guess it works because we also have things likemap(::typeof(+), ...)usage.