• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Incorrect internal Lab values

Engaged ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

I'm having trouble returning the expected values from Photoshop's LAB colour values 

 

In RGB colour space

var myRGB = [146, 163, 173]; // LAB 60 94 -60

var lab = RGB_to_LAB(myRGB);

lab[0] = round_up(lab[0], 0);
lab[1] = round_up(lab[1], 0);
lab[2] = round_up(lab[2], 0);

alert(lab)   // 66, -5, -7 
// should be 60 94 -60


function RGB_to_LAB(RGB)
{
  var colour = new SolidColor;

  colour.rgb.red   = RGB[0];
  colour.rgb.green = RGB[1];
  colour.rgb.blue  = RGB[2];

  return [
    colour.lab.l,
    colour.lab.a,
    colour.lab.b
    ]
}


function round_up(num, prec)
{
  prec = Math.pow(10, prec);
  return Math.ceil(num * prec) / prec;
}

 

I *assuming* the values displayed in the Color Picker are rounded up.

color_picker.png

 

I'm sure it's got to do with gamma/ color settings, I'm using sRGB IEC61966-2.1

How do I compensate for any discrepancies?

I'm having to feed colours into a colour range function which only works with LAB colours.  Nice.

 

 

 

 

TOPICS
Actions and scripting , Windows

Views

285

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 2 Correct answers

LEGEND , Dec 16, 2021 Dec 16, 2021
(sc = new SolidColor).rgb.hexValue = 'ff00ff'; lab = sc.lab; while
(!isNaN(lab[zro = lab.reflect.properties[0]])) {alert(lab[zro]); delete lab[zro]}

Votes

Translate

Translate
LEGEND , Dec 17, 2021 Dec 17, 2021

Change content of alert to:

Math.round(zro < 'l' ? (lab[zro] + 128) / 255 * 256 - 128 : lab[zro])

Votes

Translate

Translate
Adobe
Engaged ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

Sorry that first line should be:

 

var myRGB = [255, 0, 255]; / 60 94 -60

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 ,
Dec 16, 2021 Dec 16, 2021

Copy link to clipboard

Copied

(sc = new SolidColor).rgb.hexValue = 'ff00ff'; lab = sc.lab; while
(!isNaN(lab[zro = lab.reflect.properties[0]])) {alert(lab[zro]); delete lab[zro]}

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 ,
Dec 17, 2021 Dec 17, 2021

Copy link to clipboard

Copied

That's close. The value came out as 

60.16845703125, 92.6736744371094, -60.763671875

// rounded up 
61, 93, -60 // should be 60 94 -60

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 ,
Dec 17, 2021 Dec 17, 2021

Copy link to clipboard

Copied

Change content of alert to:

Math.round(zro < 'l' ? (lab[zro] + 128) / 255 * 256 - 128 : lab[zro])

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
Advocate ,
Dec 28, 2022 Dec 28, 2022

Copy link to clipboard

Copied

LATEST

That seems to be just a part of the correction script. This link has more info and the other components as well

http://www.rags-int-inc.com/PhotoTechStuff/ColorCalculator/AdobeMath.html

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