# How to blend images on a spherical surface / cube map

I already have an algorithm for making panoramic image mosaics by image registration and then blending images in the overlap regions.

The following image from Wikipedia illustrates several images under translational movement stitched together by finding optimal dividing lines in the overlap regions:

Now I would like to extend this blending algorithm to various panoramic image projections.

The simplest case is planar projection in which does not posses any problems for blending. The following image illustrates two images and the stitch line.

I can basically take a region from canvas (already stitched composite image) and a corresponding region from image, then blend the two together and render the blended region back to canvas:

This is done sequentially for each new image.

However, when I experimented with spherical projection and 360° mosaics a problem appears when two images and their overlap region crosses the 360° boundary:

I can no longer take out a simple rectangular regions to blend as I have to count on wrapping.

Even worse, blending images on a cube map can split the overlap region in two or three parts:

I came with a few solutions on how to blend images on spherical surface or a cube map, but no one is satisfactory:

Solution 1

Process each facet of the cube separately (or similarly, each part of a spherical map separately). Unfortunately, this produces visible artifacts where the two facets of the cube meet as the blending of images in neighboring facets are different sub-optimal solutions.

Solution 2

Perform blending in the context of newly added image. This requires to inversely project composite image from cube map (or spherical map) in the coordinate system of newly added image, blend the two images and the project the overlap region back on the compositing surface.

This should work and remove artifacts, but requires more computation as data are repeatedly projected back and forth.

Solution 3

Always blend on a spherical surface, then project the whole mosaic on whatever surface.

This reduces blending problem on a single type of surface, but spherical projection treats image parts unevenly and more elaborate approach (such as blending images on a triangulated sphere) would be needed to ensure high quality re-projection.

Solution 4

When performing the blending, provide a function that properly maps out-of-bounds coordinates.

This is similar to Solution 2, but may be even more computationally expensive as the mapping function would be called too often (the blending algorithm may access the same pixel position many times).

Question

How to efficently blend several images on spherical surface or cube map or some other common compositing surface?

• Is performing the blending in the final geometry (i.e., you have to do it each time you want a new image) not feasible? Oct 8, 2013 at 10:45
• The problem was with boundary conditions - conversion to laplacian pyramid or gradient domain is not trivial e.g. in cube map. I have finally made it so that each image is warped (projected) but rotated in such a way it has no discontinuities. Then it can be blended without above problems. Oct 10, 2013 at 21:18

I have eventually found a simple idea for the solution on the paper called "Blending Images for Texturing 3D Models".

The idea is not doing the complete blending for each new image added to canvas, but rather build separate lowpass and highpass canvas (for two-band blending). These are then merged as a final step of the rendering.

Finding seam is still a bit tricky and not used in the paper. It requires reprojecting data from canvas to image, computing the seam and then projecting the blending mask to the canvas.

The method described in the paper is simple and does not leave any blending artifacts.

The only drawback is that more data have to be kept in memory.

Update

This solution does not work if the rendered canvas is smaller than original image. Furthermore gradient-domain blending is not easily applicable as well.

• What is the problem with Poisson editing (gradient domain operations)? Just in case, you will find a fast (FFT-based) approach here: ipol.im/pub/art/2013/41 Oct 8, 2013 at 10:48