How to apply the โ€œcurveโ€ settings to the image using r, g, b, matrix?

This will ultimately be used on the iPhone, but this is a general question that can answer the language in an agnostic way.

How to apply a tuning curve (for example, in Photoshop) to an image for saturation, contrast, etc.

After looking at some c, java, and actionscript libraries, I figured out how to implement linear correction, saturation, and brightness using a 5x5 matrix:

1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 

Where I loop over each pixel and change r, g, b, the value of this pixel is based on the above matrix, but how would I translate a 5-point Bezier curve, say, using the Photoshop interface to change r, g, b, a for contrast , saturation, etc. It looks like maybe something like:

 valueWithCGAffineTransform 

can be used?

EDIT: for further reflection, the idea is that, given the 5-point Bezier curve on the 0-255 axis, how can you calculate the X value for any given Y value on the way? Then you can use this information to convert the values โ€‹โ€‹of r, g, b, values โ€‹โ€‹for the image.

+4
source share
1 answer

And the answer is:

Bicubic spline interpolation

It turned out that there was nothing to do with the matrices, but the bezier curves were close.

+3
source

Source: https://habr.com/ru/post/1332972/


All Articles