Solved

Unexpected result when using Imagemagick to combine two images

Posted on 2014-03-11
7
349 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
The goal of the tutorial is to teach the user what gradient filters are and how to use them. When you have a photo and some part of the photo is either over exposed or under exposed, you use a gradient filter to help mask the need to touch up th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now