Page 1 of 1

Masking 2 images

Posted: 2019-01-08T15:17:09-07:00
by sparks
First, I'm not sure if a 'mask' is the correct operation. Here's what I'm trying to do.

+ I have 2 images. Image1 is color, Image2 is greyscale.
+ The greyscale image has pixel values from 0-255

Using the x,y pixel value of greyscale Image2, I want to darken (or lighten) the same x,y pixel value of color Image1.

Any help would be greatly appreciated!

Re: Masking 2 images

Posted: 2019-01-08T15:44:39-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli


Perhaps what you want is (assuming IM 6)

Code: Select all

convert image1 image2 -compose hardlight -composite resultimage
If on IM 7, use magick rather than convert

See https://imagemagick.org/Usage/compose/#hardlight

Re: Masking 2 images

Posted: 2019-01-08T16:49:40-07:00
by sparks
Thanks for the quick response! I'll give that a try.

I'm using convert 6.7.8-9 Q16 on linux.

Re: Masking 2 images

Posted: 2019-01-08T17:38:28-07:00
by fmw42
You may need to increase he contrast in image2. One way is -auto-level. Another is -level or -sigmoidal-contrast or -brightness-contrast.