• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Question on the Curve adjustment layer

Engaged ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

Hi EveryOne!,

I have another clarification with the Curve adjustment layer

Please find the screenshot for more reference

The first screenshot shows the value in input - 50 & output - 50 and ColorSampler red value is 153

if I change the Curve output value to 79 then ColorSampler red value changed into  84 

Is there is any formula available PS object model?

Or any suggestion to calculate input and output value?

Could anyone please help me to resolve the issue? 

 

-yajiv

 

1.png

 

2.png 

 

 
TOPICS
Actions and scripting

Views

935

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jan 23, 2020 Jan 23, 2020
Make the curves look in the usual form (0-255) and not (0-100) like yours.
Set point [inp: 153, out: 84]
And do not bother yourself. )
 

Votes

Translate

Translate
Adobe
People's Champ ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

There is pretty complicated math

 

 

// standard curve view
// var p = [[0,0], [127, 54], [255,255]];

// yours curve view
var p = [[0,0], [255-Math.round(50/100*255), 255-Math.round(79/100*255)], [255,255]];

     
var pp = curve_array(p);

//alert(curve_array(p).toSource()); 

//alert(pp[153].toSource()); 

alert(pp[153][1]); 

function curve_array(p) 
    {
    try {
        var sd = second_derivative(p);

        var ret = new Array();

        for (var i = 0; i < p.length-1; i++) 
            {
            var cur   = p[i];
            var next  = p[i+1];

            for (var x = cur[0]; x < next[0]; x++) 
                {
                var t = (x-cur[0])/(next[0]-cur[0]);
 
                var a = 1-t;
                var b = t;
                var h = next[0]-cur[0];
 
                var y= a*cur[1] + b*next[1] + (h*h/6)*( (a*a*a-a)*sd[i]+ (b*b*b-b)*sd[i+1] );
 
                ret.push([x,y]); 
                }
            }

        ret.push(p[i]); 

        return ret;
        } 
    catch(e) { alert(e); }
    }

function second_derivative(points) 
    {
    try {
        var n = points.length;
    
        var matrix = new Array(); for (var i = 0; i < n; i++) matrix.push([0,0,0]);
        var result = new Array(); for (var i = 0; i < n; i++) result.push(0);
    
        matrix[0][1]=1;
    
        for (var i = 1; i < n-1; i++) 
            {
            matrix[i][0] = (points[i][0]-points[i-1][0])/6;
            matrix[i][1] = (points[i+1][0]-points[i-1][0])/3;
            matrix[i][2] = (points[i+1][0]-points[i][0])/6;
    
            result[i] = (points[i+1][1]-points[i][1])/(points[i+1][0]-points[i][0]) - (points[i][1]-points[i-1][1])/(points[i][0]-points[i-1][0]);
            }
    
        matrix[n-1][1]=1;
     
        // solving pass1 (up->down)

        for (var i = 1; i < n; i++) 
            {
            var k = matrix[i][0]/matrix[i-1][1];
            matrix[i][1] -= k*matrix[i-1][2];
            matrix[i][0] = 0;
            result[i] -= k*result[i-1];
            }

        // solving pass2 (down->up)
    
        for(var i = n-2; i >= 0; i--) 
            {
            var k = matrix[i][2]/matrix[i+1][1];
            matrix[i][1] -= k*matrix[i+1][0];
            matrix[i][2] = 0;
            result[i] -= k*result[i+1];
            }

        // return second derivative value for each point
    
        var y2 = new Array(n);
        for (var i=0; i < n; i++) y2[i] = result[i]/matrix[i][1];

        return y2;
        } 
    catch(e) { alert(e); }
    }

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

What's source of this amazing function you created - Adobe Documents or something else to share? 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

I found this algorithm a long time ago somewhere on the Internet.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

Dear r-bin,

Thank you so much for your reply. Definitely this is complicated math.

Actually I have input value 153 and the output value is 84.

Now I need to know If I change which output value to get the ColorSample values is 84 

 

3.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

Make the curves look in the usual form (0-255) and not (0-100) like yours.
Set point [inp: 153, out: 84]
And do not bother yourself. )
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 23, 2020 Jan 23, 2020

Copy link to clipboard

Copied

LATEST

hi r-bin,

Thank God.

It is working like a charm :). Your timely help much appreciated. 

Thank you once again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines