First, break the problem down into simpler problems, such as abutting two images with a transition between them.
Suppose we have two images 60x60 pixels. Scripts are Windows; adjust as required. We get pure green from the colour name "lime".
Code: Select all
"%IMG%convert" -size 60x60 xc:red red.tiff
"%IMG%convert" -size 60x60 xc:lime green.tiff
Suppose we want a 10 pixel overlap. Then the final image will be 60*2-10 = 110 pixels wide. We can place each image on a canvas of this size:
Code: Select all
"%IMG%convert" ^
-size 110x60 canvas:grey ^
red.tiff ^
-composite ^
redLeft.tiff
"%IMG%convert" ^
-size 110x60 canvas:grey ^
green.tiff ^
-gravity East ^
-composite ^
greenRight.tiff
I choose grey for the canvas, just so I can see it. It won't show in the final image.
Create a mask: black on the left, white on the right, with a smooth fade in the middle 10 pixels:
Code: Select all
"%IMG%convert" ^
-size 50x60 xc:black ^
( -size 60x10 gradient: -rotate 90 ) ^
-size 50x60 xc:white ^
+append ^
mask.tiff
Apply the mask to the greenRight image, making it transparent where the mask was black and opaque where the mask was white. Place the result over the redLeft image.
Code: Select all
"%IMG%convert" ^
redLeft.tiff ^
( greenRight.tiff mask.tiff -compose CopyOpacity -composite ) ^
-compose Over -composite ^
out.tiff
There is a problem: the central portion is too dark. This is because we have worked in sRGB space, but RGB is a better choice.
Code: Select all
"%IMG%convert" ^
( redLeft.tiff -colorspace RGB ) ^
( greenRight.tiff mask.tiff -compose CopyOpacity -composite -colorspace RGB ) ^
-compose Over -composite ^
-colorspace sRGB ^
out2.tiff
You can extend this technique to any number of slices. Obvious improvements are possible, such as applying the colorspace adjustment to the mask instead of the photos.