When using imagemagick to apply curves (convert -function), the output differs from the output when I'm using a curves adjustment layer in Photoshop. What is the reason for this difference?

I'm using 16 bit Tiff images in ProphotoRGB as base files. In Photoshop I create a curves adjustment layer and apply the "Increase Contrast" settings. Then I read the x,y coordinates from the points on the Graph (0,0; 37,16; ...) and converted them to match between 0 and 1, i.e. I divided them by 255.

Next I used im_fx_curves -c from the imagemagick docs to retreive the coefficients of the function: http://www.imagemagick.org/Usage/color_mods/#curves

Now, in theory, I should get exactly the same image with the function convert -function Polynomial coefficients as with the curves adjustment layer in Photoshop. However the result quite differs, e.g. the shadows are noticeably brighter. What could be the reason for that? And more important: How could I "correct" this difference to get same results?

One suspect is the color space. Might there be another step because of ProphotoRGB? (Please note, I'm not trying to convert to sRGB at this moment)

Edit: changes as requested following

  1. The input is ProphotoRGB, the Output is ProphotoRGB, both 16bit, can't see an error here
  2. The exact command line: convert "%%G" -function Polynomial "-3.786,5.767,-1.543,0.562,0" "%ConvertTarget%\%%~nG.tif"
  3. The coordinates in Photoshop: 0,0 38,17 212,231 231,250 255,255
  4. The coordinates to coefficients conversion: ./im_fx_curves -c 0,0 0.149019607843137,0.0666666666666667 0.831372549019608,0.905882352941176 0.905882352941176,0.980392156862745 1,1 > coefficients.txt
  5. The histograms:

Before > Photoshop curves > IM Curves


  • 2
    \$\begingroup\$ Please include complete command line in question. \$\endgroup\$ May 21, 2016 at 21:03
  • 1
    \$\begingroup\$ And also, all the relevant histograms... \$\endgroup\$
    – yo'
    May 21, 2016 at 21:47
  • \$\begingroup\$ Changes made to original post. Thanks for the comments. \$\endgroup\$
    – ptmr.io
    May 23, 2016 at 6:37
  • \$\begingroup\$ Please change the mode of histogram from "Colors" to "RGB" (or I do not know how it is actually called). \$\endgroup\$ May 23, 2016 at 12:15
  • \$\begingroup\$ Changed histogram as requested. \$\endgroup\$
    – ptmr.io
    May 24, 2016 at 6:56

2 Answers 2


You definitely need to ensure that the curves processing happens in exact same color spaces. What you describe may be caused by different tone response curves (for example using Prophoto vs. sRGB)

Even then there might be differences:

  • Photoshop apparently uses perceptual processing in some areas of the program where some other apps prefer simpler math

  • It is possible that for example IM first linearizes the data before applying the curves while PS works with existing tone response curve given by the profile you chose for editing. In other words, the implementations may differ

  • \$\begingroup\$ The color spaces/profiles still match, double checked that. If PS has an other implementation, is there a possibility to mimick that in Imagemagick? \$\endgroup\$
    – ptmr.io
    May 24, 2016 at 11:21
  • \$\begingroup\$ Did you try StackOverflow? \$\endgroup\$
    – MirekE
    May 24, 2016 at 13:59
  • \$\begingroup\$ wouldn't it be bad to post a duplicate, especially when it's about image manipulation and I already posted on the photo part of SE? \$\endgroup\$
    – ptmr.io
    May 25, 2016 at 10:03

When I implemented curves in my own image viewer, I first just did it on the RGB values. It annoyed me that it seemed to screw up the color balance, especially when increasing the brightness with the curve. Then I made the option to decide what the LUT should apply to. E.g. Luminance of the YUV transform.

I found that luminance is better for brightening and rgb brightness is better for darkening. See examples below. The high saturation colours keep their perceptual color after the curve is applied in the upper middle and lower right image, while the upper right and lower middle gets weird, oversaturated.

Adobe uses a more advanced perceptual model, based on human perception research, which might be difficult for other software to mimick.

lut decrease lut increase

Decrease brightness: Orig | RGB LUT | YUV lut

Increase brightness. : Orig | RGB LUT | YUV lut

LUT compare


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.