Curve in Photoshop

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
alidayvn
Posts: 1
Joined: 2019-08-29T21:59:46-07:00
Authentication code: 1152

Curve in Photoshop

Post by alidayvn » 2019-08-29T22:00:56-07:00

Hey Guys, i try to simulate the curve in photoshop by using MagicWand.
I tried MagickFunctionImageChannel, it works well when i only has two arguments, as below:

double d[4];
d[0] = 0.0; d[1] = 0.0; d[2] = 1.0; d[3] = 0.5;
status = MagickFunctionImageChannel(magick_wand_local,RedChannel,PolynomialFunction,4,d);

but when i try to add another control point to the function, it just messed up, i cant figure out any clue to connect the value in PS curve
to MagickFunctionImageChannel.

Any idea?

User avatar
fmw42
Posts: 25560
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Curve in Photoshop

Post by fmw42 » 2019-08-30T20:39:47-07:00

The polynomial function uses coefficients not control points, I believe. The d values are coefficients of a polynomial, not control points. Sorry, I do not know the MagickWand API and just use the command line.

See https://imagemagick.org/Usage/transform ... polynomial


To emulate a smooth curve, you need to develop software to create a splined lookup table from control points. I have a bash unix shell script that does that called, curves, at my link below. My script does not work in Windows.

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Curve in Photoshop

Post by snibgo » 2019-08-31T06:33:12-07:00

From a number of control points, software can calculate coefficients for a polynomial that passes through those points. But this is usually not a good idea, because the resulting curve is often too extreme.

Instead, we often use a spline to pass through the control points. Gnuplot can do that job. However, there are different criteria and methods for generating splines, and Photoshop's curve is likely to be different to the curve from other software.
snibgo's IM pages: im.snibgo.com

Post Reply