Masking 2 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
sparks
Posts: 2
Joined: 2019-01-08T15:09:49-07:00
Authentication code: 1152

Masking 2 images

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Masking 2 images

Post 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
sparks
Posts: 2
Joined: 2019-01-08T15:09:49-07:00
Authentication code: 1152

Re: Masking 2 images

Post by sparks »

Thanks for the quick response! I'll give that a try.

I'm using convert 6.7.8-9 Q16 on linux.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Masking 2 images

Post 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.
Post Reply