﻿ Transform Templates - Tile

# Transform Templates - Tile

This topic discusses application of the Transform panel with Tables or Images on a tile field in a table. See the Transform panel and Transform Templates topics for use and for links to lists of templates for other data types for tables and use of the Transform Dialog with other components, such as Drawings.

Many tile functions are the tile equivalents of mathematical functions operating on numeric fields.  In the case of tiles, the computation is performed upon the tile pixel value within a tile and put into the corresponding tile pixel in the target.   Tile functions are all GPGPU enabled.

Absolute Value

Take the absolute value of the tile pixel value in the source field and put it into the target field.  Absolute value leaves positive numbers unchanged and converts negative numbers into their positive equivalents.

Add two values and put the result into the target field.   Appears for single channel images as well.  Useful for increasing the level of terrain elevation data.

The effect is the equivalent of lifting the terrain 100 units (in this case, feet).  From the above we see that palette and hill-shading effects are applied even during a preview.

Arc Cosine

Take the arc cosine (inverse cosine) of the source field and put it into the target field.

Arc Sine

Take the arc sine (inverse sine) of the source field and put it into the target field.

Arc Tangent

Take the arc tangent (inverse tangent) of the source field and put it into the target field.

Arc Tangent of Ratio

Take the arc tangent (inverse tangent) of the ratio between the DY field and the DX field and put into the target field.

Aspect

Appears for single channel images. Treating the pixel values as heights to imply a surface, compute the direction in which the slope of the terrain faces and save as a pixel value that direction in degrees, with 0 to 180 representing the Eastern semicircle and -1 to -179 the Western semicircle.  A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.   The direction is computed by comparing heights of a square array of pixels within a given radius.

The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array.  Aspect works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Caution: Slight increases in Radius can cause disproportionately enormous increases in the computation time required.  Without a GPU a Radius of 3 is already very slow.   With a GPU, even incredibly large computations involving a Radius of 9 or even 10 are possible on a desktop machine, as Manifold will automatically GPGPU parallelize the aspect calculation.   Start with a Radius of 1 and then scale up slowly to see where patience ends.   As a practical matter, there is not much gain in accuracy of aspect computation when increasing Radius beyond 4 or 5.

Preview: Apply Aspect to Tile using a Radius of 3.

The values resulting from Aspect are no longer heights but are degrees of compass orientation, so all are colored within the blue range of the palette in use. It makes little sense to apply hill shading to a raster display of aspect values.   We would remove hill shading and choose a different palette after applying Aspect.

Base 10 Logarithm

Put the base 10 logarithm (also called the common logarithm) of the source field into the target field.

Base 2 Logarithm

Put the base 2 logarithm (also called the binary logarithm) of the source field into the target field.

Bessel J0

A Bessel function of the first kind: Put the result of the Bessel function J0(x) using the source field as x into the target.

Bessel J1

A Bessel function of the first kind: Put the result of the Bessel function J1(x) using the source field as x into the target.

Bessel Jn

The nth Bessel function of the first kind: Put the result of the Bessel function Jn(x) for Order n using the source field as x into the target.  Specifying 2 for Order uses a J2(x) Bessel function.  Using 0 or 1 for the Order is equivalent to using J0(x) or J1(x), respectively.

Bessel Y0

A Bessel function of the second kind: Put the result of the Bessel Function Y0(x) using the source field as x into the target.

Bessel Y1

A Bessel function of the second kind: Put the result of the Bessel Function Y1(x) using the source field as x into the target.

Bessel Yn

The nth Bessel function of the second kind: Put the result of the Bessel Function Yn(x) for Order n using the source field as x into the target.  Specifying 2 for Order uses a Y2(x) Bessel function.  Using 0 or 1 for the Order is equivalent to using Y0(x) or Y1(x), respectively.

Blur

Appears for single channel images.  Take the source field, Interpolate pixel values based on radius and power, averaging pixel values over a square array of pixels, and place the result in the target field.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in averaging compared to other pixels in the array.  Blur works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Blur to Tile using a Radius of 10 and a Power of 1.

Ceiling

Put the rounded up integer value of the source field into the target field.

Ceiling up to Decimals

Put the value of the source field rounded up to the specified number of Decimal positions into the target field.

Copy

Copy the source field into the target field.

Complementary Error Function

Take the complementary error function (also called erfc(z) ) of the source field and put it into the target field.

Contour Areas

Using values in a raster image as heights of terrain, create a drawing with vector areas representing contours for the terrain heights from the specified minimum height to maximum height, using intervals of the given Step.   Each area record will have ValueMin and ValueMax attribute fields giving the minimum and maximum height for that contour area.

The Decompose to shapes option, when checked (default), will automatically decompose all areas for the same range of contour interval values into separate area objects.   Unchecking this option will result in the creation of a single, multibranched area object for each contour interval value range.  This makes for a simpler results table and the ease of selecting all like areas with a single Ctrl-click, but when starting with larger raster data it can result in very large areas, consisting of millions of coordinates to cover all of the branches.

Zoom in for previews: The system shows a preview for data in the current viewport if reasonable. If a preview does not appear, zoom further into the display to reduce the quantity of data in the viewport.

See the Example: Contour Areas and Contour Lines topic for a step-by-step example.

See also the Example: Trace Vector Areas from Raster Pixels  topic, for the related template that traces areas by pixel values.

See the Manifold 9 - Five Minutes for Contours video and the Manifold 9 - Contour a 300MB DEM in Five Seconds video.

Contour Lines

Using values in a raster image as heights of terrain, create a drawing with vector lines representing contours for the terrain heights from the specified minimum height to maximum height, using intervals of the given Step.    Each line record will have a Value attribute fields giving the height for that contour line.

The Decompose to shapes option, when checked (default), will automatically decompose all lines for the same contour value into separate line objects.   Unchecking this option will result in the creation of a single, multibranched line object for each contour value.  This makes for a simpler results table and the ease of selecting all like lines with a single Ctrl-click, but when starting with larger raster data it can result in very large lines, consisting of millions of coordinates to cover all of the branches.

Leaving the default Decompose to shapes option checked also has the advantage that if any of the created lines exceeds 64 million coordinates (! ... a big line...), Manifold will automatically split it into more than one line so that each stays less than 64 million coordinates in size.

Zoom in for previews: The system shows a preview for data in the current viewport if reasonable. If a preview does not appear, zoom further into the display to reduce the quantity of data in the viewport.

See the Example: Contour Areas and Contour Lines topic for a step-by-step example.

See also the Example: Trace Vector Areas from Raster Pixels  topic, for the related template that traces areas by pixel values.

See the Manifold 9 - Five Minutes for Contours video and the Manifold 9 - Contour a 300MB DEM in Five Seconds video.

Cosine

Take the cosine of the source field and put it into the target field.

Cube Root

Take the cube root of the source field and put it into the target field.

Direction Blur

Appears for single channel images.   Take the source field, Interpolate pixel values based on radius and power, averaging pixel values over a square array of pixels emphasizing the direction specified by the given angle, and place the result in the target field.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in averaging compared to other pixels in the array.  Direction Blur works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Direction Blur to Tile using a Radius of 5, a Power of 1, and an Angle of 0.27 radians, which is approximately 15.5 degrees.

The system blurs more in the direction of the specified Angle.

Direction Edges

Appears for single channel images.  Take the source field, emphasize edges by examining pixel values over a square array of pixels looking for changes along a direction at the specified angle, and place the result in the target field.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in comparisons compared to other pixels in the array.  Direction Edges works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Direction Edges to Tile using a Radius of 1, a Power of 3, and an Angle of 0.27 radians, which is approximately 15.5 degrees.

The system emphasizes the edges where changes are found between pixel values when traversing the data in an approximately 15.5 degree angle.

Divide

Divide the source field by the divide field and put the result into the target field.  Appears for single channel images as well.  Useful for decreasing vertical scale in terrain elevation data.

Preview: Apply Divide to Tile using a Divide by factor of 2.

The terrain heights become lower and less steep. From the above we see that palette and hill-shading effects are applied even during a preview.

Divide and Truncate

Divide the source field by the divide field and put the integer part of the result into the target field.

Edges

Appears for single channel images.  Find edges (transitions between pixel values) in any direction.  Take the source field, emphasize edges by examining pixel values over a square array of pixels, and place the result in the target field.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in comparisons compared to other pixels in the array.  Edges works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Edges to Tile using a Radius of 1 and a Power of 2.

Error Function

Take the error function (also called erf(z) ) of the source field and put it into the target field.

Exponent

The exponential function: Take e to the power of the source field and place result into the target field. For anything but small numbers in the source field such exponentiation very rapidly results in numbers larger than can be represented in most types and thus stores a NULL in the target.

Floor

Put the rounded down integer value of the source field into the target field.

Floor down to Decimals

Put the value of the source field rounded up to the specified number of Decimal positions into the target field.

Fractional Part

Take only the decimal fraction portion of the source and put into the target field.

Fractional Part from Decimals

Take only the decimal fraction portion of the source beyond the specified number of Decimal positions and put into the target field.

Gamma Function

Put the gamma function for the source field into the target field.

Gaussian Blur

Appears for single channel images.  Take the source field, Interpolate pixel values based on radius and power, averaging pixel values over a circular radius with a convolution function computed using a Gaussian function , and place the result in the target field.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in averaging compared to other pixels in the array. Radius has a greater visual effect than Power.  Gaussian Blur corrects for circular radius while Blur computes blur on a square matrix.    Gaussian Blur works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Gaussian Blur to Tile using a Radius of 10 and a Power of 1.

A familiar effect in Photoshop editing, Gaussian Blur is also useful to reduce details in raster data such as terrain elevation data sets.   For example, a highly detailed, military-grade, terrain elevation data set might be reduced in resolution using Gaussian Blur to enable release as a declassified data set for civilian use.

###### Comparing Gaussian Blur to Blur

Blur is the classic box blur of many image editing programs, with the added ability to weight the central pixel.  Blur more closely approximates the "bokeh" effect of lense blur in out-of-focus regions of photographic images where some parts of the image are in-focus while others are out-of-focus.   A Blur example is on the left below.

Gaussian Blur, on the right above, combines a Gaussian function (often thought of as a bell curve) with pixel values to compute weighted pixel averaging.  Gaussian Blur tends to better preserve boundaries and edges and operates as a low-pass filter as well.  Applying a slight Gaussian Blur to an image before downsizing it will often produce a better appearance for the reduced-size image by eliminating Moire effects and other high-frequency feature artefacts.

Hyperbolic Arc Cosine

Put the hyperbolic arc cosine of the source field into the target field.

Hyperbolic Arc Sine

Put the hyperbolic arc sine of the source field into the target field.

Hyperbolic Arc Tangent

Put the hyperbolic arc tangent of the source field into the target field.

Hyperbolic Cosine

Put the hyperbolic cosine of the source field into the target field.

Hyperbolic Sine

Put the hyperbolic sine of the source field into the target field.

Hyperbolic Tangent

Put the hyperbolic tangent of the source field into the target field.

Hypotenuse

The great and ancient Pythagorean theorem: The square root of the sum of the squares of the two sides of a right triangle.  Save into the target the value of the hypotenuse taking two given source fields as DX and DY.

Log-gamma Function

The log-gamma function takes the natural logarithm of the gamma function for the source field and stores the result into the target field.

Logarithm

Put the base e logarithm (also called the natural logarithm) of the source field into the target field.

Maximum Value

Take the maximum, that is the greater value, of either the source field or the comparison field and save into the target field.

Modulo

The remainder (of a congruence) function: Take what is left over by the integral division of the source field by the given Divide by value and place into the target field.

Multiply

Multiply the two source fields and place the result into the target field.  Appears for single channel images as well.  Useful for increasing vertical scale in terrain elevation data.

Preview: Apply Multiply to Tile using a Multiply by factor of 2.

The terrain heights become higher and more steep. From the above we see that palette and hill-shading effects are applied even during a preview.

Negate

Appears for single channel images. Multiply the source field by -1 and place the result into the target field.

Preview: Apply Negate to Tile.

Creates a photographic negative.

With terrain elevation data, Negate turns hills into depressions.

Noise

Appears for single channel images. Place random noise values into pixels over the given range.

Preview: Apply Noise to Tile using a Range of 60.

Parse Base64 String

Takes a base64-encoded string that encodes a tile value, convert it back into the original value and store into the tile.

Parse Hex String

Takes a hex-encoded string that encodes a tile value, convert it back into the original value and store into the tile.

Power

Compute the source field to the power of the specified Power value and put the result into the target field. A Power of 2 is the source field squared while a Power of 3 is the source field cubed.

Power of 10

Compute 10 to the power of the source field and put the result into the target field.  If the source field has values 1, 2, 3,... the result of Power of 10 will be 10, 100, 1000,....   For anything but small numbers in the source field such exponentiation very rapidly results in numbers larger than can be represented in most types and thus stores a NULL in the target.

Power of 2

Compute 2 to the power of the source field and put the result into the target field.  If the source field has values 1, 2, 3,... the result of Power of 2 will be 2, 4, 8,....   For anything but small numbers in the source field such exponentiation very rapidly results in numbers larger than can be represented in most types and thus stores a NULL in the target.

Reciprocal Cube Root

Also known as the inverse cube root: Take 1 divided by the cube root of the source field and put the result into the target field.

Reciprocal Square Root

Also known as the inverse square root: Take 1 divided by the square root of the source field and put the result into the target field.

Round

Round a source field with a fractional part up or down to the nearest integer and put the result into the target field.

Round to Decimals

Round a source field with a fractional part up or down to the number of decimals specified by  Decimals and put the result into the target field.

Sharpen

Appears for single channel images.  Enhance contrast and edge detection by comparing pixel values within a square array of pixels. The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array. The Power value is the weight to give the center pixel: a weight of 1 means not to emphasize it.  A weight of 5 means to give the center pixel's value five times the value in averaging compared to other pixels in the array.  Sharpen works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Preview: Apply Sharpen to Tile using a Radius of 5 and a Power of 1.

With terrain elevation data, Sharpen may appear to add detail but it does not.  It simply emphasizes contrasts between pixels that are already in the data.   Increasing Z for hill shading might give a better effect.

Sign

For a source field that is positive or negative put a 1 or -1 respectively into the target field.

Sine

Take the sine of the source field and put it into the target field.

Slope

Appears for single channel images. Treating the pixel values as heights to imply a surface, compute the inclination in degrees of the surface at the pixel's position and save as a pixel value from 0 to 90 . Compute the degree to which terrain slopes by comparing heights of a square array of pixels within a given radius. A larger Radius takes longer to calculate but averages out the changes in slope to a greater extent.  The Radius value sets the number of pixels from the center pixel to the edge:  A Radius of 1 results in a 3x3 pixel array.  Slope works on a single channel: tiles should be a single channel, such as uint8, and not multichannel, such as uint8x3.

Caution: As with the Aspect template, slight increases in Radius can cause disproportionately enormous increases in the computation time required.  Without a GPU a Radius of 5 is already very slow.   With a GPU, even incredibly large computations involving a Radius of 9 or even 10 are possible on a desktop machine, as Manifold will automatically GPGPU parallelize the aspect calculation.   Start with a Radius of 1 and then scale up slowly to see where patience ends.   As a practical matter, there is not much gain in accuracy of slope computation when increasing Radius beyond 5.

Preview: Apply Slope to Tile using a Radius of 5.

The values resulting from Slope are no longer heights but are degrees of inclination, so all are colored within the blue range of the palette in use.  It makes little sense to apply hill shading to a raster display of aspect values.   We would remove hill shading and choose a different palette after applying Slope.

Square Root

Take the square root of the source field and put it into the target field.

Subtract

Subtract one source field from the other and put the result into the target field.  Appears for single channel images as well.  Useful for decreasing the level of terrain elevation data.

Preview: Apply Subtract to Tile using a Subtract value of 100.

The effect is the equivalent of lowering the terrain 100 units (in this case, feet).  From the above we see that palette and hill-shading effects are applied even during a preview.

Tangent

Take the tangent of the source field and put it into the target field.

Trace Areas

Using values in a raster image, create a drawing with vector areas covering regions of similarly-colored, that is, similarly-valued, pixels. Each area will also have a Value attribute field giving the pixel value for which it was created.  The template can create areas whether values for pixels are intended as colors or as elevation or other values.

The Similarity factor gives the range within which pixel values will be considered to be in the same classification.  A Similarity of 10 would group values of 11, 14, and 18 together in one group and values of 20, 23 and 27 in a different group.  The default value of 1 for Similarity means to treat pixels within the same integer values as unique.   A value of 0 for Similarity would treat each unique pixel value found as a separate classification (using 0 is often a mistake given there might not be an intended difference between close pixel values such as 1.00003 and 1.000031).

The Decompose to shapes option, when checked (default), will automatically decompose all areas for the same class of color into separate area objects.   Unchecking this option will result in the creation of a single, multibranched area object for each class.  This makes for a simpler results table and the ease of selecting all like areas with a single Ctrl-click, but when starting with larger raster data it can result in very large areas, consisting of millions of coordinates to cover all of the branches.

We start with a raster image where a single number for each pixel, that is, a single channel, is intended to be an index number for a palette image.   Each number indicates a land use code for that pixel.   The image above is colored with a palette to represent visually the content of the image.   For example, it uses green colors for pixels where the classification code is intended to mean forest.  The image is created from a tile field in the table called Tile1.  Approximately 30 different colors are used, to represent 30 different land uses in the region.

Preview: Apply Trace Areas to Tile1 using a Similarity of 0.

The preview shows the area objects that will be created in the new drawing.  Press Add Component to create the new drawing.

Dragging and dropping the new drawing into the map, we can color it using Style to show the areas it contains.

### Trace Areas and Heights

The Trace Areas template can be used with data sets that show terrain elevations to create results similar to using the Contour Areas template.

Consider the elevation data set used in examples, as seen above.

Choosing Trace Areas with a Similarity of 1 will attempt to create an area for each region of pixels that has a different integer bounded value.

That creates so many areas so densely packed that the preview is a mass of blue preview color.

Using a Similarity of 10 tells the template to create an area that covers each swath of pixels within a range of 10, that is, heights from 0 to 10, 10 to 20, and so on.

From the preview we can see that results in a more useful set of areas.   We press Add Component to create the new drawing.

Formatting the drawing we can see the effect is similar to creating contour areas.

See the Example: Trace Vector Areas from Raster Pixels  topic as well as the Trace Vector Areas from Raster Pixels  video.

Truncate

Take the integer part of the source field, discarding any decimal fraction part, and put the result into the target field.

Truncate to Decimals

Take the integer part of the source field as well as any decimal fraction up to the specified number of Decimal places, discarding any decimal fraction part beyond, and put the result into the target field.

## Notes

Everything Math - For a handy reference to anything in mathematics, see the Wolfram MathWorld site.   Thank you Wolfram!

Contents Pane

Transform

Contents - Transform

Transform Options

Transform Templates - Drawings

Transform Templates - Images

Transform Templates - Binary

Transform Templates - Boolean

Transform Templates - Datetime

Transform Templates - Geom

Transform Templates - Numeric

Transform Templates - Text

Transform Templates - Tile

Transform: Center and Centroids

Transform: Escape Templates

Transform: Overlay Topology

Transform: Voronoi Diagrams