Example: Set Image Transparency using Alpha

This example continues using the same example data as the Example: Using the Assign Channels Button topic.

 

Color images such as RGB images often also have an Alpha or A output, which specifies transparency for each pixel.   Such images are commonly known as RGBA images.   When an image is imported from a format such as JPG or other format that might not have an alpha channel value for each pixel, Manifold nonetheless is ready to apply a transparency factor to each pixel, a useful capability when the image is seen as a layer in a map.    

 

The A output row in the Style panel 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.

 

Suppose we have a map with two layers, a lower drawing layer that shows shapes colored using thematic formatting in Style and an upper image layer showing the ginevra image.

il_style_image_bgr01_13.png

With the ginevra image clicked off we see the drawing layer.

 

il_style_image_bgr01_14.png

With the ginevra layer clicked on we do not see the drawing layer because the image is fully opaque.

 

With the focus on the ginevra layer tab we use the Style panel.  

 

il_style_image_bgr01_15.png

 

We double-click into the Value cell for the A row so we can edit the 0 value, to change it to some other value.

 

il_style_image_bgr01_16.png

 

We change the Value to 100 and we press Update Style.

 

il_style_image_bgr01_17.png

A value of 0 for Alpha means no transparency while a value of 255 would mean complete transparency.   The value of 100 we have applied means about 40% transparency.   That level of transparency allows the drawing below the image to show through the partially transparent image.

 

We can restore full opacity by changing the Value for A back to 0.

 

il_style_image_bgr01_18.png

 

Change the value for A in the Value cell to 0 and press Update Style.

 

il_style_image_bgr01_19.png

The image is restored to full opacity, that is, zero transparency.

 

Applying Changes in Alpha to Linked Data

When working with spatial data we may find the Alpha setting useful to show displays from more than one data source.  The steps which follow are somewhat contrived, in that the usual way we would change transparency of layers in a map is using the Layers panel.   However, changing transparency using the Layers panel only changes transparency for that layer in that particular map.   Changing the alpha channel is changing a property of the image and will apply in whatever setting that image is used.

 

il_style_image_bgr01_20.png

In the illustration above we see shaded terrain elevation data, in the region just to the East of Huckleberry, Maryland, from a server in Maryland as shown in the Example: Autocontrast and Hill Shading Images using Style  topic.

 

We create a new data source using the Bing street map imageserver as shown in the Example: Create a New Data Source from a Manifold Image Server  topic.   

 

Important: We then create an editable copy of that image as shown in the Example: Style Applied to an Image Server Image topic, and then we drop that editable copy of the image into the map.  This is an important step because images within the Bing data source are read-only, so if we want to change the Style used by that image we must first copy the image within the Bing data source, paste it as read/write image outside of the data source, and then adjust the properties to point back at the tile table that Bing provides.  This sound more complicated than it is in real life, where only a few moments are required.

 

il_style_image_bgr01_21.png

The imageserver layer is opaque, so we can no longer see the LiDAR data image below it.    We click the imageserver layer to make it the active layer and then we use the Style panel.

 

il_style_image_bgr01_22.png

 

We see that the images provided by the Bing imageserver are RGBA images, that is, they have a fourth channel, Channel 3, that is used for A or Alpha.   We double-click on the A output row's channel cell.  

 

il_style_image_bgr01_23.png

 

We want to apply the same, fixed value for Alpha for all pixels so in the pull-down menu we choose Value.  

 

il_style_image_bgr01_24.png

 

We then enter a value of 100 for the value and press Update Style.

il_style_image_bgr01_25.png

The result as seen above is that a transparency value of 100 is applied to all pixels in the image server layer, allowing the LiDAR layer beneath it to show through.

 

Notes

Alpha channel or Layers panel? -  In this example, we show how to vary the transparency of an image by altering the Alpha channel for each pixel.   That is a different technique than using the Layers panel to change the transparency of a layer in a map.

 

As noted above changing transparency using the Layers panel only changes transparency for that layer in that particular map.   Changing the alpha channel is changing a property of the image and will apply in whatever setting that image is used.

 

See Also

Images

 

Images and Channels

 

Palette Images

 

Style

 

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: 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.

 

Example: Change the Contrast of an Image - In this example we use the Style panel 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: Autocontrast and Hill Shading Images using Style - This example shows how the Style panel 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 panel 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.