Example: How Images use Tiles from Tables

The data for an image imported from a .jpg file can be stored in a table in the form of tiles of uint8x3 values, which are x3 tuples of unsigned eight bit integers, a typical way of representing RGB colors.   

 

In this example we import a small .jpg image called bronze.jpg into our project.  The result is an image component called bronze and a table called bronze Tiles.  

 

We can double-click on the image and on the table to open them.  

 

 

The image shows a bronze statue.

 

 

The table has a field called Tile which has data of type tile for each record.  It is a small table since the image is small.   The style used for the Tile field in the table shows the X and Y size of the tile and the number of channels:  128 pixels by 128 pixels by 3 channels.   If we prefer a different format we could right-click the Tile column header and choose Style to choose a different format.

 

 

For example, we could choose a style that reported the X and Y dimensions in pixels of the tiles, as well as the data type, in this case uint8, used for each of the three channels.

 

If we right click on the bronze image component in the Project pane and choose Properties we can see that the image takes its content from the table called bronze Tiles using the field called Tile as the source of the tiles.  

 

 

Those properties are editable so if we like we can change them to use other fields or to use other tables.

 

For example, we can copy the bronze Tiles  table, paste it and then rename the pasted copy bronze Tiles 2.

 

 

We open the bronze Tiles 2 table we can Ctrl-click on the row handle for the second record to select it.   We then press the Delete key to delete the selected record.   

 

 

We now open the Properties for the bronze image and we edit the value in the Table property to be the bronze Tiles 2 table.    We press Enter to accept the edit and then OK.

 

 

We press OK to exit the Properties dialog.   

 

To refresh the bronze image we click it to move the focus there, and then in the main menu we choose View - Refresh.

 

 A message icon appears in the lower left corner of the image.   We choose View - Messages to see the system is complaining intermediate levels are out of date for the image, with an offer to update them.  We do that.   This is a side effect of primitive surgery on the image by deleting a tile.

 

 

We see that the image now has a rectangular region missing because the tile for that region was deleted from the bronze Tiles 2 table.

 

If we want to restore the tile we deleted from the bronze Tiles 2 table, we can do that by copying the missing tile from the original bronze Tiles table and pasting it into the bronze Tiles 2 table.

 

 

We open the bronze Tiles table and we ctrl-click the second row to select it, which is the tile for the X = 1 and Y = 0 position that we deleted from the bronze Tiles 2 table.

 

Press Ctrl-C, the keyboard shortcut for Copy, or press Edit - Copy in the main menu.

 

 

Switching to the bronze Tiles 2 table, we press Ctrl-V, the keyboard shortcut for Paste, or in the main menu we can press Edit - Paste.    The tile we copied appears in the bronze Tiles 2 table.

 

 

The bronze image updates with the missing tile now filled in as a result of the Paste.

 

 

 Once again, a message icon appears in the lower left corner of the image.   We choose View - Messages to see the system is complaining intermediate levels are out of date for the image, with an offer to update them.  We do that.   

 

 

This particular example is a clumsy, not-quite-right way of messing with a table that provides tiles for an image.  For example, images normally refresh automatically with no need to refresh them or to mess about with updating intermediate levels.  We have to do that in this case because we have manually broken the machinery of images: there is logical inconsistency to just deleting a tile so all of the tiles required for the image are not present.   It is a tribute to the robustness of images that the image did not simply choke on that inconsistency.    But deleting the tile is still useful as a "quick and dirty" example of how images are just a means of visual display for data that is stored as tiles in a table.

 

This example continues in the Example: An Image using Computed Fields in a Table topic.

 

See Also

Images

 

Images and Channels

 

Palette Images

 

Style

 

Style: Images

 

Style: Channels and Outputs Tutorial

 

Style: Autocontrast

 

Style: Palettes

 

Tables

 

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: An Image using Computed Fields in a Table - How an image can be created from tiles where the data for the tiles is taken from a field that is computed on the fly.

 

SQL Example: Re-tile an Image using a Different Tile Size - Starting with an image that uses a tile size of 128 x 128 pixels this SQL example creates a copy of the image using 500 x 500 pixel tiles.