Example: An Image using Computed Fields in a Table

This example is a continuation of the Example: How Images use Tiles from Tables topic.




Using the same bronze image from the previous example, 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.




In the Schema dialog we click the <new field> entry and then enter the name cTile of type tile.     In the Expression box 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 the Add button and then OK.




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.   The TileAbs( )  function returns a floating point value, so this tile contains a single channel that is a float64 data type.




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 system warns us using red text that we must specify the coordinate system used.   We click on the coordinate system button to do so.




In the pull-down menu we choose the Pseudo_Mercator system.  Press Create Image.




When we open the image we see it is now 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.


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.


See Also



Images and Channels


Palette Images




Style: Images


Style: Autocontrast


Style: Palettes




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 Edit - Style dialog to change the contrast of an image.


Example: Using the Assign Channels Button - The Assign Channels button in the Style panel 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 panel 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 Edit - 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 Edit - 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.