Skip to content

move var, std to ColorVectorSpace #872

@johnnychen94

Description

@johnnychen94

The right place for var and std should be ColorVectorSpace

function Statistics.var(A::AbstractArray{C}; kwargs...) where C<:AbstractGray
imgc = channelview(A)
base_colorant_type(C)(var(imgc; kwargs...))
end
function Statistics.var(A::AbstractArray{C,N}; kwargs...) where {C<:Colorant,N}
imgc = channelview(A)
colons = ntuple(d->Colon(), Val(N))
inds1 = axes(imgc, 1)
val1 = Statistics.var(view(imgc, first(inds1), colons...); kwargs...)
vals = similar(imgc, typeof(val1), inds1)
vals[1] = val1
for i in first(inds1)+1:last(inds1)
vals[i] = Statistics.var(view(imgc, i, colons...); kwargs...)
end
base_colorant_type(C)(vals...)
end
Statistics.std(A::AbstractArray{C}; kwargs...) where {C<:Colorant} = mapc(sqrt, Statistics.var(A; kwargs...))

Steps to achieve it:

  1. copy codes to ColorVectorSpaces, merge and ask for a new release
  2. remove codes here: since ColorVectorSpace is loaded in this package, we don't need to deprecate them. But we need some compatibility-checking codes so that if an older version of ColorVectorSpace is installed, this package still functions normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions