Alpha Compositing: Transitioning to White

Sydney Dombowsky
Sydney Dombowsky
  • Updated

Introduction

Alpha compositing is the process of blending an image with a background using alpha values to set transparency, creating a seamless image with a smooth transition along the boundary. This can be beneficial when combining rasters with different resolutions or spectral ranges as demonstrated in the Alpha Compositing: Blending Two Raster Images article. Another use case for alpha compositing is demonstrated in this tutorial, where we will create an area of interest transitioning to transparent using an orthophoto and a project boundary. This is useful when we don’t want an abruptly clipped project boundary, but rather a gradual blend into the background.

 

Files

Due to the large file size of the raster image, the GeoTIFF file must be downloaded separately from the City of Vancouver's Open Data Portal or the links below. Optionally, you can copy and paste the HTTPS URL directly into the GeoTIFF reader.

 

Orthophoto2011 (GeoTIFF):

https://safe-kc.s3.us-west-2.amazonaws.com/Alpha+Compositing%3A+Blending+Two+Images/Orthophoto2011.zip

 

The project boundary Esri Shapefile and FME workspace template can be downloaded from the files section on the right.

 

Step-by-Step Instructions 

This tutorial will walk you through the steps to produce an image fading to white using a project boundary and an orthophoto. The tutorial is divided into three sections to create the alpha mask, prepare data for joining, and combine rasters for writing.

 

Part 1: Create Buffers and Properties to Rasterize Alpha Mask

In Part 1, we will read the source data, create buffers, and set raster properties so the mask can be rasterized.

 

1. Read Project Boundary Shapefile

Open a New workspace in FME Workbench. Click the Reader button in the Toolbar and set the following parameters to add the Project Boundary file:

  • Format: Esri Shapefile
  • Dataset: /ProjectBoundary.shp
    • Browse to downloaded data

 

2. Set Buffer Size and Count

We want to set two attributes that we will use as buffer parameters, which can be done using an AttributeCreator. Add an AttributeCreator and connect its Input port to the ProjectBoundary Esri Shapefile reader feature type and create the following attributes in the parameters dialog:

Output Attribute Value
BUFF_COUNT 50
BUFF_SIZE 3

 

3. Create Buffers

To create multiple buffers, we will use the MultiBufferer custom transformer. This can be installed through FME Workbench directly by adding the transformer and accepting the install dialog. You can also download the transformer from FME Hub and import it into FME Workbench.

Connect the AttributeCreator Output port to the MultiBufferer Input port and set the following parameters:

  • Buffer Interval: BUFF_SIZE
    • Click the drop-down arrow to select the attribute value
  • # of Buffers: BUFF_COUNT
    • Click the drop-down arrow to select the attribute value
  • Create Donuts: Yes
    • This setting is important as it creates multiple buffer rings rather than nesting polygons

 

4. Assign Color to Buffers

We want each of the buffers to have a different transparency value as an alpha band. We will do this by setting a color value that will later be converted to a transparency value. To create this attribute, add an ExpressionEvaluator to the canvas and connect its Input port to the MultiBufferer Output port.

  • Evaluation Mode: Create New Attribute
  • Result: COLOR
  • Arithmetic Expression: 

    1/double(@Value(BUFF_COUNT))*@Value(_buffer_id)

This will create a new attribute called COLOR that is assigned a value between 0 and 1, increasing the value for each buffer as we get further from the center. We will use these values to set the fme_color attribute to rasterize. When we rasterize and convert to an alpha band, the outer buffer will be white and will gradually become more transparent as we move inward to show the orthophoto we mosaic with.

 

5. Set fme_color Attribute

In order to rasterize the buffers we’ve created, FME requires the attribute fme_color to assign geometry color. We will create this attribute using a StringConcatenator and referencing the COLOR attribute we assigned in the previous step.

  • New Attribute: fme_color
  • String Parts:
String Type String Value
Attribute Value COLOR
Constant ,
Attribute Value COLOR
Constant ,
Attribute Value COLOR

Concatenated Result: @Value(COLOR),@Value(COLOR),@Value(COLOR)

 

6. Read Orthophoto (GeoTIFF Reader)

We will now read the orthophoto source image. Add a GeoTIFF reader and set the following parameters:

  • Format: GeoTIFF (Geo-referenced Tagged Image File Format)
  • Dataset: /Orthophoto2011.tif
    • Click the ellipsis to browse to the downloaded file if you saved it locally, or paste the data HTTPS URL instead and remove the quotations

      https://safe-kc.s3.us-west-2.amazonaws.com/Alpha+Compositing%3A+Blending+Two+Images/Orthophoto2011.zip

 

7. Extract Bounding Box

Before we combine the orthophoto and project boundary buffers, we will extract the bounding box of the orthophoto to rasterize with the project boundary alpha mask. We will then set the bounding box color to white so it will hide the orthophoto area outside of the buffers.

Add a BoundingBoxReplacer and connect its Input port to the GeoTIFF reader feature type. Leave the default parameters.

 

8. Set Feature Color

Using a FeatureColorSetter, we will set the extracted bounding box to white. 

Connect the BoundingBoxReplacer Box output port to a FeatureColorSetter Input port. Open the parameters and set the following:

  • Color Scheme: Fixed
  • Pen Color: 1,1,1
    • Click the ellipsis button to select the color ‘White’ or set manually set to 1,1,1 or 255,255,255

 

Part 2: Rasterize and Prepare for Combining

Now that the data is ready to be rasterized, we can create the alpha mask. We will then prepare the rasters for combining by ensuring their properties match.

 

1. Rasterize Alpha Mask

To rasterize the colored project boundary buffers, we will use an ImageRasterizer. 

Connect both the StringConcatenator Output port and the FeatureColorSetter Colored output port to an ImageRasterizer Input port:

Set the following parameters:

  • Resolution Specification: Cell Spacing
  • X Cell Spacing: 1
  • Y Cell Spacing: 1
  • Interpretation Type: RGBA32
  • Background Color: 0,0,0
    • Click the ellipsis to select the color ‘Black’ or manually enter 0,0,0

 

2. Assign Band Values

We will now set the alpha band values to equal the red band values (green or blue could be used instead as all three color bands are equal) using a RasterExpressionEvaluator. This will provide the alpha band with a gradual transition from opaque to transparent.

Add a RasterExpressionEvaluator to the canvas. Connect the ImageRasterizer Raster output port to the RasterExpressionEvaluator A input port and set the following parameters:

  • Mode: One Raster
  • Band Expressions:
Interpretation Expression
Red8 A[0]
Green8 A[1]
Blue8 A[2]
Alpha8 A[0]

This keeps the original values for red, green, and blue that we created with the fme_color attribute, and assigns the red band values to the alpha band.

 

3. Add Alpha Band to Orthophoto

The original 2011 orthophoto has an interpretation type of RGB24. Before mosaicking the project boundary buffers with the orthophoto, the number of bands must match. We will add an alpha band with a constant value to the orthophoto using a RasterBandAdder.

Connect the Orthophoto2011 GeoTIFF reader feature type to a RasterBandAdder Input port and set the following parameters:

  • Interpretation Type: Alpha8
  • Value: 255
    • This sets the transparency of the orthophoto to opaque

 

4. Create Attribute for Ordering

The final steps to perform before we combine the rasters include sorting them. We want the buffer alpha mask to be read last so it is on top of the original raster.

We will add an order attribute to both raster streams using AttributeManagers. Add two AttributeManagers to the canvas. Connect one to the RasterExpressionEvaluator Result output port. Connect the other to the RasterBandAdder Output port:

In the AttributeCreator connected to the first RasterInterpretationCoercer (the alpha mask stream, AttributeCreator_3), set the following:

  • Output Attribute: ORDER
  • Value: 2

In the AttributeCreator connected to the second RasterInterpretationCoercer (the orthophoto stream, AttributeCreator_4), set the following:

  • Output Attribute: ORDER
  • Value: 1

 

5. Sort Raster Order

We will now use the ORDER attribute we created to sort the incoming rasters with a Sorter transformer. Connect both AttributeCreators Output ports to a Sorter Input port:

In the Sorter parameters, set the following:

  • Attribute: ORDER
  • Method: Numeric
  • Order: Ascending

 

Part 3: Combine and Write Output

In this final section, we will mosaic the two rasters and write the data to PNG for viewing.

 

1. Combine Rasters

The rasters are now prepared to be mosaicked. We will use a RasterMosaicker with the option to Composite Using Alpha Band selected, which will allow for the smooth transition from opaque to transparent.

Add a RasterMosaicker to the canvas and connect its Input port to the Sorter Sorted output port. Set the following parameters:

  • Overlapping Values: Composite Using Alpha Band

 

2. Write to PNG

The output is now ready to be written to a file for viewing. In this example, we will write to a PNG raster image. Click the Writer button in the Toolbar and set the parameters:

  • Format: PNG (Portable Network Graphics)
  • Dataset: /Output
    • Browse to an output folder location

Click OK. In the Feature Type dialog, set the file name:

  • Raster File Name: AlphaFade

Click OK. Connect the RasterMosaicker Output port to the AlphaFade PNG writer feature type.

 

3. Run Workspace and View Output

The workspace is now ready to be run.

With caching enabled, click the green Run button in the Toolbar to run the workspace. Once the translation succeeds, select the AlphaFade PNG writer feature type and click the View Written Data button in the Mini Toolbar.

In the Data Preview window, we can view the output file:

 

Additional Resources

Tutorial: Alpha Compositing: Blending Two Raster Images

RasterInterpretationCoercer Transformer Documentation

RasterCombiner Transformer Documentation

RasterPropertyExtractor Transformer Documentation

RasterGeoreferencer Transformer Documentation

MultiBufferer Custom Transformer

 

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.