Example: Set Image Transparency using Alpha

This example continues using the same example data as the Example: Use the BGR Button to Assign Channels  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 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.


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.


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



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 choose Edit - Style  to launch the Style dialog.




We click on the A row to highlight it.




Next, we change the Value to 100 and we press Apply.



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.




Change the value for A in the Value box to 0 and press Apply.



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


When working with spatial data we may find the Alpha setting useful to show displays from more than one data source.


In the illustration above we see shaded terrain elevation data 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.   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:


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 choose Edit - Style to launch the Style dialog.




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 click on the A output row to highlight it.




We want to apply the same Alpha value for all pixels so our first step is in the Source box to choose Value.  




We can then enter a value of 100 into the Value box and press Apply.


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


See Also



Images and Channels


Palette Images




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


Example: Use the BGR Button to Assign Channels - The BGR button in the Edit - Style dialog for images allows us to assign channels in the data to B, G and R outputs that create the displayed image, using BGR, RGB or Grayscale ordering.


Example: Assign Channels using Source - The Source control in the Style dialog for images assigns channels to display outputs such as R, G, B or A.  .  This topic shows examples of using Source and the visual results.


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.