1 2 Previous Next 49 Replies Latest reply on Oct 7, 2011 6:12 AM by rob day

# Getting a greyscale value from the Eyedropper?

Today, someone asked me how to pick up a gray value with the Eyedropper, and get a grayscale (K-only) color value in an otherwise CMYK document.

As we all know, the eyedropper tool gives RGB colorspace back, at least for raster images. So, fine, I get a gray rectangle with RGB:

Now, how can I convert this to grey? I can't really find a reasonable way. Converting to CMYK gives me 35/28/28/0, which is useles.

Converting to L*ab gives me 69/0/0, which seemed promising, but also is kind of a dead end:

In Illustrator, I have the choice for greyscale:

So, short of ducking over to Illustrator, is there a reasonable way to get the equivalent gray value out of InDesign?

I suppose one could write a script that uses math...but color math is hard, and it is easy to screw it up.

Of course, there is some amusing color science irony that if one tries to go the other way, say, from 39.0% K to RGB, one gets 169/171/174 . I suppose it relates to color profiles and whatnot (as does why Illustrator and InDesign may not end up with the same numbers).

Anyhow, any tips or convenient workarounds?

Sure would be nice if ID had "Grayscale" as an option like Illustrator...

• ###### 1. Re: Getting a greyscale value from the Eyedropper?

I generally just go to separations preview and read it...

• ###### 2. Re: Getting a greyscale value from the Eyedropper?

Pick up the color and change to lab. The "l" value can be used, just invert it. (i.e. "l" reading is 22, gray equivalent would be 78)

• ###### 3. Re: Getting a greyscale value from the Eyedropper?

Jeffrey: Would you believe I tried that? At least in my color profiles,

that does not look anywhere close.

• ###### 4. Re: Getting a greyscale value from the Eyedropper?

John, after a few more tests, my suggested lab method is flawed.

• ###### 5. Re: Getting a greyscale value from the Eyedropper?

Without a grayscale space there's no way to get a color managed  conversion to grayscale inside of ID.

With AppleScript I can go get the conversion from Photoshop. This takes the RGB fill of the current selection and gets the grayscale conversion in PS based on the current PS Color Settings:

activate

set {a, b, c} to color value of fill color of selection

set theColor to {class:RGB color, red:a, green:b, blue:c}

set gs to convert color theColor to grayscale

set k to gray value of gs

end tell

set properties of fill color of selection to {space:CMYK, color value:{0, 0, 0, k}}

display dialog "CMYK 0|0|0|" & k

end tell

Don't know if you can do something similar with JavaScript

edit: I added a line to update the selection fill with the converted CMYK color

• ###### 6. Re: Getting a greyscale value from the Eyedropper?

This version keeps you in ID. It isn't a color managed conversion but comes close if your doc profile is SWOP:

set space of fill color of selection to LAB

set {a, b, c} to color value of fill color of selection

set myKvalue to (100 - a) * 1.15

if myKvalue is greater than 100 then

set myKvalue to 100

end if

set space of fill color of selection to CMYK

set color value of fill color of selection to {0, 0, 0, myKvalue}

end tell

• ###### 7. Re: Getting a greyscale value from the Eyedropper?

Hey Rob:

For simplicity, etc., I really do like Peter's idea of using the Sep. Preview. I always forget about that choice. Though that makes me think that the eyedropper's RGB limitation is even dumber than I thought, and really ID should be able to eyedrop grayscale. Perhaps I'll file something.

Don't know if you can do something similar with JavaScript

You can, but it's more of a pain, since you can't use a language feature to dispatch a message to two different apps (well, not without using applescript inside your javascript). So instead you need to use Bridgetalk to send a message to Photoshop. It's enough of a pain that I'm not going to offer you the 10-second version of your script in Javascript. And I'm on a Mac anyhow, it's just a philosophical preference for JS over AS...

This version keeps you in ID. It isn't a color managed conversion but comes close if your doc profile is SWOP:

Oof. That's definitely what I meant by "I suppose one could write a script that uses math...but color math is hard, and it is easy to screw it up."

I suppose you're a domain expert in a way that I'm not,but you suggest converting to Lab, and then setting K = (100-L)*1.15, right?

It's not obvious to me why 1.15 is the right magic value, and while I'm not insisting that you have to "show your work," it'd make me a lot more comfortable to know.

But honestly, I think I'm going to avoid the color math and just use the sep. preview; oh, and maybe file a feature request. But thanks.

• ###### 8. Re: Getting a greyscale value from the Eyedropper?

For simplicity, etc., I really do like Peter's idea of using the Sep. Preview.

I missed Peter's post—sep preview does give you the file's exact gray value. For image files the eyedropper gives you correct values for Lab, CMYK, RGB images but not for grayscale because it doesn't exist. I've been wishing out loud for a grayscale space since ID2, but something tells me it won't happen. The missing grayscale space creates a number of display problems, but no output problems so it's probably not a priority.

1.15 is indeed a magic number. Reversing the L value gets you a linear tonal scale, so multiplying by some number imitates a curve—something like what you would get with Photoshop's 20% dot gain grayscale profile.

• ###### 9. Re: Getting a greyscale value from the Eyedropper?

Rob:

1.15 is indeed a magic number.

I know it's a magic number, that wasn't my question! What I said was, "It's not obvious to me why 1.15 is the right magic value, and while I'm not insisting that you have to 'show your work,' it'd make me a lot more comfortable to know." I.e. where does it come from?

Reversing the L value gets you a linear tonal scale, so multiplying by some number imitates a curve—something like what you would get with Photoshop's 20% dot gain grayscale profile.

Wait, what?

If I have a linear scale (blue line) and I multiply it by a constant (1.15) I get a linear scale back (red line). This is obvious since y_blue = mx + b and so y_red = (mx + b)*1.15 = (1.15m)x+1.15b, so I get a line with a slope that's 1.15 times my original slope and a slightly bigger y intercept:

• ###### 10. Re: Getting a greyscale value from the Eyedropper?

where does it come from?

Trial and error. As I mentioned in post 6 there's no CM here.

I was about to say a color managed conversion from neutral RGB colors to a black only CMYK is impossible, but remembered I use this profile to convert a grayscale image to black only CMYK and it will also work for neutral RGB:

http://www.zenodesign.com/forum/MaxBlack.zip

With the profile assigned to your doc, AdobeRGB 169|169|169 converts to 0|0|0|40.75—the same conversion you would get in PS converting from AdobeRGB to 20% Dot Gain grayscale.

So this simple script works:

set docprofile to CMYK profile of active document

set CMYK profile of active document to "MaxBlack"

set space of fill color of selection to CMYK

set CMYK profile of active document to docprofile

end tell

• ###### 11. Re: Getting a greyscale value from the Eyedropper?
Trial and error. As I mentioned in post 6 there's no CM here.

Oh. Ha ha, that's what I get for failing to define my terms.

In my mind (twisted and warped as it is!), if it's trial and error, it is not "magic." A magic number is one that is special; is a unique and [mostly] unchanging constant; and while its derivation may be complicated and confusing, is somehow generally accepted. For instance: "the ratio of a circle's diameter to its circumference is the magic number pi." I realize that no reasonable person might have picked my definition of magic, though.

It's also funny because the 1.15 you select is quite similar to the 1.16 (well, 116) that appears as a constant all over the Lab color space wikipedia page:

### CIE XYZ to CIE L*a*b* (CIELAB) and CIELAB to CIE XYZ conversions

#### The forward transformation

\begin{align} L^\star &= 116 f(Y/Y_n) - 16\\ a^\star &= 500 \left[f(X/X_n) - f(Y/Y_n)\right]\\ b^\star &= 200 \left[f(Y/Y_n) - f(Z/Z_n)\right] \end{align}

...

#### The reverse transformation

The reverse transformation is most easily expressed using the inverse of the function f above:

\begin{align} Y &= Y_n f^{-1}\left(\tfrac{1}{116}\left(L^*+16\right)\right)\\ X &= X_n f^{-1}\left(\tfrac{1}{116}\left(L^*+16\right) + \tfrac{1}{500}a^*\right)\\ Z &= Z_n f^{-1}\left(\tfrac{1}{116}\left(L^*+16\right) - \tfrac{1}{200}b^*\right)\\ \end{align}

but actually I guess it's just a coincidence since they're dividing by 116 and you're multiplying by 1.15; and we're ignoring the f(t) function, which is not insignificant. Not that XYZ tristimulus colors are CMYK colors -- in fact really they're a transformation away from RGB colors!

Oof.

• ###### 12. Re: Getting a greyscale value from the Eyedropper?

but actually I guess it's just a coincidence

Definitely a coincidence. If you are trying to find a K value that has the same appearance as a neutral RGB value there isn't a single constant that would get you there. If you change profiles the number wouldn't work and it probably doesn't work over the entire tonal scale anyway.

The maximum black profile trick does get you the correct conversion of RGB to Dot Gain 20% grayscale, but doesn't necessarily get you the same appearance because the black only CMYK color you get is previewed through your document's CMYK profile not a Dot Gain 20% grayscale profile. If your doc is all black/grayscale you could assign the MaxBlack profile and it would work. Otherwise Sep Preview is the way to go.

• ###### 13. Re: Getting a greyscale value from the Eyedropper?

Definitely a coincidence. If you are trying to find a K value that has the same appearance as a neutral RGB value there isn't a single constant that would get you there

For the record, that's not the actual goal -- the goal is to get the K value out of a CMYK PDF with nothing on the C/M/Y plates. The only reason RGB comes up here is because ID uses an RGB preview as a proxy to sample the dots.

(I'm sure you knew this, but I didn't want to confuse everyone else reading along who is already confused...all 198 of them! Whoa, 198 views? Geeze, that seems high. I thought this would be a lot more esoteric.)

I've marked Peter's answer as Correct. Nice that you can upgrade from Helpful to Correct in the new forum software.

• ###### 14. Re: Getting a greyscale value from the Eyedropper?

I'm not sure it really deserves a "correct" tag since it doesn't answer the question of how to use the eyedropper. It was really more of an observation than a suggested workaround.

• ###### 15. Re: Getting a greyscale value from the Eyedropper?

While I think we should have a long debate about the merits of correctness here, because that is what dreary Saturday mornings are for, I believe it answers this question that I posed initially:

Is there a reasonable way to get the equivalent gray value out of InDesign?

Philosophically, I think if one answer stands above the rest, even if it is only 90% correct, it's probably better to flag it as Correct. In this case, I originally had yours and Rob's marked as Helpful, but after further consideration (and Rob's comments on yours), I think it's useful to distinguish yours from his.

Perhaps more to the point, it seems unlikely anyone is going to come up with answer that it more correct.

• ###### 16. Re: Getting a greyscale value from the Eyedropper?

Short debate. You win.

• ###### 17. Re: Getting a greyscale value from the Eyedropper?

I'm a bit late to this party, but how's this?

var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
color.colorValue = [averageValue,averageValue,averageValue];
}
var calcValue = 100 - (averageValue/255 * 100);
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];

• ###### 18. Re: Getting a greyscale value from the Eyedropper?

Harbs:

I'm a bit late to this party, but how's this?

if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] +         color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
}
var calcValue = averageValue/255 * 100;
color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];


Err. That does a terrible job! But what I didn't think of and just thought to try (by misreading your post!) is 100-(rgb/255). Which actually seems pretty good:

You can still see differences though. I think Peter's answer is still the best so far though...

• ###### 19. Re: Getting a greyscale value from the Eyedropper?

I was tired when I wrote the script.

I fixed the code to what it should have been...

• ###### 20. Re: Getting a greyscale value from the Eyedropper?

Well, any differences are InDesign's fault!

• ###### 21. Re: Getting a greyscale value from the Eyedropper?

Harbs. wrote:

Well, any differences are InDesign's fault!

RGB black is much darker than 100K. Are you guys taking that into account?

• ###### 22. Re: Getting a greyscale value from the Eyedropper?

I think InDesign has dot gain in the calculations.

I'm trying to come up with an equation which will work to compensate across the spectrum...

This seems to work reasonably well when K is over 50%:

var fudgeFactor = -12;
var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
}
var calcValue = 100 - (averageValue/255 * 100);
calcValue-=fudgeFactor;
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

var inverseValue = Math.abs(calcValue-100);
color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];

• ###### 23. Re: Getting a greyscale value from the Eyedropper?

If the aim really is to get the output K value there's no way.

Depending on what profiles are embedded the same original gray value can produce any number of RGB eyedropper values. So below is a doc with US Sheetfed Uncoated assigned with it's profile policy set to Preserve. The top PDF has no embedded profile (it gets the doc's profile). The bottom PDF has US SWOP Coated embedded and the profile is preserved. When I eyedropper the 40% patch from each image I get very different values 168|174|174 for the uncoated version, and 153|153|153 for the bottom version. In both images Sep Preview has the output as 0|0|0|40:

• ###### 24. Re: Getting a greyscale value from the Eyedropper?

Grayscale image values are put on the black plate and output unchanged (ID ignores grayscale profiles). Their previews are adjusted by the assigned CMYK profile, which could be anything. Even if you could come up with an equation that converts the RGB to the output K value, it would only work for one profile.

• ###### 25. Re: Getting a greyscale value from the Eyedropper?

Like Rob says, there's no perfect method, but this is pretty darn good:

var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
}
var calcValue = 100 - (averageValue/255 * 100);
calcValue+=(calcValue/5.5);
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

var inverseValue = Math.abs(calcValue-100);
color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];

• ###### 26. Re: Getting a greyscale value from the Eyedropper?

When I ran it on my test the top returned 38, the bottom returned 47—not very useful in either case if you are looking for 40%

• ###### 27. Re: Getting a greyscale value from the Eyedropper?

And dot gain is a non-linear curve. You get more at larger dot size and less at smaller sizes (well, up to a point -- at some point the dots will merge and they all become 100%).

• ###### 28. Re: Getting a greyscale value from the Eyedropper?

My equation is non-linear.

It's not perfect, but eyeballing various shades in InDesign seemed to give good results.

I wonder how good the Grayscale option in Illustrator is. Rob, do you care to run tests there?

• ###### 29. Re: Getting a greyscale value from the Eyedropper?

Harbs. wrote:

My equation is non-linear.

I didn't look closely before, but I take it the non-linearity comes from this line:

calcValue+=(calcValue/5.5);

How did you arrive at 5.5

• ###### 30. Re: Getting a greyscale value from the Eyedropper?

The results are the same out of Illustrator.

Remember the question here is can you get the grayscale output value from the eyedropper (the value that shows in Sep Preview)? ID doesn't apply any dot gain to grayscale images, the values go unchanged on to the black plate. When the grayscale is inside of a PDF and the PDF includes a CMYK profile the preview depends on the embedded CMYK profile, or the ID document CMYK profile if there's no profile included. You won't be able to come up with a working formula because the sampled RGB values are dependent on the assigned CMYK profile.

• ###### 31. Re: Getting a greyscale value from the Eyedropper?

Peter Spier wrote:

How did you arrive at 5.5

Trial and error...

• ###### 32. Re: Getting a greyscale value from the Eyedropper?

rob day wrote:

The results are the same out of Illustrator.

Same as what? Same as each other (i.e. accurate), or similar to the results of my script (i.e. inaccurate)?

• ###### 33. Re: Getting a greyscale value from the Eyedropper?

So why has nobody yet asked the obvious question?

If ID KNOWS the correct grayscale numbers (and CMYK numbers, for that matter, in CMYK images), which it clearly does in seps preview, WHY is it not possible to pick those up directly from placed rasters?

• ###### 34. Re: Getting a greyscale value from the Eyedropper?

Oh. I'm sure it's possible.

You interested in attempting to write a plugin to do this?

There's just very little exposed to scripting about placed images...

Harbs

• ###### 35. Re: Getting a greyscale value from the Eyedropper?

In my post 23 test I placed the grayscale in ID and exported the page as PDF/X-1a (no profile) and then as PDF/X-4 (embed profiles). Then I placed both files in an ID doc with Preserve Embedded as the policy. The two placed PDFs have different RGB proxies even though the gray output values are identical. If I do the same out of Illustrator I get the same results.

Here's my test:

http://www.zenodesign.com/forum/gspdf.zip

• ###### 36. Re: Getting a greyscale value from the Eyedropper?

Oh. I'm sure it's possible.

Not until ID has a grayscale space.

• ###### 37. Re: Getting a greyscale value from the Eyedropper?

rob day wrote:

Not until ID has a grayscale space.

Well, it depends what you are expecting. Peter was asking why you can't get the values of the separations preview. I'm sure it's possible to get those values. If you want proper color-managed values, the yes, you are right it's not possible until InDesign supports gray profiles...

Harbs

• ###### 38. Re: Getting a greyscale value from the Eyedropper?

My question was directed at the Grayscale option in the colors panel in Illustrator.

John was looking for the same functionality in InDesign.

I just tested, and the results of my script were superior to the results in Illustrator.

It looks like Illustrator just does a straight conversion of RGB values to K -- like my first attempt at my script.

The Grayscale option in Illustrator has no color adjustment whatsoever.

• ###### 39. Re: Getting a greyscale value from the Eyedropper?

WHY is it not possible to pick those up directly from placed rasters?

It does for CMYK and RGB images.

The eye dropper returns 100 Black when I sample a directly placed grayscale image. PDFs could have any number of color objects and embedded profiles, so I'm guessing that's why it's an RGB proxy.

Also, the eyedropper/PDF proxy relationship isn't reliable in anyway making a script impossible. It looks like the eyedropper picks up RGB values based on the color management setting when the PDF is placed, but the preview of an untagged PDF changes with the document's profile assignment. So below I've placed the PDF into a doc with US Sheetfed Uncoated assigned, switched the assignment to US Sheetfed Coated, sampled the 40% patch, and the RGB value isn't even close:

1 2 Previous Next