NumberMap
ReferencesRepresents an immutable rectangular grid of number values. Ie. a bitmap with double precision numbers instead of colours.
Constructors
NumberMap
#Create a new map.
Parameters:
| 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. |
Properties
Height
#Gets the height of the map. If the Height equals zero, it implied this map only contains a single value.
Indexers
Methods
AddNoise
#Use a random engine to add noise to this map.
AllEqualTo
#Test whether all values are equal to a given value.
Parameters:
| value (double) | Equality value. |
Returns: True if all values are equal to value.
AllEqualTo
#Test whether all values are equal.
Parameters:
| value (out double) | If this method returns true, the constant value will be returned here. |
Returns: True if all values are equal to value.
Blend
#Overlay two maps.
Blend
#Overlay two maps.
Blur
#public NumberMap Blur(SamplerTiling horizontal, SamplerTiling vertical, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| vertical (SamplerTiling) | Vertical tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (double) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
Blur
#public NumberMap Blur(SamplerTiling horizontal, SamplerTiling vertical, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| vertical (SamplerTiling) | Vertical tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (NumberMap) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
BlurHorizontal
#public NumberMap BlurHorizontal(SamplerTiling horizontal, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map horizontally.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (double) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
BlurHorizontal
#public NumberMap BlurHorizontal(SamplerTiling horizontal, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map horizontally.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (NumberMap) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
BlurVertical
#public NumberMap BlurVertical(SamplerTiling vertical, BlurProfileType profile, double radius, CancellationToken token = default(CancellationToken))
Blur this map vertically.
Parameters:
| vertical (SamplerTiling) | Vertical tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (double) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
BlurVertical
#public NumberMap BlurVertical(SamplerTiling vertical, BlurProfileType profile, NumberMap radius, CancellationToken token = default(CancellationToken))
Blur this map vertically.
Parameters:
| vertical (SamplerTiling) | Vertical tiling. |
| profile (BlurProfileType) | Blur profile. |
| radius (NumberMap) | Blur radius. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Blurred map.
Clip
#Clip all values in this map to a numeric domain.
Clip
#Clip all values in this map to a numeric domain.
Convolve
#public NumberMap Convolve(SamplerTiling horizontal, SamplerTiling vertical, ConvolutionKernel kernel, CancellationToken token = default(CancellationToken))
Apply a convolution kernel to this map.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| vertical (SamplerTiling) | Vertical tiling. |
| kernel (ConvolutionKernel) | Convolution kernel. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Convolved map.
CreateFromDelegate
#Populate a number map using a shader delegate.
Parameters:
| width (int) | Width of map to create. |
| height (int) | Height of map to create. |
| shader (NumberMapShader) | Shader delegate. |
Returns: 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.
Parameters:
| 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. |
Returns: Float depth map.
CreateMoveX
#Create a transformation map for motion along the x-axis.
CreateMoveY
#Create a transformation map for motion along the y-axis.
CreateSampler
#Create a sampler object for this map.
Parameters:
| horizontal (SamplerTiling) | |
| vertical (SamplerTiling) |
Returns: Sampler.
CreateScaleX
#Create a transformation map for scaling along the x-axis.
CreateScaleY
#Create a transformation map for scaling along the y-axis.
DownSample
#Downsample this map.
Parameters:
| blockSize (int) | Number of rows and columns per downsampled block. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Downsampled map.
DownSample
#public NumberMap DownSample(int blockWidth, int blockHeight, CancellationToken token = default(CancellationToken))
Downsample this map.
Parameters:
| blockWidth (int) | Number of columns per downsampled block. |
| blockHeight (int) | Number of rows per downsampled block. |
| token (CancellationToken = null) | Cancellation token. |
Fragment
#Fragment the map.
Parameters:
| seeds (IEnumerable<PointF>) | Fragment seeds. |
Returns: Fragmented map.
Fragment
#Fragment the map.
Parameters:
| seeds (SpatialTree<PointF>) | Fragment seeds. |
Returns: Fragmented map.
Log
#Compute the base-x logarithm of this map.
Parameters:
| base (double) | Logarithm base. |
Returns: Logarithmic map.
Max
#Maximize all values in this map with respect to a limit.
Parameters:
| value (double) | Value to maximize against. |
Returns: Maximum map.
Max
#Maximize all values in this map with respect to a limit map.
Parameters:
| other (NumberMap) | Map to maximize against. |
Returns: 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.
Parameters:
| 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. |
Returns: 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.
Parameters:
| 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. |
Returns: Map with median values.
Min
#Minimize all values in this map with respect to a limit.
Parameters:
| value (double) | Value to minimize against. |
Returns: Minimum map.
Min
#Minimize all values in this map with respect to a limit map.
Parameters:
| other (NumberMap) | Map to minimize against. |
Returns: Minimum map.
Modify
#Apply a custom modifier to a map.
Modify
#Apply a custom modifier to a map.
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.
Returns: Normalised map.
Normalise
#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'.
Pixelate
#Pixelate this map.
Posterise
#Pull all values in this map to a collection of key values.
Parameters:
| table (IEnumerable<double>) | Key values to tabulate against. |
Returns: Tabulated map.
Posterise
#Pull all values in this map to a collection of key values.
Parameters:
| table (params double[]) | Key values to tabulate against. |
Returns: Tabulated map.
Resize
#public NumberMap Resize(int width, int height, ResizingInterpolation scheme, CancellationToken token = default(CancellationToken))
Perform a resizing operation on this map.
Parameters:
| width (int) | New width. |
| height (int) | New height. |
| scheme (ResizingInterpolation) | Interpolation scheme. |
| token (CancellationToken = null) | Cancellation token. |
Round
#Round all the values in this map.
Parameters:
| decimals (int) | Number of decimals. Must be in the (0~16) range. |
Returns: Rounded map.
ShiftHorizontal
#Shift all columns in this map.
Parameters:
| amount (int) | Amount to shift rightwards. Negative amounts offset leftwards. |
Returns: Shifted map.
ShiftVertical
#Shift all rows in this map.
Parameters:
| amount (int) | Amount to shift downwards. Negative amounts offset upwards. |
Returns: Shifted map.
Sobel
#public NumberMap Sobel(SamplerTiling horizontal, SamplerTiling vertical, SobelOperator operator, CancellationToken token = default(CancellationToken))
Apply a sobel operator to this map.
Parameters:
| horizontal (SamplerTiling) | Horizontal tiling. |
| vertical (SamplerTiling) | Vertical tiling. |
| operator (SobelOperator) | Operator to apply. |
| token (CancellationToken = null) | Cancellation token. |
Returns: Modified number map.
Split
#Split this map into portions larger than and smaller than some threshold.
SubMap
#Copy a portion of this map into a new map.
ToBitmap
#Create a bitmap out of this number map.
Parameters:
| gradient (Gradient) | Gradient to use for mapping numbers to colours. |
| format (PixelFormat) | Pixel format to use. |
Returns: Bitmap.
ToColourMap
#Create a colour map out of this number map.
Parameters:
| gradient (Gradient) | Gradient for number->colour conversion. |
Returns: 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.
Parameters:
| 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.
Parameters:
| 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. |
Returns: Transformed map.
Operators
| Operation | Result | Description | ||
|---|---|---|---|---|
| double | + | NumberMap | NumberMap | Add a value to this number map. |
| NumberMap | + | NumberMap | NumberMap | Add two maps together. |
| NumberMap | + | ConvolutionKernel | NumberMap | Apply a convolution kernel to a number map using Clip tiling. Use the Convolve() method if you want control over the tiling. |
| NumberMap | + | double | NumberMap | Add a value to this number map. |
| double | / | NumberMap | NumberMap | Divide a value by the entire map. |
| NumberMap | / | NumberMap | NumberMap | Divide one map by another. |
| NumberMap | / | double | NumberMap | Divide this map by a value. |
| double | * | NumberMap | NumberMap | Multiply this map by a factor. |
| NumberMap | * | NumberMap | NumberMap | Multiply two maps together. |
| NumberMap | * | double | NumberMap | Multiply this map by a factor. |
| double | - | NumberMap | NumberMap | Subtract the entire map from a value. |
| NumberMap | - | NumberMap | NumberMap | Subtract one map from another. |
| NumberMap | - | double | NumberMap | Subtract a value from this number map. |
| - | NumberMap | NumberMap | Inversion operator. | |
| + | NumberMap | NumberMap | Identity operator. | |