Page 1 of 1

possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-18T12:49:46-07:00
by fmw42
I am not sure if this is bug or if I misunderstand -tint. However, the results for tinting a gradient with primary and secondary colors seems inconsistent.

Why are the results for yellow and cyan different in location of the gradient than for magenta (and red, green, blue)?



convert grad.png -fill red -tint 30 red.png
Image

convert grad.png -fill green -tint 30 green.png
Image

convert grad.png -fill blue -tint 30 blue.png
Image

convert grad.png -fill magenta -tint 30 magenta.png
Image

convert grad.png -fill yellow -tint 30 yellow.png
Image

convert grad.png -fill cyan -tint 30 cyan.png
Image

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-18T13:40:25-07:00
by magick
The -tint image requires an RGB image. We'll look into supporting CMYK.

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-18T16:15:29-07:00
by fmw42
The input was not CMYK. It is PNG which does not support CMYK.

The input image was grayscale created by

convert -size 256x256 gradient: -rotate 90 grad.png
Image


Note that with green the darker part extends further to the right than in the red and blue results

Here are the same commands with -colorspace sRGB added and using rgb colors:


convert grad.png -colorspace sRGB -fill "rgb(255,0,0)" -tint 30 red2.png
Image

convert grad.png -colorspace sRGB -fill "rgb(0,255,0)" -tint 30 green2.png
Image

convert grad.png -colorspace sRGB -fill "rgb(0,0,255)" -tint 30 blue2.png
Image

convert grad.png -colorspace sRGB -fill "rgb(255,0,255)" -tint 30 magenta2.png
Image

convert grad.png -colorspace sRGB -fill "rgb(255,255,0)" -tint 30 yellow2.png
Image

convert grad.png -colorspace sRGB -fill "rgb(0,255,255)" -tint 30 cyan2.png
Image




I am not sure that -colorspace sRGB changed the colorspace to RGB, so I modified the gradient as follows to get a colorspace RGB gradient. But the results are much the same.


convert grad.png -depth 8 \
\( -clone 0 -fill "gray(1)" -opaque black \) \
\( -clone 0 -fill "gray(2)" -opaque black \) \
-combine -colorspace sRGB grad2.png

Image



convert grad2.png -colorspace sRGB -fill "rgb(255,0,0)" -tint 30 red3.png
Image

convert grad2.png -colorspace sRGB -fill "rgb(0,255,0)" -tint 30 green3.png
Image

convert grad2.png -colorspace sRGB -fill "rgb(0,0,255)" -tint 30 blue3.png
Image

convert grad2.png -colorspace sRGB -fill "rgb(255,0,255)" -tint 30 magenta3.png
Image

convert grad2.png -colorspace sRGB -fill "rgb(255,255,0)" -tint 30 yellow3.png
Image

convert grad2.png -colorspace sRGB -fill "rgb(0,255,255)" -tint 30 cyan3.png
Image



Perhaps the green channel is not being handled properly?


PS I get similar results with


convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,0,0)" -tint 30 red4.png
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,255,0)" -tint 30 green4.png
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,0,255)" -tint 30 blue4.png
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,0,255)" -tint 30 magenta4.png
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,255,0)" -tint 30 yellow4.png
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,255,255)" -tint 30 cyan4.png


convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,0,0)" -tint 30 red4.jpg
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,255,0)" -tint 30 green4.jpg
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,0,255)" -tint 30 blue4.jpg
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,0,255)" -tint 30 magenta4.jpg
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(255,255,0)" -tint 30 yellow4.jpg
convert -size 256x256 gradient: -rotate 90 -colorspace sRGB -fill "rgb(0,255,255)" -tint 30 cyan4.jpg

So it is not a png issue.

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-18T18:45:46-07:00
by magick
To get symmetric results, you need an intensity that is symmetric. Try average instead of the default Rec709Luma:
  • convert grad.png -intensity average -fill "rgb(0,255,0)" -tint 30 tint.png

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-18T19:15:04-07:00
by fmw42
magick wrote:To get symmetric results, you need an intensity that is symmetric. Try average instead of the default Rec709Luma:
  • convert grad.png -intensity average -fill "rgb(0,255,0)" -tint 30 tint.png

That does not quite seem to work for me -- the C,M,Y do not seem quite the same as the R,G,B. The C,M,Y have a broader dark region than the R,G,B. At least that is the way it looks to me.

But see further down my fx experiment

convert grad.png -intensity average -fill "rgb(255,0,0)" -tint 30 tint_red.png
Image

convert grad.png -intensity average -fill "rgb(0,255,0)" -tint 30 tint_green.png
Image

convert grad.png -intensity average -fill "rgb(0,0,255)" -tint 30 tint_blue.png
Image

convert grad.png -intensity average -fill "rgb(255,255,0)" -tint 30 tint_yellow.png
Image

convert grad.png -intensity average -fill "rgb(0,255,255)" -tint 30 tint_cyan.png
Image

convert grad.png -intensity average -fill "rgb(255,0,255)" -tint 30 tint_magenta.png
Image



However: If I use -fx and try to simulate the tint formula (though it may not be correct), all look similar even with a normal rec709luma gradient.

fact=0.3 (hoping it corresponds to tint 30)

convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
\( -clone 0 \) \
-delete 0 -combine fx_red.png
Image

convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
-delete 0 -combine fx_green.png
Image

convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_blue.png
Image


convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
-delete 0 -combine fx_yellow.png
Image

convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_cyan.png
Image

convert -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_magenta.png
Image

The above is kind of what I expected from -tint with respect to symmetry among all the colors tested

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-19T08:00:39-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.7-7 Beta available by sometime tomorrow. Thanks.

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-19T11:38:04-07:00
by fmw42
Thanks.

I believe this is a closer implementation (though it does not seem to matter with or without the -intensity). I forgot the multiply by u

But I would be curious what the exact fx expression is that matches the corrected -tint.



fact=0.3

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
\( -clone 0 \) \
-delete 0 -combine fx_red2.png
Image

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
-delete 0 -combine fx_green2.png
Image

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_blue2.png
Image

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
-delete 0 -combine fx_yellow2.png
Image

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_cyan2.png
Image

convert -intensity average -size 256x256 gradient: -rotate 90 \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
\( -clone 0 \) \
\( -clone 0 -fx "u+$fact*u*(1-(4.0*((u-0.5)*(u-0.5))))" \) \
-delete 0 -combine fx_magenta2.png
Image

Re: possible bug -tint 6.8.7.6 Q16 Mac OSX

Posted: 2013-11-20T11:19:46-07:00
by fmw42
This seems to be fixed now in 6.8.7.7 beta.

All the test images have their color distributions the same. Thanks