Solved

Unexpected result when using Imagemagick to combine two images

Posted on 2014-03-11
7
355 Views
Last Modified: 2014-07-16
Hello All,

I am using ImageMagick-6.8.8-Q16 on a Windows 8 PC. I'm trying to use it to overlay one image, "overlay.jpg", on top of a "background.jpg". Both JPGs are the same size. I tried the following 3 commands, with these results:

convert background.jpg overlay.jpg -compose darken    -composite bg-ov-darken.jpg
convert background.jpg overlay.jpg -compose multiply  -composite bg-ov-multiply.jpg
convert background.jpg overlay.jpg -compose add       -composite bg-ov-add.jpg

Open in new window


resulting images
The first two options, "darken" and "multiply", give me the expected result. However, "add" gives me a bright blue in just one section of the image's overlap (the outputs are, top-bot, "darken", "multiply", and "add").

This is not what I was expecting... is it right? Or is this a bug? I have attached the two input JPGs.
background.jpg
overlay.jpg
0
Comment
Question by:futuremoose
  • 3
  • 3
7 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39922445
Please recreate what you want in photoshop or http://pixlr.com/ and lets focus on getting your desired output.    

What you are seeing in blue is not a bug though.
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 166 total points
ID: 39922704
I tried to see the math behind "add", but can't find it on the guide: http://www.imagemagick.org/Usage/compose/

The mathematical compose operators are: Multiply,  Screen,  Bumpmap,  Divide,  Plus,  Minus,  ModulusAdd,  ModulusSubtract,  Difference,  Exclusion,  Lighten,  Darken,  LightenIntensity,  DarkenIntensity

Dan
0
 
LVL 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 334 total points
ID: 39923327
It's explained more here http://www.imagemagick.org/Usage/compose/
rgbhttp://www.imagemagick.org/script/compose.php

plus      The source is added to the destination and replaces the destination. This operator is useful for averaging or a controled merger of two images, rather than a direct overlay.

add      As per 'plus' but transparency data is treated as matte values. As such any transparent areas in either image remain transparent.

Again, let's concentrate on what your expected output needs to be or are you just playing?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:futuremoose
ID: 39925224
Hi Guys,

First, thanks for helping... sorry for kind of late reply, but I am probably in a very different time zone (Tokyo).

As Scott pointed out, both "Plus" and "Add" are on the URL he mentione, but "Add" is not for some reason.

Anyhow "Plus" gives me an all white result (which I think is what I would expect from the description) but "Add" is supposed to be same as "Plus" but treats transparency differently... neither of which explains the blue result (at least to me... can you tell me how the blue overlap is possible? I must be missing something).

Anyhow, I'm not just playing... I need to merge two images and have the overlap color match the customers RGB spec exactly. This should explain exactly what I am trying to do. I hope you can help... thanks in advance.

an illustration
0
 

Author Comment

by:futuremoose
ID: 39925263
As you can see in the above post, neither the add or multiply gives me quite the result I need. Perhaps I need to use a "blend" of some sort?
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 334 total points
ID: 39925413
Where are you getting your color values from because they don't seem to match up in photoshop.  That could be a function of screen calibration on my end.  

"multiply" gives you a much different result that your first posted compared to  http:#a39925224.  

I use image magick on my server but I use it for uploading images to a webserver, resizing, making thumbnails.  I have only dabbled in blending and never did anything exact because of course with all different monitors calibrations, it is futile to get an exact color.  

If you need to use pure rgb numbers and not worry about how they appear on any given screen, then we we probably need to enlist the help of somebody more versed in the physics of color.
0
 

Author Closing Comment

by:futuremoose
ID: 40201196
Never really got a good answer on why I was getting the unexpected blue result. Anyhow, I found another way around the problem. Thanks everyone for their help.
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
PaperPort (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) is among the most important applications that I run on my Windows computers. I use it every day, for nearly all of my document and photo scanning, as well as most of my…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question