Transform - Tiles: Compose

The Watershed template appears in the template list when a raster tile field, of type Tile, has been picked in the Transform pane.  The template composes a tile value, either a new tile value composed from specified channels or a rearrangement of an existing tile field.

 

Compose

Compose a tile value, either a new tile value composed from specified channels or a rearrangement of an existing tile field by rearranging existing channels:

 

  • pixels - Compose a new tile from numeric values or single-channel tiles.  

  • rearrange channels - Rearranges channel values in an existing tile.  Setting a specific channel to (none) sets it to 0.

 

Launch the template by choosing a Tile field and then double-clicking the Compose template.  When the template launches we can specify options.

 

 

Compose : pixels

Fills all pixels in the specified channels using the given values, and save the result into the Result destination.  Useful for forcing all terrain elevations to a single, specified height.   Formerly known as Fill.

 

 

With the focus on the Alps image, in the Transform pane we choose the Tile field and then we double-click the Compose template to launch it.

 

 

In the Compose template, we choose pixels as the Compose option. The Alps image has only one channel, so only one channel control, Channel 0, appears.  We enter 0 for the value to place into all of the Channel 0 pixels.  

 

For the Result destination, we choose New Field and then enter Tile composed as the name of the new tile field to add to the table.  For the new image name we enter Alps composed.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.

 

Press Transform.  

 

A new image called Alps composed appears in the Project pane.   We drag and drop the new Alps composed image into the Alps window as a layer.

 

 

If we Style the new Alps composed image using the same thematic format used for the Alps image, it appears in all blue color, the color that the thematic format assigns to 0 height pixels.

 

The SRTM terrain height seen in the Alps layer is a hill shaded view of the foothills of the Alps near Vicenza that has missing pixels, seen in white, where the Space Shuttle radar scan did not acquire elevations.  Assigning 0 to all pixels using compose flattens the terrain to a single height of 0 in the preview, including invisible pixels.  To fill in only missing (invisible) pixels, see the Fill in Missing Pixels video.

Multiple Channel Images

The Compose : pixels operation works with more than one channel as well.

 

Consider the image below, which shows a section of an NAIP, four-channel image of a park near the state capitol building in Indianapolis, Indiana.    The image has three RGB channels in Channels 0, 1, and 2 plus a near-infrared channel in Channel 3.

 

We show the image as a Color Infrared display, as described in the Example: Display an NAIP Four Band Image as Color Infrared (CIR)  topic.   Channel 3 has been assigned to red, Channel 0 assigned to green, and Channel 1 has been assigned to blue.

 

In addition, we have Ctrl-clicked two tiles to select them.

 

 

With the focus on the Indianapolis image, in the Transform pane we choose the Tile field and then we double-click the Compose template to launch it.

 

 

In the Compose template we choose the pixels option.   The template shows all four channels in the image.  We will force use of a green color that as R, G, and B values would be 141, 198, and 63 respectively.  Given the use of Channels 3, 0, and 1 for R, G, and B, we enter the values seen above into the different channels.  

 

We will transform the image in place, writing results into the original tile field, so in the Result box we choose Same Field.     To apply the transform only to selected tiles, we check the Transform selection only box.  

 

Press Transform.

 

 

The pixel values are transformed in place so the image immediately updates with our changes.  In the illustration above we have chosen Edit - Select None to deselect the tiles so that the red selection color does not interfere with coloring.     We see that pixels in the two selected tiles have been filled with values composed from the numbers we specified.   The rest of the image is unchanged.

 

Compose : rearrange channels

Rearranges channel values in an existing tile.  Setting a specific channel to (none) sets it to 0.

 

We will rearrange channels in a four channel NAIP image to create a color infrared (CIR) image.   NAIP images contain four channels, channels 0, 1, 2, and 3, for Red, Green, Blue, and Near Infrared.

 

A normal image uses only channels 0, 1, and 2 assigned to Red, Green, and Blue as follows:

 

R, G, B =  0, 1, 2

 

A color infrared (CIR) image uses channels 0, 1, and 3, assigned to Red, Green, and Blue as follows:

 

R, G, B =  3, 0, 1

 

We begin with an NAIP image showing part of the Sacramento River near Redding, California.

 

 

With the focus on the Redding image, in the Transform pane we choose the Tile field and then we double-click the Compose template to launch it.

 

 

In the Compose template we choose the rearrange channels option.   The template shows all four channels in the image in their current arrangement.  

 

 

We choose values in the pull down menus for the Channel 0, Channel 1, Channel 2, and Channel 3 parameters as shown above.  We do not want to transform the Tile field "in place", but instead will save the result to a new tile field.  

 

For the Result destination, we choose New Field and then enter Tile CIR as the name of the new tile field to add to the table.   From the Info pane we can see that the data type of tiles in the Redding image is uint8x4, which means the tile has four channels of type uint8.   We therefore choose uint8 as the Channel type for the new tile field we will create.

 

For the new image name we enter Redding Color Infrared.   We could use whatever names we want for the names of the new tile and image, but it is wise to use names that remind us of what they are supposed to be.

 

Press Transform.  

 

A new image called Redding Color Infrared appears in the Project pane.   We double-click open the new Redding Color Infrared image and use the Locations button in the main toolbar to match the view in the Redding window, for easy comparisons.

 

 

The image pops open with unexpected blue colors.  We expected to see the classic red foliage of color infrared images.   That happens because the new tile is in BGR data ordering and we want it to be in RGB.   That is easy to change.

 

 

With the focus on the Redding Color Infrared image, In the Style pane we use the arrangement picker button to choose RGB, and then we press Update Style.

 

 

That's better!

 

 

If we pop open the drawing's table, we see that we have added a second tile field to the same table that stores tile data for the Redding image.   That allows us to keep the data in the original channel order in one tile field and to also have it in CIR channel order in another tile field.

 

Since we could have just created a second image from the same Tile field, and then used Style to change the display assignments for channels for that second image, why go to the trouble of creating a second tile field that has physically different data storage for the channels?    We do that since not all software can shuffle channel assignments on the fly for display, like Manifold can.   If we ever need to arrange channels in explicit order, perhaps for export in use in other software, we can do that using the rearrange channels transform operation.

 

 

Notes

 

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

 

See Also

Transform Pane

 

Transform Reference

 

Transform - Tiles

 

SQL Example: Create NDVI Displays - How to create a query that creates an NDVI display from a four-band NAIP image, with tips and tricks on how to copy and paste existing information to get the result we want.