Linear alpha mask for merging overlapping pictures
Posted: 2018-02-20T11:50:18-07:00
Good evening!
I am using the following ImageMagick version on Windows:
I am trying to merge overlapping pictures. The pictures are 800x800, with a 200 px overlap on the height. I want to overlay the images and merge them via a linear alpha mask. I am creating a mask with a linear alpha on the bottom of the first image (p1.png) and top of the second image (p2.png) as follows:
The top image p1.png:
https://imgur.com/8vYyuIj
The bottom image p2.png:
https://imgur.com/pu7hPWA
And the resultant merged image merged.png:
https://imgur.com/3ySjaRE
How can I fix middle part (overlap) of the final image? It seems to be "undersaturated"? My theory is that the two linear gradients going in opposite directions should add up leaving the original colours after overlapping the pictures?
Help is appreciated, I am quite new to ImageMagick.
Thanks
Goose.
I am using the following ImageMagick version on Windows:
Code: Select all
Version: ImageMagick 7.0.7-22 Q16 x64 2018-01-22 http://www.imagemagick.org
Code: Select all
magick -size 800x600 xc:none none.png
magick -size 800x200 gradient:none-black gradient.png
convert -page +0+0 none.png -page +0+600 gradient.png -layers merge +repage temp.png
convert temp.png -alpha copy mask.png
convert p1.png mask.png -alpha Off -compose CopyOpacity -composite masked.png
magick -size 800x200 gradient:black-none gradient-top.png
convert -page +0+0 gradient-top.png -page +0+200 none.png -layers merge +repage temp.png
convert temp.png -alpha copy top-mask.png
convert p2.png top-mask.png -alpha Off -compose CopyOpacity -composite masked-1.png
convert -page +0+0 masked.png -page +0+600 masked-1.png -layers merge +repage merged.png
https://imgur.com/8vYyuIj
The bottom image p2.png:
https://imgur.com/pu7hPWA
And the resultant merged image merged.png:
https://imgur.com/3ySjaRE
How can I fix middle part (overlap) of the final image? It seems to be "undersaturated"? My theory is that the two linear gradients going in opposite directions should add up leaving the original colours after overlapping the pictures?
Help is appreciated, I am quite new to ImageMagick.
Thanks
Goose.