Alpha Compositing: Blending Two Raster Images

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Blending Two Images

Similar to the Raster Mosaicker Scenario, updated imagery, partially covering the area of interest, is used to update an existing mosaic in this scenario. However, this article shows how to use Alpha compositing to do the same thing, while generating a smooth transition on the boundary between the old and new imagery. This could also be used when the old and new imagery differs in spectral range and/or resolution.

http_download_1444329918608_6032.jpeg

The implementation of a smooth transition is similar to the previous scenario - multiple buffers change gradually their transparency. For the older outer infrared image we go from fully opaque area to the transparent, for the newer true color image we go from fully transparent areas to opaque. 'Compositing Using Alpha Band' option set to 'yes' mixes the pixels of two images appropriately, so we see how one image gradually transforms into another:

http_download_1444329919321_6032.jpeg

As a side note I wanted to mention how the RasterCheckPointer inserted before the RasterMosaicker improves the overall performance - the workspace needs as many seconds to complete the task as many minutes it needs without this transformer.

Note: To run this example, you will need to download both the attached template AlphaCompositingTwoImages.fmwt and the source dataset in the zip file

 

Transition to White

In some raster project specs we may find an item that requires clipping rasters to the project boundary.

rtaimage2.jpg In FME, it can easily be done with non-rectangular raster clippers, which is implemented as a standard function of the Clipper transformer.

rtaimage3.jpg

But sometimes, the customer's requirements go even further. The rasters shouldn't be clipped abruptly, but rather they should gradually blend into the surrounding whiteness (or blackness).

This is possible using the RasterMosaicker's alpha compositing option. Compositing is an operation that uses the value of the alpha band to weight the amount that each overlapping band contributes to each resultant pixel value.

The idea of how to make a raster gradually disappear is simple - we generate multiple concentric buffers (using the MultiBufferer) around the project area, assign colors changing gradually from black to white, rasterize the features and copy color values to the alpha band where they will represent the amount of transparency rather than colors - higher the value, the more transparent a pixel will be. Areas that were black will be completely transparent, purely white areas will be fully opaque, all shades of gray will be transparent to a different degree.

Here is an image showing how the mask we apply to the raster looks before converting a color band to an alpha band:

rtaimage1.jpg

The RasterExpressionEvaluator allows calculations on band values. In our case, we need to copy values from any color band to the alpha band:

A[0];A[1];A[2];A[0]

The last step is the mosaicking of the original raster and the mask containing transparency information:

rtaimage4.jpg

The attached template contains the workspace, the source raster in TIFF format, and the MapInfo project boundary.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.