Page 1 of 1

Negative gray gradients

Posted: 2019-06-08T09:24:27-07:00
by snibgo
Tested with IM v7.0.7-28 HDRI on Windows 8.1.

Negative colours are generally allowed and work fine, eg:

Code: Select all

magick xc:gray(-123%) txt:

# ImageMagick pixel enumeration: 1,1,65535,gray
0,0: (-80608)  #000000000000  gray(-123%)
However, they are apparently not allowed in gradient, eg:

Code: Select all

magick -size 10x1 gradient:gray(-123%)-white txt:

magick: unrecognized color `(' @ warning/color.c/QueryColorCompliance/2394.
magick: unrecognized color `123%)' @ warning/color.c/GetColorCompliance/1050.
magick: no images for write '-write' 'txt:' at CLI arg 2 @ error/operation.c/CLINoImageOperator/4792.
I think they should be allowed, and that this is a simple bug.

Re: Negative gray gradients

Posted: 2019-06-08T10:15:19-07:00
by fmw42
What is your expected behavior for any negative color value in HDRI compile?

Re: Negative gray gradients

Posted: 2019-06-08T10:46:26-07:00
by snibgo
I forgot to put "-size 10x1" in the gradient example. Now corrected.

I expect the text output to show a gradient between -123% and white (+100%).

A workaround is to use only positive values in the gradient, then subtract:

Code: Select all

magick -size 10x1 gradient:gray(0)-gray(223%) -evaluate subtract 123% txt:

# ImageMagick pixel enumeration: 10,1,65535,gray
0,0: (-80609.3)  #000000000000  gray(-123.002%)
1,0: (-64371.2)  #000000000000  gray(-98.2241%)
2,0: (-48133)  #000000000000  gray(-73.4463%)
3,0: (-31894.9)  #000000000000  gray(-48.6685%)
4,0: (-15656.8)  #000000000000  gray(-23.8908%)
5,0: (581.298)  #024502450245  gray(0.887004%)
6,0: (16819.4)  #41B341B341B3  gray(25.6648%)
7,0: (33057.5)  #812281228122  gray(50.4426%)
8,0: (49295.6)  #C090C090C090  gray(75.2203%)
9,0: (65533.8)  #FFFEFFFEFFFE  gray(99.9981%)

Re: Negative gray gradients

Posted: 2019-06-08T11:57:44-07:00
by fmw42
For a constant image

Code: Select all

magick xc:gray(-123%) txt:
What color should that be? I am not clear on why you would want negative colors? Can you explain?

Re: Negative gray gradients

Posted: 2019-06-08T12:59:18-07:00
by snibgo
I'm working on a general solution to the recent thread on wavy lines. For this, I will build a displacement map that will interpolate between the wavy lines, but extrapolate beyond them. The wavy lines will be at 0 and 100% of the result, but the image outside the lines might be -30% to +105%. For that, I need a gradient between those values. IM can do this in HDRI, but a syntax bug prevents negative values in "gradient:".

Re: Negative gray gradients

Posted: 2019-06-08T13:32:05-07:00
by fmw42
Thanks. I understand.