How to multiply an image by a constant ?

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
voldemarz
Posts: 2
Joined: 2014-09-26T04:18:34-07:00
Authentication code: 6789

How to multiply an image by a constant ?

Post by voldemarz »

Sorry if this is a simple question, but I can't find info online.

I have substracted two images and would like scale the resulting diff image by some constant to make differences more noticeable. I'd imagine ImageMagick is able to do this, but I can't find the right commands for this. Can anyone point me to the right place, documentation?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to multiply an image by a constant ?

Post by snibgo »

If you want to multiply all the pixel values by a certain factor, such as 45, then "-evaluate Multiply 45". See http://imagemagick.org/script/command-l ... p#evaluate

"-auto-level" may also be useful.
snibgo's IM pages: im.snibgo.com
voldemarz
Posts: 2
Joined: 2014-09-26T04:18:34-07:00
Authentication code: 6789

Re: How to multiply an image by a constant ?

Post by voldemarz »

Thanks, it works. I just achieved the same result using -color-matrix. It seems though there is something wrong with the examples here http://www.imagemagick.org/Usage/color_ ... lor-matrix

It doesn't work if colon is placed after input file name as in the example, the convert tool just keeps reading input from console (Windows 8.1).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to multiply an image by a constant ?

Post by snibgo »

The usage pages show Bash commands, not Windows commands. See http://www.imagemagick.org/Usage/windows/

For example, use double-quotes for Windows:

Code: Select all

convert rose: -color-matrix "6x1: 0,0,0,0,0,1"  matrix_red_max.png
Or, I believe better, don't use spaces so you don't need quotes:

Code: Select all

convert rose: -color-matrix 6x1:0,0,0,0,0,1  matrix_red_max.png
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to multiply an image by a constant ?

Post by anthony »

voldemarz wrote:Thanks, it works. I just achieved the same result using -color-matrix. It seems though there is something wrong with the examples here http://www.imagemagick.org/Usage/color_ ... lor-matrix

It doesn't work if colon is placed after input file name as in the example, the convert tool just keeps reading input from console (Windows 8.1).
The colon ':' in "rose:" is part of the name of a built in image. for a file you would not have a colon unless you are specifying the image type of the file. EG: "type:filename"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply