Color Channels
References
NeuroCore.ColorChannels.channel_axis — Methodchannel_axis(x, size[; first_pad=nothing, last_pad=nothing, stride=nothing, dilation=nothing])Returns an AxisIterator along the channel axis.
NeuroCore.ColorChannels.channel_axis — Methodchannel_axis(x)Returns the axis corresponding to the channel dimension.
NeuroCore.ColorChannels.channel_axis_type — Methodchannel_axis_type(x)Returns the key type corresponding to the channel axis.
NeuroCore.ColorChannels.channel_indices — Methodchannel_indices(x)Returns the indices corresponding to the channel axis
NeuroCore.ColorChannels.channel_keys — Methodchannel_keys(x)Returns the keys corresponding to the channel axis
NeuroCore.ColorChannels.channel_view — Methodchannel_view(A)returns a view of A, splitting out (if necessary) the color channels of A into a new first dimension.
Of relevance for types like RGB and BGR, the channels of the returned array will be in constructor-argument order, not memory order (see reinterpretc if you want to use memory order).
Example
```julia img = rand(RGB{N0f8}, 10, 10) A = channel_view(img) # a 3×10×10 array
See also: color_view
NeuroCore.ColorChannels.channeldim — Methodchanneldim(x) -> IntReturns the dimension corresponding to channel.
NeuroCore.ColorChannels.clamp01! — Methodclamp01!(array::AbstractArray)Restrict values in array to [0, 1], in-place. See also clamp01.
NeuroCore.ColorChannels.clamp01 — Methodclamp01(x) -> yProduce a value y that lies between 0 and 1, and equal to x when x is already in this range. Equivalent to clamp(x, 0, 1) for numeric values. For colors, this function is applied to each color channel separately.
See also: clamp01!, clamp01nan.
NeuroCore.ColorChannels.clamp01nan! — Methodclamp01nan!(array::AbstractArray)Similar to clamp01!, except that any NaN values are changed to 0.
See also: clamp01!, clamp01nan
NeuroCore.ColorChannels.clamp01nan — Methodclamp01nan(x) -> ySimilar to clamp01, except that any NaN values are changed to 0.
See also: clamp01nan!, clamp01.
NeuroCore.ColorChannels.color_signed — Methodcolor_signed()
color_signed(colorneg, colorpos) -> f
color_signed(colorneg, colorcenter, colorpos) -> fDefine a function that maps negative values (in the range [-1,0]) to the linear colormap between colorneg and colorcenter, and positive values (in the range [0,1]) to the linear colormap between colorcenter and colorpos.
The default colors are:
colorcenter: whitecolorneg: green1colorpos: magenta
See also: scale_signed.
NeuroCore.ColorChannels.color_view — Methodcolor_view(C, gray1, gray2, ...) -> imgCCombine numeric/grayscale images gray1, gray2, etc., into the separate color channels of an array imgC with element type C<:Colorant.
As a convenience, the constant zeroarray fills in an array of matched size with all zeros.
Example
imgC = color_view(RGB, r, zeroarray, b)creates an image with r in the red chanel, b in the blue channel, and nothing in the green channel.
See also: StackedView.
NeuroCore.ColorChannels.color_view — Methodcolor_view(C, A)returns a view of the numeric array A, interpreting successive elements of A as if they were channels of Colorant C.
Of relevance for types like RGB and BGR, the elements of A are interpreted in constructor-argument order, not memory order (see reinterpretc if you want to use memory order).
Example
A = rand(3, 10, 10)
img = color_view(RGB, A)See also: channel_view
NeuroCore.ColorChannels.float32 — Functionfloat32.(img)converts the raw storage type of img to Float32, without changing the color space.
NeuroCore.ColorChannels.float64 — Functionfloat64.(img)converts the raw storage type of img to Float64, without changing the color space.
NeuroCore.ColorChannels.n0f16 — Functionn0f16.(img)converts the raw storage type of img to N0f16, without changing the color space.
NeuroCore.ColorChannels.n0f8 — Functionn0f8.(img)converts the raw storage type of img to N0f8, without changing the color space.
NeuroCore.ColorChannels.n2f14 — Functionn2f14.(img)converts the raw storage type of img to N2f14, without changing the color space.
NeuroCore.ColorChannels.n4f12 — Functionn4f12.(img)converts the raw storage type of img to N4f12, without changing the color space.
NeuroCore.ColorChannels.n6f10 — Functionn6f10.(img)converts the raw storage type of img to N6f10, without changing the color space.
NeuroCore.ColorChannels.nchannel — Methodnchannel(x) -> IntReturns the size along the dimension corresponding to the channel.
NeuroCore.ColorChannels.normed_view — Methodnormed_view([T], img::AbstractArray{Unsigned})returns a "view" of img where the values are interpreted in terms of Normed number types. For example, if img is an Array{UInt8}, the view will act like an Array{N0f8}. Supply T if the element type of img is UInt16, to specify whether you want a N6f10, N4f12, N2f14, or N0f16 result.
See also: raw_view
NeuroCore.ColorChannels.raw_view — Methodraw_view(img::AbstractArray{FixedPoint})returns a "view" of img where the values are interpreted in terms of their raw underlying storage. For example, if img is an Array{N0f8}, the view will act like an Array{UInt8}.
See also: normed_view
NeuroCore.ColorChannels.scale_minmax — Methodscale_minmax(min, max) -> f
scale_minmax(T, min, max) -> fReturn a function f which maps values less than or equal to min to 0, values greater than or equal to max to 1, and uses a linear scale in between. min and max should be real values.
Optionally specify the return type T. If T is a colorant (e.g., RGB), then scaling is applied to each color channel.
Examples
Example 1
julia> f = scale_minmax(-10, 10)
(::#9) (generic function with 1 method)
julia> f(10)
1.0
julia> f(-10)
0.0
julia> f(5)
0.75Example 2
julia> c = RGB(255.0,128.0,0.0)
RGB{Float64}(255.0,128.0,0.0)
julia> f = scale_minmax(RGB, 0, 255)
(::#13) (generic function with 1 method)
julia> f(c)
RGB{Float64}(1.0,0.5019607843137255,0.0)See also: take_map.
NeuroCore.ColorChannels.scale_signed — Methodscale_signed(maxabs) -> fReturn a function f which scales values in the range [-maxabs, maxabs] (clamping values that lie outside this range) to the range [-1, 1].
See also: color_signed.
NeuroCore.ColorChannels.scale_signed — Methodscale_signed(min, center, max) -> fReturn a function f which scales values in the range [min, center] to [-1,0] and [center,max] to [0,1]. Values smaller than min/max get clamped to min/max, respectively.
See also: color_signed.
NeuroCore.ColorChannels.select_channel — Methodselect_channel(x, i)Return a view of all the data of x where the index for the channel dimension equals i.
NeuroCore.ColorChannels.take_map — Functiontake_map(f, A) -> fnew
take_map(f, T, A) -> fnewGiven a value-mapping function f and an array A, return a "concrete" mapping function fnew. When applied to elements of A, fnew should return valid values for storage or display, for example in the range from 0 to 1 (for grayscale) or valid colorants. fnew may be adapted to the actual values present in A, and may not produce valid values for any inputs not in A.
Optionally one can specify the output type T that fnew should produce.
Example:
julia> A = [0, 1, 1000];
julia> f = take_map(scale_minmax, A)
(::#7) (generic function with 1 method)
julia> f.(A)
3-element Array{Float64,1}:
0.0
0.001
1.0NeuroCore.ColorChannels.StackedView — TypeStackedView(B, C, ...) -> APresent arrays B, C, etc, as if they are separate channels along the first dimension of A. In particular,
B == A[1,:,:...]
C == A[2,:,:...]and so on. Combined with color_view, this allows one to combine two or more grayscale images into a single color image.
See also: color_view.
Base.float — Methodfloat(x::Colorant)
float(T::Type{<:Colorant})convert the storage type of pixel x to a floating point data type while preserving the Colorant information.
If the input is Type T, then it is equivalent to floattype.
NeuroCore.ColorChannels.each_channel — Methodeach_channel(x)Create a generator that iterates over the channel dimensions A, returning views that select all the data from the other dimensions in A.
NeuroCore.ColorChannels.getchannels — Functiongetchannels(P, C::Type, I)Get a tuple of all channels needed to construct a Colorant of type C from an P::AbstractArray{<:Number}.
NeuroCore.ColorChannels.has_channeldim — Methodhas_channeldim(x) -> BoolReturns true if x has a dimension corresponding to channel.
NeuroCore.ColorChannels.setchannel — Methodsetchannel(c, val, idx)Equivalent to:
cc = copy(c)
cc[idx] = val
ccfor immutable colors. idx is interpreted in the sense of constructor arguments, so setchannel(c, 0.5, 1) would set red color channel for any c::AbstractRGB, even if red isn't the first field in the type.
NeuroCore.ColorChannels.setchannels! — Functionsetchannels!(P, val, I)For a color val, distribute its channels along P[:, I...] for P::AbstractArray{<:Number}.
NeuroCore.ColorChannels.ColorChanPerm — TypeColorChanPerm(perm)
Construct a reordering permutation for the color channel. This handles swaps between memory layout and constructor argument order for AbstractRGB and various AlphaChannel and ChannelAlpha color types.