Color Channels

References

NeuroCore.ColorChannels.channel_axisMethod
channel_axis(x, size[; first_pad=nothing, last_pad=nothing, stride=nothing, dilation=nothing])

Returns an AxisIterator along the channel axis.

NeuroCore.ColorChannels.channel_viewMethod
channel_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

source
NeuroCore.ColorChannels.clamp01Method
clamp01(x) -> y

Produce 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.

source
NeuroCore.ColorChannels.color_signedMethod
color_signed()
color_signed(colorneg, colorpos) -> f
color_signed(colorneg, colorcenter, colorpos) -> f

Define 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: white
  • colorneg: green1
  • colorpos: magenta

See also: scale_signed.

source
NeuroCore.ColorChannels.color_viewMethod
color_view(C, gray1, gray2, ...) -> imgC

Combine 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.

source
NeuroCore.ColorChannels.color_viewMethod
color_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

source
NeuroCore.ColorChannels.normed_viewMethod
normed_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

source
NeuroCore.ColorChannels.raw_viewMethod
raw_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

source
NeuroCore.ColorChannels.scale_minmaxMethod
scale_minmax(min, max) -> f
scale_minmax(T, min, max) -> f

Return 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.75

Example 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.

source
NeuroCore.ColorChannels.scale_signedMethod
scale_signed(min, center, max) -> f

Return 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.

source
NeuroCore.ColorChannels.take_mapFunction
take_map(f, A) -> fnew
take_map(f, T, A) -> fnew

Given 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.0
source
NeuroCore.ColorChannels.StackedViewType
StackedView(B, C, ...) -> A

Present 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.

source
Base.floatMethod
float(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.

source
NeuroCore.ColorChannels.each_channelMethod
each_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.setchannelMethod
setchannel(c, val, idx)

Equivalent to:

cc = copy(c)
cc[idx] = val
cc

for 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.

source
NeuroCore.ColorChannels.ColorChanPermType

ColorChanPerm(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.

source