This example is a continuation of the Example: How Images use Tiles from Tables topic.
Using our example bronze image, we make a copy of the bronze Tiles table under the name bronze Tiles 2.
Right-click on the bronze image and choose Properties.
Edit the Properties of the bronze image so it uses the bronze Tiles 2 table. For later use we write down the Rect value of [0, 0, 186, 216].
Open the bronze Tiles 2 table, and then choose Edit - Schema to open the Schema dialog for the table.
Press the Add command button.
Choose Field in the drop down menu.
In the Field dialog enter the name cTile (a mnemonic for computed tile) and choose the type tile. The other settings we leave at defaults, since they match the parameters of the tile used in the bronze image, as we can tell from the table we opened.
This will be a computed field, so we press the Edit Expression button to launch the Expression dialog, to enter the expression that will be used to compute the field.
In the Expression dialog we enter the expression
TileAbs( ) is an absolute value function that when applied to RGB data as found in the Tile field has the effect of cutting out and using the first channel. We press OK.
Back in the Field dialog, we check our work and press OK.
The Schema dialog shows the new field in provisional, bluish color. We press Save Changes to save the change to the table and to close the Schema dialog.
As expected, a new field appears in the table called Ctile, of type tile. The field is shown in read-only gray background color since it is a computed field, the value of which is automatically computed for each record based on the expression we entered.
If we would like to see more info for the cTile field, we can right-click on the column header for the cTile field and choose Style, and then choose a format for the field that shows the data type used:
The TileAbs( ) function returns a floating point value, so this tile contains a single channel that is a float64 data type.
We will now create a new image, which takes tile data from the new cTile field we have just created.
We right-click onto the bronze Tiles 2 table and choose New Image. In the New Image dialog we choose the cTile field with a value of float64. We also enter the Bounds saved earlier, from the Rect value of [0, 0, 186, 216]. The cTile tile data uses the same projection, default Pseudo-Mercator, as the original Tile field for the bronze image, so we do not change the coordinate system setting.
Press Create Image.
That creates a new bronze 2 image in the Project pane, which we can double-click to open.
When we open the image we get a message about intermediate levels and about building a temporary index. Pressing View-Message and agreeing to build a temporary index makes the image appear, as seen below.
The image is drawn in gray scale, the result of the TileAbs function operating on the pixel values within the tiles of the Tile fields for each record to grab the first channel of each pixel.
In the workflow shown above we've cut a big corner by not creating a spatial index on the cTile field when we added it. Manifold can deal with the lack of a spatial index in an image by building a temporary index whenever we want to display the image, but responding to the message that is necessary every time we open an image is inconvenient.
It would be better to build a spatial index on the cTile field. That is easy to do. With the focus on the opened the bronze Tiles 2 table, launch Edit - Schema.
In the Schema dialog, press the Add command button and then choose Index in the drop down menu.
In the Index dialog, we use the name X_Y_cTile_x, following Manifold convention to name the index of a tile field by prefacing it with the X and Y fields used and appending an _x to the name of the tile field used. We choose spatial index for tiles (rtree) as the type. We choose X for the x field and Y for the y field, and cTile as the tile field.
The dialog automatically fills in float64 as the data type of pixels. We leave the default 128 x 128 dimensions for the tile, as those are the dimensions it uses. We leave the default, average, as the reduce method. Press OK.
A new spatial index based on cTile appears. We press Save Changes.
The next time we open the bronze 2 image, we will still get a message about intermediate levels, which we can build, but there will not be any message or offers to build a temporary spatial index. Once we build intermediate levels the first time the image is opened, we will not have to do that again: the image will simply pop open.
The example shows not only the use of a computed field, it also shows how images can take their content from whatever compatible table and field their properties specify. In this example we created a bronze Tiles 2 table that has two fields of type tile, one the original data and the other a field computed from that original data. We could use either column in an image. Note that the new, computed tiles are made up of different data in each pixel but the image display nonetheless still was able to create an image. Multiple images can use multiple fields from the same table at the same time.
One of the benefits of Manifold's "everything is a table" philosophy is the ability to keep just one copy of data somewhere and then see different views of that data based upon computations. Manifold is fast, especially when GPU parallel processing can be used, so it is a realistic strategy to do even complex computations on large images to transform data on the fly for display in different forms based on a single, stored data set.
Images and Channels
Style: Channels and Outputs Tutorial
Example: How Images use Tiles from Tables - An example showing how an image is made up from data stored in a table in tiles.
Example: Create Two Images From One Table - More than one image can show data from the same table, including from the same tile field.
Example: Change the Contrast of an Image - In this example we use the Style dialog to change the contrast of an image.
Example: Using the Assign Channels Button - The Assign Channels button in the Style pane for images allows us to assign channels to the standard three Red, Green, and Blue display outputs using frequently-desired arrangements. The button provides a short cut way to assign all channels at once instead of doing each channel individually.
Example: Assign Channels - How to use the Style pane for images to assign channels to display outputs such as R, G, B or A. This topic shows examples of channel combinations and the visual results.
Example: Set Image Transparency using Alpha - The A row in the Style dialog allows us to specify what transparency we want to apply to the image, either by applying the same value for A for all pixels or by using one of the other channels to also control the A value.
Example: Autocontrast and Hill Shading Images using Style - This example shows how the Style dialog can hill shade an image using the values of pixels as heights and generating shadows as if the Sun were located at the specified azimuth and altitude. This capability is used most frequently with raster images to give an impression of three dimensionality in cases where the values of pixels represent terrain elevations.
Example: Style Applied to an Image Server Image - Because the Style dialog simply changes the way an image is displayed and not the data, it can operate on read-only data served by various web servers such as WMS REST servers. In this example we look at every detail of creating a data source using an image server and then manipulating the appearance of the display with Style. We will connect to a WMS server that provides LiDAR data in various forms, including as terrain elevation.