How does the "Color Picker" convert from RGB to LAB?
I'm writing a script that converts a document to Index color, then makes a selection of each of the colors it was indexed to.
The scripting command to convert to Index Color seems to only accept RGB values for the colors it will use to index to. To select the colors after indexing, Color Range only accepts LAB colors as arguments. So I have to convert my RGB numbers to LAB values to select the same colors I just used to separate. (scripting the wand only accepts locations to click, not directly entering color values through scripting)
If I bring up the "Color Picker" in Photoshop and enter an RGB value I used to separate, and take the LAB values shown in the color picker and put them in the Color Range in the script, it gets a perfect selection every time. No decimal places on the lab values or anything, just using the whole numbers shown, with the Color Range Min and Max values set to the same LAB value shown and the "Fuzziness" set to 0, it fully selects the exact color needed. But I need to script the conversion, I can't manually bring up the Color Picker, it defeats the whole purpose.
Of course, there's a "Convert color" scripting command. When I use this, I get a different LAB value for the same RGB number than the Color Picker gives.
If I change my Color Settings in Photoshop, the Color Picker always returns the same LAB value for the same RGB value, regardless. (Which tells you that what it's doing is fundamentally wrong, because it only makes sense to convert relative values like RGB number to absolute values like LAB numbers through a color profile, and the same RGB equates to different LAB depending on the profile, but that's another story.)
However, changing the color settings in Photoshop does make the scripting command "Convert color" return (often wildly) different LAB values for the same RGB number.
So, does anyone know what the "Color Picker" does to convert an entered RGB value to LAB, so I can attempt to replicate it and get my selections?
I've noticed the values seem to be closest to what I get using Convert Color with an sRGB profile in Color Settings, but not close enough to make it work.
Thanks,
Tom.
