Question about blending two images

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
wrybread
Posts: 4
Joined: 2011-10-24T15:17:19-07:00
Authentication code: 8675308

Question about blending two images

Post by wrybread »

I'm trying to blend two images, removing the green channel of one of them.

I'm trying to take this image:

Image

And make it look like this:

Image

I'm doing it in Photoshop by laying this over the original image:

Image

And then in Blending Options removing the green channel of that green layer, like this (note the checkbox for Green is unchecked - that's the only change being made on this panel):

Image

Does anyone have any hints about how I might achieve such a thing in ImageMagick?

Thanks for any help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Question about blending two images

Post by fmw42 »

this should be pretty close

convert Clipboard01.jpg -colorspace gray -auto-level +level-colors black,green1 Clipboard01_test1.jpg

see
http://www.imagemagick.org/Usage/color_ ... vel-colors
wrybread
Posts: 4
Joined: 2011-10-24T15:17:19-07:00
Authentication code: 8675308

Re: Question about blending two images

Post by wrybread »

Code: Select all

convert Clipboard01.jpg -colorspace gray -auto-level +level-colors black,green1 Clipboard01_test1.jpg
Very close.

Is there some simple way to brighten it a bit? That produces this:

Image

And I'd like to get it closer to this:

Image

Or maybe brightness isn't the method I should be using?

I posted the test image and the target if anyone wants to play with the source images themselves:

http://sinkingsensation.com/stuff/tests/tests.zip
wrybread
Posts: 4
Joined: 2011-10-24T15:17:19-07:00
Authentication code: 8675308

Re: Question about blending two images

Post by wrybread »

For anyone else coming down this path, this does a pretty good job of finishing the transformation:

Code: Select all

convert test2.jpg -modulate 185% test3.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Question about blending two images

Post by fmw42 »

I think you typed green and it needs to be green1. With green1, I get the same brightness as you had desired.

In IM, pure green is green1.

see
http://www.imagemagick.org/script/color.php


If that does not work, then what version of IM are you using? If old, consider upgrading as it works fine for me using green1 in IM 6.7.3.2 Q16 Mac OSX Tiger. It is possible that you have an old version of IM before -auto-level. If so try using -contrast-stretch 0 in place of -auto-level.
wrybread
Posts: 4
Joined: 2011-10-24T15:17:19-07:00
Authentication code: 8675308

Re: Question about blending two images

Post by wrybread »

> I think you typed green and it needs to be green1.

Wow and thanks, you're right, I copied it incorrectly. Perfect now.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Question about blending two images

Post by anthony »

For a 'pure RGB green' I generally recommend using the color name "lime".

The reason "green" is so dark is that it is the SVG defination of "green" and not the X11 defination of "green".

See IM examples, Color Basics, Color Name Conflicts
http://www.imagemagick.org/Usage/color_ ... _conflicts
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Question about blending two images

Post by fmw42 »

I believe that lime and green1 are identical. see http://www.imagemagick.org/script/color.php
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Question about blending two images

Post by anthony »

fmw42 wrote:I believe that lime and green1 are identical. see http://www.imagemagick.org/script/color.php
It is.

However color names that are followed by numbers are not generally regarded as a good thing, unless you are actually after a pre-prepared 4 color gradient. For example: khaki1, khaki2, kahki3, kahki4

The main reason for that is that the number '1' color does not always correspond to the X11 color name. In some cases none of the colors in the numbered gradient actually directly match the color without a number. For example "khaki" does not directly match any of the colors "khaki1" to "kahki4" though "khaki" is almost identical to "khaki2".

Code: Select all

convert -list color | grep khaki
khaki                 rgb(240,230,140)                              SVG X11 XPM 
khaki1                rgb(255,246,143)                              X11 
khaki2                rgb(238,230,133)                              X11 
khaki3                rgb(205,198,115)                              X11 
khaki4                rgb(139,134,78)                               X11 
Basically numbered colors are typically avoided, unless you have a specific requirement (which I have never actually seen!). The only exception to this is gray# numbered colors....

ASIDE: gray50 is a perfect 50% gray color, but only if you restrict yourself to 24 bit colors (8 bit depth). It is not the same as a perfect 16 bit depth gray which you can get using gray(50%), whcih can be important for some mathematical image processing such as composition lighting effects, and other image mapping, and FFT.

That is to say even the gray# numbers are not always good enough either!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply