NumberMap

References
public sealed class NumberMap
Represents an immutable rectangular grid of number values. Ie. a bitmap with double precision numbers instead of colours.

Constructors

NumberMap

#
public NumberMap(double[][] map, bool copy)
Create a new map.
map (double[][])Float map. Ie. an array of equal length number columns.
copy (bool)If true, the map will be duplicated in memory. If there is a chance of this data being unexpectedly modified by some code, you must set copy=true. If there's any doubt in your mind whatsoever, use copy=true.

NumberMap

#
public NumberMap(int width, int height, double constant)
Create a new constant map.
width (int)Width of map.
height (int)Height of map.
constant (double)Constant value.

Properties

Constant

#
public double Constant { get; }
Gets the constant value of this map. If IsConstant is not true, this value is meaningless.

Count

#
public long Count { get; }
Gets the total number of entries in this map.

Height

#
public int Height { get; }
Gets the height of the map. If the Height equals zero, it implied this map only contains a single value.

InfinityCount

#
public long InfinityCount { get; }
Gets the number of infinite values in this map.

IsConstant

#
public bool IsConstant { get; }
Gets whether this map contains only a single value.

Maximum

#
public double Maximum { get; }
Gets the highest value in this map. NaNs are ignored in this test.

Minimum

#
public double Minimum { get; }
Gets the lowest value in this map. NaNs are ignored in this test.

NanCount

#
public long NanCount { get; }
Gets the number of nan values in this map.

NegativeInfinityCount

#
public long NegativeInfinityCount { get; }
Gets the number of negative infinite values in this map.

PositiveInfinityCount

#
public long PositiveInfinityCount { get; }
Gets the number of positive infinite values in this map.

Width

#
public int Width { get; }
Gets the width of the map. If the Width equals zero, it implied this map only contains a single value.

Indexers

this[]

#
public double this[int x, int y] { get; }
Gets the number at the given (x,y) coordinate. If the map is constant this indexer will throw.
x (int)X index.
y (int)Y index.
Value at (x,y).

Methods

Abs

#
public NumberMap Abs()
Convert all values in this map to their absolute.
Absolute map.

AddNoise

#
public NumberMap AddNoise(Random engine, double minimum, double maximum)
Use a random engine to add noise to this map.
engine (Random)Random engine.
minimum (double)Least amount of noise to add.
maximum (double)Most amount of noise to add.
Map with noise.

AddPerlinNoise

#
public NumberMap AddPerlinNoise(double dx, double dy, double minimum, double maximum, double waveLength)
Add perlin noise to this map.
dx (double)X offset.
dy (double)Y offset.
minimum (double)Least amount of noise to add.
maximum (double)Most amount of noise to add.
waveLength (double)Wavelength of average perlin wave.
Map with perlin noise.

AddPerlinNoise

#
public NumberMap AddPerlinNoise(double dx, double dy, NumberMap minimum, NumberMap maximum, double waveLength)
Add perlin noise to this map.
dx (double)X offset.
dy (double)Y offset.
minimum (NumberMap)Least amount of noise to add.
maximum (NumberMap)Most amount of noise to add.
waveLength (double)Wavelength of average perlin wave.
Map with perlin noise.

AddPerlinNoise

#
public NumberMap AddPerlinNoise(double dx, double dy, NumberMap minimum, NumberMap maximum, NumberMap waveLength)
Add perlin noise to this map.
dx (double)X offset.
dy (double)Y offset.
minimum (NumberMap)Least amount of noise to add.
maximum (NumberMap)Most amount of noise to add.
waveLength (NumberMap)Wavelength of average perlin wave.
Map with perlin noise.

AllEqualTo

#
public bool AllEqualTo(double value)
Test whether all values are equal to a given value.
value (double)Equality value.
True if all values are equal to value.

AllEqualTo

#
public bool AllEqualTo(out double value)
Test whether all values are equal.
value (out double)If this method returns true, the constant value will be returned here.
True if all values are equal to value.

Blend

#
public NumberMap Blend(NumberMap layer, BlendMode blend, double strength)
Overlay two maps.
layer (NumberMap)Top layer.
blend (BlendMode)Blend type.
strength (double)Strength of blending.
Combined result.

Blend

#
public NumberMap Blend(NumberMap layer, BlendMode blend, NumberMap strength)
Overlay two maps.
layer (NumberMap)Top layer.
blend (BlendMode)Blend type.
strength (NumberMap)Strength of blending.
Combined result.

Blur

#
public NumberMap Blur(SamplerTiling horizontal, SamplerTiling vertical, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
profile (BlurProfileType)Blur profile.
radius (double)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

Blur

#
public NumberMap Blur(SamplerTiling horizontal, SamplerTiling vertical, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
profile (BlurProfileType)Blur profile.
radius (NumberMap)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

BlurHorizontal

#
public NumberMap BlurHorizontal(SamplerTiling horizontal, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map horizontally.
horizontal (SamplerTiling)Horizontal tiling.
profile (BlurProfileType)Blur profile.
radius (double)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

BlurHorizontal

#
public NumberMap BlurHorizontal(SamplerTiling horizontal, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map horizontally.
horizontal (SamplerTiling)Horizontal tiling.
profile (BlurProfileType)Blur profile.
radius (NumberMap)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

BlurVertical

#
public NumberMap BlurVertical(SamplerTiling vertical, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map vertically.
vertical (SamplerTiling)Vertical tiling.
profile (BlurProfileType)Blur profile.
radius (double)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

BlurVertical

#
public NumberMap BlurVertical(SamplerTiling vertical, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map vertically.
vertical (SamplerTiling)Vertical tiling.
profile (BlurProfileType)Blur profile.
radius (NumberMap)Blur radius.
token (CancellationToken = null)Cancellation token.
Blurred map.

Clip

#
public NumberMap Clip(double min, double max)
Clip all values in this map to a numeric domain.
min (double)Lower limit.
max (double)Upper limit.
Clipped map.

Clip

#
public NumberMap Clip(NumberMap min, NumberMap max)
Clip all values in this map to a numeric domain.
min (NumberMap)Lower limit.
max (NumberMap)Upper limit.
Clipped map.

Convolve

#
public NumberMap Convolve(SamplerTiling horizontal, SamplerTiling vertical, ConvolutionKernel kernel, CancellationToken token = default(CancellationToken))
Apply a convolution kernel to this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
kernel (ConvolutionKernel)Convolution kernel.
token (CancellationToken = null)Cancellation token.
Convolved map.

CreateFromDelegate

#
public static NumberMap CreateFromDelegate(int width, int height, NumberMapShader shader)
Populate a number map using a shader delegate.
width (int)Width of map to create.
height (int)Height of map to create.
shader (NumberMapShader)Shader delegate.
Instantiated number map.

CreateFromShapes

#
public static NumberMap CreateFromShapes(int width, int height, double backgroundElevation, IEnumerable<IShaderGeometry> shapes)
Populate a number map using the elevation data of various shapes.
width (int)Width of numbermap.
height (int)Height of numbermap.
backgroundElevation (double)Value of background elevation.
shapes (IEnumerable<IShaderGeometry>)Collection of shapes in numbermap space.
Float depth map.

CreateMoveX

#
public static NumberMap CreateMoveX(int width, int height, double dx)
Create a transformation map for motion along the x-axis.
width (int)Width of map.
height (int)Height of map.
dx (double)Amount of motion.
Motion map.

CreateMoveY

#
public static NumberMap CreateMoveY(int width, int height, double dy)
Create a transformation map for motion along the y-axis.
width (int)Width of map.
height (int)Height of map.
dy (double)Amount of motion.
Motion map.

CreateRotateX

#
public static NumberMap CreateRotateX(int width, int height, double originX, double originY, double angle)
Create a transformation map for rotating around an origin.
width (int)Width of map.
height (int)Height of map.
originX (double)X origin of rotation.
originY (double)Y origin of rotation.
angle (double)Rotational angle (counter-clockwise, in radians).
Rotation map for the x-axis.

CreateRotateY

#
public static NumberMap CreateRotateY(int width, int height, double originX, double originY, double angle)
Create a transformation map for rotating around an origin.
width (int)Width of map.
height (int)Height of map.
originX (double)X origin of rotation.
originY (double)Y origin of rotation.
angle (double)Rotational angle (counter-clockwise, in radians).
Rotation map for the x-axis.

CreateSampler

#
public IMapSampler CreateSampler(SamplerTiling horizontal, SamplerTiling vertical)
Create a sampler object for this map.
horizontal (SamplerTiling)
vertical (SamplerTiling)
Sampler.

CreateScaleX

#
public static NumberMap CreateScaleX(int width, int height, double origin, double factor)
Create a transformation map for scaling along the x-axis.
width (int)Width of map.
height (int)Height of map.
origin (double)Scaling origin.
factor (double)Scaling factor.
Scaling map.

CreateScaleY

#
public static NumberMap CreateScaleY(int width, int height, double origin, double factor)
Create a transformation map for scaling along the y-axis.
width (int)Width of map.
height (int)Height of map.
origin (double)Scaling origin.
factor (double)Scaling factor.
Scaling map.

DownSample

#
public NumberMap DownSample(int blockSize, CancellationToken token = default(CancellationToken))
Downsample this map.
blockSize (int)Number of rows and columns per downsampled block.
token (CancellationToken = null)Cancellation token.
Downsampled map.

DownSample

#
public NumberMap DownSample(int blockWidth, int blockHeight, CancellationToken token = default(CancellationToken))
Downsample this map.
blockWidth (int)Number of columns per downsampled block.
blockHeight (int)Number of rows per downsampled block.
token (CancellationToken = null)Cancellation token.

Flip

#
public NumberMap Flip()
Flip this map along the diagonal.
Flipped map.

Fragment

#
public NumberMap Fragment(IEnumerable<PointF> seeds)
Fragment the map.
seeds (IEnumerable<PointF>)Fragment seeds.
Fragmented map.

Fragment

#
public NumberMap Fragment(SpatialTree<PointF> seeds)
Fragment the map.
seeds (SpatialTree<PointF>)Fragment seeds.
Fragmented map.

Log

#
public NumberMap Log()
Compute the base-e logarithm of this map.
Logarithmic map.

Log

#
public NumberMap Log(double base)
Compute the base-x logarithm of this map.
base (double)Logarithm base.
Logarithmic map.

Log10

#
public NumberMap Log10()
Compute the base-10 logarithm of this map.
Logarithmic map.

Max

#
public NumberMap Max(double value)
Maximize all values in this map with respect to a limit.
value (double)Value to maximize against.
Maximum map.

Max

#
public NumberMap Max(NumberMap other)
Maximize all values in this map with respect to a limit map.
other (NumberMap)Map to maximize against.
Maximum map.

Median

#
public NumberMap Median(SamplerTiling horizontal, SamplerTiling vertical, ShapeMaskGeometry geometry, int radius, CancellationToken token = default(CancellationToken))
Apply a rectangular median filter to this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
geometry (ShapeMaskGeometry)Type of mask to use, only Square and Circle are supported by the current implementation.
radius (int)Constant radius of median filter geometry.
token (CancellationToken = null)Cancellation token.
Map with median values.

Median

#
public NumberMap Median(SamplerTiling horizontal, SamplerTiling vertical, ShapeMaskGeometry geometry, NumberMap radius, CancellationToken token = default(CancellationToken))
Apply a rectangular median filter to this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
geometry (ShapeMaskGeometry)Type of mask to use, only Square and Circle are supported by the current implementation.
radius (NumberMap)Variable radius map. The values in the map are rounded to integers.
token (CancellationToken = null)Cancellation token.
Map with median values.

Min

#
public NumberMap Min(double value)
Minimize all values in this map with respect to a limit.
value (double)Value to minimize against.
Minimum map.

Min

#
public NumberMap Min(NumberMap other)
Minimize all values in this map with respect to a limit map.
other (NumberMap)Map to minimize against.
Minimum map.

MirrorHorizontal

#
public NumberMap MirrorHorizontal()
Mirror this map horizontally.
Mirrored map.

MirrorVertical

#
public NumberMap MirrorVertical()
Mirror this map vertically.
Mirrored map.

Modify

#
public NumberMap Modify(Func<double, double, double> modifier, NumberMap controlMap)
Apply a custom modifier to a map.
modifier (Func<double, double, double>)Custom modifier delegate. First argument is the map value, second argument is the control value.
controlMap (NumberMap)Control map.
Modified map.

Modify

#
public NumberMap Modify(Func<double, double> modifier)
Apply a custom modifier to a map.
modifier (Func<double, double>)Custom modifier delegate.
Modified map.

Normalise

#
public NumberMap Normalise()
Normalise this map to the (0~1) domain. If the map contains infinite values, all negative infinities will become 0.0, all positive infinities will become 1.0 and every finite value will become 0.5.
Normalised map.

Normalise

#
public NumberMap Normalise(double min, double max)
Normalise this map to a custom domain. If the map contains infinite values, all negative infinities will become 'min', all positive infinities will become 'max' and every finite value will become the average of 'min' and 'max'.
min (double)Custom domain start.
max (double)Custom domain end.
Normalised map.

Pixelate

#
public NumberMap Pixelate(int size)
Pixelate this map.
size (int)Size of pixels.
Pixelated map.

Pixelate

#
public NumberMap Pixelate(int width, int height)
Pixelate this map.
width (int)Width of pixels.
height (int)Height of pixels.
Pixelated map.

Posterise

#
public NumberMap Posterise(IEnumerable<double> table)
Pull all values in this map to a collection of key values.
table (IEnumerable<double>)Key values to tabulate against.
Tabulated map.

Posterise

#
public NumberMap Posterise(params double[] table)
Pull all values in this map to a collection of key values.
table (params double[])Key values to tabulate against.
Tabulated map.

Pow

#
public NumberMap Pow(double exponent)
Raise this map to a power.
exponent (double)Exponent.
Exponentiated map.

Pow

#
public NumberMap Pow(NumberMap exponent)
Raise this map to a power.
exponent (NumberMap)Exponent.
Exponentiated map.

Resize

#
public NumberMap Resize(int width, int height, ResizingInterpolation scheme, CancellationToken token = default(CancellationToken))
Perform a resizing operation on this map.
width (int)New width.
height (int)New height.
scheme (ResizingInterpolation)Interpolation scheme.
token (CancellationToken = null)Cancellation token.

Round

#
public NumberMap Round(int decimals)
Round all the values in this map.
decimals (int)Number of decimals. Must be in the (0~16) range.
Rounded map.

ShiftHorizontal

#
public NumberMap ShiftHorizontal(int amount)
Shift all columns in this map.
amount (int)Amount to shift rightwards. Negative amounts offset leftwards.
Shifted map.

ShiftVertical

#
public NumberMap ShiftVertical(int amount)
Shift all rows in this map.
amount (int)Amount to shift downwards. Negative amounts offset upwards.
Shifted map.

Sobel

#
public NumberMap Sobel(SamplerTiling horizontal, SamplerTiling vertical, SobelOperator operator, CancellationToken token = default(CancellationToken))
Apply a sobel operator to this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
operator (SobelOperator)Operator to apply.
token (CancellationToken = null)Cancellation token.
Modified number map.

Split

#
public NumberMap Split(double threshold, double lessThan, double equalTo, double largerThan)
Split this map into portions larger than and smaller than some threshold.
threshold (double)Threshold value.
lessThan (double)Value to assign to samples smaller than threshold.
equalTo (double)Value to assign to samples equal to threshold.
largerThan (double)Value to assign to samples larger than threshold.
Split map.

SubMap

#
public NumberMap SubMap(int x0, int x1, int y0, int y1)
Copy a portion of this map into a new map.
x0 (int)Inclusive index of first column to include in duplicate.
x1 (int)Exclusive index of last column to include in duplicate.
y0 (int)Inclusive index of first row to include in duplicate.
y1 (int)Exclusive index of last row to include in duplicate.
Float map portion.

ToBitmap

#
public Bitmap ToBitmap(Gradient gradient, PixelFormat format)
Create a bitmap out of this number map.
gradient (Gradient)Gradient to use for mapping numbers to colours.
format (PixelFormat)Pixel format to use.
Bitmap.

ToBitmap

#
public Bitmap ToBitmap(Gradient gradient)
Create a bitmap out of this number map.
gradient (Gradient)
Bitmap.

ToColourMap

#
public ColourMap ToColourMap(Gradient gradient)
Create a colour map out of this number map.
gradient (Gradient)Gradient for number->colour conversion.
Colour map.

ToNormalMap

#
public void ToNormalMap(SamplerTiling horizontal, SamplerTiling vertical, double factor, out NumberMap red, out NumberMap green, out NumberMap blue, CancellationToken token = default(CancellationToken))
Create an RGB normal map from this numbermap.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
factor (double)Vertical scaling factor.
red (out NumberMap)Red component of normal map will be outputted here.
green (out NumberMap)Green component of normal map be outputted here.
blue (out NumberMap)Blue component of normal map will be outputted here.
token (CancellationToken = null)Cancellation token.

Transform

#
public NumberMap Transform(SamplerTiling horizontal, SamplerTiling vertical, SamplerInterpolation interpolation, Transform matrix)
Transform this map.
horizontal (SamplerTiling)Horizontal tiling.
vertical (SamplerTiling)Vertical tiling.
interpolation (SamplerInterpolation)Interpolation.
matrix (Transform)Transformation matrix. The kernel encodes how samples (treated as integer [x,y] points) are moved. This matrix needs to be inversible.
Transformed map.

Operators

OperationResultDescription
double+NumberMapNumberMapAdd a value to this number map.
NumberMap+NumberMapNumberMapAdd two maps together.
NumberMap+ConvolutionKernelNumberMapApply a convolution kernel to a number map using Clip tiling. Use the Convolve() method if you want control over the tiling.
NumberMap+doubleNumberMapAdd a value to this number map.
double/NumberMapNumberMapDivide a value by the entire map.
NumberMap/NumberMapNumberMapDivide one map by another.
NumberMap/doubleNumberMapDivide this map by a value.
double*NumberMapNumberMapMultiply this map by a factor.
NumberMap*NumberMapNumberMapMultiply two maps together.
NumberMap*doubleNumberMapMultiply this map by a factor.
double-NumberMapNumberMapSubtract the entire map from a value.
NumberMap-NumberMapNumberMapSubtract one map from another.
NumberMap-doubleNumberMapSubtract a value from this number map.
-NumberMapNumberMapInversion operator.
+NumberMapNumberMapIdentity operator.