Page 1 of 1

image multiplication?

Posted: 2014-06-19T08:29:14-07:00
by rubinglen
Hi all!

I have two same-sized black on white images (image1.png image2.png). I would like to merge these images in such a way that the locations where both images are black are turned to white in the composite image.

I tried making some commands using compose and multiply, but I didn't have much luck. I think there was something very wrong with my commands...I am very new to image processing and could use some advice on this. Thanks!

Re: image multiplication?

Posted: 2014-06-19T08:48:18-07:00
by snibgo
You might compose them. See http://www.imagemagick.org/Usage/compose/

What result do you want when one or other isn't black? I mean, just setting the result to white, no matter what, would satisfy your requirement!

Re: image multiplication?

Posted: 2014-06-19T09:18:06-07:00
by rubinglen
That's a good question, obviously I didn't explain well b/c I did not think this out thoroughly.


More precisely:

I would like to remove (turn white) from image1.png any places where image 1.png and image2.png have overlapping black pixels. All the rest of image1.png I want to leave the same.

Re: image multiplication?

Posted: 2014-06-19T10:34:49-07:00
by snibgo
Okay. You want the output to be input #1, except that where both inputs are black, you want white. This will do it, but there may be a better way. Windows BAT syntax:

Code: Select all

convert ^
  g1.png ^
  ( +clone ^
    g2.png ^
    -negate ^
    -compose Multiply -composite ^
    -alpha set +transparent White ^
  ) ^
  -compose Over -composite ^
  out.png

Re: image multiplication?

Posted: 2014-06-19T11:28:40-07:00
by rubinglen
that works, thanks!