don't grok -fx

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
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

don't grok -fx

Post by mikmach »

Hello,

I'd like to reduce red tint in areas where red color isn't visually dominant. I've got and idea to play with something like:

abs(b-g) > 0.1 && r-max(b,g) < 0.1 ? r*0.9

Two questions:

- how to implement it with -fx ; for now it responds
convert.exe: unable to parse expression `r' @ error/fx.c/FxEvaluateSubexpression/2307.

- any other idea how to solve that problem?

$ convert -version
Version: ImageMagick 6.9.3-5 Q8 x64 2016-02-20 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: don't grok -fx

Post by snibgo »

The "?" operator is ternary: it needs three expressions. You are missing a colon and the third expression, eg:

Code: Select all

abs(b-g) > 0.1 && r-max(b,g) < 0.1 ? r*0.9 : r
When the first expression is true, the result is r*0.9. When it is false, the result is r. (Of course, put whatever you need for the third expression.)
snibgo's IM pages: im.snibgo.com
mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: [SOLVED] don't grok -fx + reduce red tint in non red areas

Post by mikmach »

Thank you very much. I've improved my command. Pure RGB path was nonsense, solution which works perfectly for me:

Code: Select all

convert file.tif -channel H -fx "hue < 0.93 && hue > 0.07 && saturation > 0.15 ? r * 0.98 : r" +channel file-fx.tif
Post Reply