RasterMosaicking with Alpha Compositing

From fmepedia

you need FME 2009 build 5600 or higher in order to run this workspace.

Transition to white

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

In FME, it easily can be done with non-rectangular raster clippers, now implemented as a standard function of the Clipper transformer (before FME 2009 we had to use a special trick).

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

Now it's possible starting from the build 5600 where we added alpha compositing option to our RasterMosaicker. 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 how to make a raster gradually disappear is simple (I think, I use these words too often) - we generate multiple concentric buffers (using MultiBufferer) around the project area, assign colors changing gradually from black to white, rasterize the features and copy color values to alpha band where they will represent the amount of transparency rather than colors - more the value less the transparency. Areas that were black will be completely transparent, purely white areas will be fully opaque, all grades 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:

RasterExpressionEvaluator allows calculations on band values. In our case we need simple copying values from any color band to the alpha band:

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

(see RasterExpressionEvaluator_Examples for raster expression examples).

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

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

Blending two images

Another interesting scenario is blending of two images. Imagine we have some newer imagery partially covering the area of interest. This scenario can complement my Raster Mosaicker Scenario, which talks about making raster mosaics and inserting updated imagery.

A simple update just puts new images on top of the old ones, and the boundary between two images is very sharp. If the images are quite different (different resolution or even spectral range), this sharp transition may look not very nice.

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:

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

The archive (~18 Mb) contains the workspace and two source images.

Attached Files
filesizedate
BlendingImages.zip17.6 MB08/28/08
NoBlending.jpg63.3 kB08/27/08
RasterAlphaCompositing.zip3.1 MB08/27/08
blended.jpg174.6 kB08/28/08
dest.jpg119.2 kB08/27/08
index.php------
mask.jpg132.5 kB08/27/08
sharpedges.jpg187.1 kB08/28/08
source.jpg240.1 kB08/27/08
User Comments Add a new comment