Page 1 of 1

composite -compose screen @some % of overlay image?

Posted: 2012-03-12T21:43:02-07:00
by rutile
I've been combining two images with a straight blend, so that the final image is some percent of the overlay and the background. Like so:

composite -blend 25 overlay.jpg background.jpg destination.jpg

Now I'd like to do the same thing, but in screen or multiply mode. I thought it would be a simple matter of replacing -blend with -screen, but apparently it isn't that simple.

All I want to do is replicate a GIMP layering, where two layers are combined in screen mode, and the layer on top is only visible or weighted at 25%.

I know this should be pretty easy, but it escapes me, any help is appreciated.

Thanks

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-12T22:43:11-07:00
by anthony
-blend is a specialised composition that weights the two images before adding (plus) them together.
http://www.imagemagick.org/Usage/compose/#blend
-dissolve is very similar but performs an over composition.
http://www.imagemagick.org/Usage/compose/#dissolve

To do this with screen or multiply does not make sense. mathematically a weighted multiple (or for screen negated multiply) is just a same as doing the multiply of the images and a constant!


An alternative to blend is to use the special 'mathematic' compostion
http://www.imagemagick.org/Usage/compose/#mathematics

EG; using convert options...

Code: Select all

   -compose blend -define compose:args=25x75  -composite
and

Code: Select all

   -compose mathematics -define compose:args=0,0.25,0.75,0  -composite
should produce the same results.

WARNING: mathematics uses 'screen' alpha blending when alpha channels are present, just like the other mathematical composition methods. Blend however uses 'blend' alpha blending.
See Mathematical Composition and Alpha Blending
http://www.imagemagick.org/Usage/compose/#math_blending

ASIDE: looks like their is a bug in mathematical blending without the 'sync' channel flag. -- I have noted it, to have a look.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-12T23:37:14-07:00
by rutile
thanks, but maybe we talking at cross purposes? I'm not sure if I understand what you are suggesting. I'm ok with the blend mode for where I need to use that. What I need to do now is combine two images in screen mode. A background image with a starfield, and black silhouetted foreground, and an overlay image with the foreground illuminated showing detail. I want to combine the two images using screen, so that where the background image is purely black, about 25% of the overlay image foreground detail shows through. In Gimp, I make the foreground image 25% opaque, and use screen mode. I need to do this with several hundred images, each time I make a scene, so I'd like to do it in imagemagick. I'm rather dense when it comes to figuring out the command line options through, for example, in your examples, I'm not sure where the input image designations go, and I don't think those commands give me a screen mode?

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-13T00:14:24-07:00
by anthony
Sounds like a masked composition to me.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-13T01:02:58-07:00
by stupid
Try this.

convert BOTTOM_IMAGE ( TOP_IMAGE -alpha Set -channel A -evaluate Multiply 0.25 +channel ) -compose Screen -composite OUT.JPG

s.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-13T09:48:32-07:00
by rutile
stupid wrote:Try this.

convert BOTTOM_IMAGE ( TOP_IMAGE -alpha Set -channel A -evaluate Multiply 0.25 +channel ) -compose Screen -composite OUT.JPG

s.
Stupid isn't so stupid ;)

My terminal doesn't like the parenthesis, but without them it seems to work. It doesn't exactly replicate the GIMP version, but I think that I can work with it.
thanks a lot. I couldn't make these images without imagemagick.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-14T00:01:01-07:00
by anthony
Without the parenthesis, you are applying the alpha channel dissolve to BOTH images, not just one image.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-14T02:40:14-07:00
by stupid
It's worth noting that the parentheses require spaces on both sides of each character. Eg SPACE(SPACE... SPACE)SPACE. You could also try escaping the parentheses: \(... \). On Windows that would be ^(... ^).

s.

Re: composite -compose screen @some % of overlay image?

Posted: 2012-03-14T19:56:52-07:00
by anthony
windows does not need escaping for parenthesis
http://www.imagemagick.org/Usage/windows/#dos