Merging 3 images, help

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
M4g
Posts: 2
Joined: 2011-11-25T14:23:45-07:00
Authentication code: 8675308

Merging 3 images, help

Post by M4g »

Hello friends! I need some help and ideas with this:
Condition:
1st image (texture, can be absolutely any image):
Image
2nd image:
Image
3rd image:
Image
What I need:
Image
---
any suggestions?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Merging 3 images, help

Post by fmw42 »

Make your third image into a binary mask (black and white). Then composite the old car image over the background using the binary mask to control which image gets what. The trick (which is not easy to get perfect) is that you need to make the blue into white and everything else black (including the subaru letters). Or make the blue into black and everything else white and then negate the result.

then

convert car.png background.png mask.png -composite result.png
M4g
Posts: 2
Joined: 2011-11-25T14:23:45-07:00
Authentication code: 8675308

Re: Merging 3 images, help

Post by M4g »

no-no! 3rd no matter!
for e.g.:
Image
+
Image
=
Image
any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Merging 3 images, help

Post by fmw42 »

If you modify the third image correctly as a mask, it will do the job. But the hard part is making just the blue into white and everything else black including the subaru text (and no alpha channel). That is all I can tell you. If you can make that mask correctly, link to it on your message and I will show you that it works. You can also make the blue into black and everything else white including the subaru text and that can work also with the switching of the texture and car image.


I renamed your images for simplicity but you can figure those out. So try these steps and see what I am doing. Then you need to refine your mask.


convert 1mask.png -alpha extract 1mask3.png
convert 1car.png -alpha extract -negate 1mask4.png
convert 1mask3.png 1mask4.png -average -fill white +opaque black 1mask5.png
convert 1texture_02.png[300x100+0+0] 1car.png 1mask5.png -alpha off -composite \
\( 1mask4.png -negate \) -compose copy_opacity -composite 1result.png
Post Reply