简体   繁体   中英

Make a mask from an image

I have two png images of complex figures of the same resolution. The second image is always the same. I want to designate a position of the black dotes on the second image and to reverse color of dotes in the area on the first image. How can I get the desired area and work with it on the first image? I myself can only think of iterating through dots of the second image and, if condition is met, apply reversal to the dot of the same index on the first image. But that is obviously inefficient. `` The first image The second image The desired result

this is solution using ImageMagick. first, -negate the background(first image) and multiply logo(second image). at last negate again. then you could get res.png .

magick TH4C5.png -negate Y3MDy.png -compose multiply  -composite -negate tmp2.png

result

This works for me in ImageMagick.

convert triangle.png \( rectangle.png -negate \) -compose multiply -composite -negate result.png

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM