My (scientific) collaborator sent me swatches of the three colors ("red," "green," and "blue") shown below.

larger version

Unfortunately, it is a raster image and the lines are antialiased, so when I zoom in and use a color picker to find the color of each line, each line is comprised of many different color values. I can no longer contact my collaborator to ask him for the RGB color triplets he used to generate said antialiased lines.

I wish to find:

  1. a single RGB triplet that approximates the color of the "red" line
  2. a single RGB triplet that approximates the color of the "green" line
  3. a single RGB triplet that approximates the color of the "blue" line

That way, I can generate plots that look similar to my collaborator's (my plotter can only take one RGB triplet per plot line/curve).

Can someone lend me a hand and tell me how to do this (or please do it for me)? I'm not an artist and don't have fancy software. I have GIMP 2 and Microsoft Paint.

  • 3
    does it really matter?
    – joojaa
    Commented May 16 at 3:32
  • 1
    ^^^ start with red: R255G0B0, green: R0G255B0, and blue: R0G0B255. I think most people will see the correlation even if the colours aren't perfect matches Commented May 16 at 13:19

2 Answers 2


well we can ask mathematica to calculate this for us, lets ignore mostly white:

hextocol = ResourceFunction["ColorToHex"];
img = RemoveAlphaChannel[Import["https://i.sstatic.net/IY6n9AaW.png"]];
mask = Binarize @ Threshold[ColorNegate[img], 0.65];
colors = 
 DominantColors[img, 5, ColorCoverage -> 0.2, Masking -> mask]

and running this results in:

enter image description here

{"#384374", "#398d47", "#8e243e"}

Let me be a bit methodical.

  1. I am zooming in a lot. You could resample the image to a pair number (800%) With anti-alias off (nearest neighbor) this way you keep the pixels and do not average them more.

  2. The image has an additional problem It has clearly been strongly compressed using probably JPG. Jpg compression makes color duller, and darker (red circle).

enter image description here

  1. So we need to choose. The current aliasing (halo) is changing it through white, so I am discarding the lighter colors.

  2. By eye, I am choosing the purest colors marked with the red arrow (first row of numbers). And I am choosing a second option a little darker, less pure but more "solid" (second row of numbers).

enter image description here

  1. But let me be more methodical. I extracted the saturation channel and equalized it so I hidded the less saturated colors... And it turns out I have a decent eye.

enter image description here

The only one that I disagree with is the pink arrow because I feel it is too dark. But still, I listed the values in the previous image (Third row under the blue)

  • That's beautiful work you did -- thank you! In case it's helpful, I've updated my post to include a larger, possibly slightly higher-resolution version of the color swatches (at the bottom of the post). Unfortunately, though, I don't have access to a less compressed version of the image.
    – Andrew
    Commented May 18 at 18:42
  • @Andrew is your original a JPEG image?
    – joojaa
    Commented May 18 at 19:19
  • @joojaa It's an image embedded into a Microsoft Word document (.docx). I don't have the original image as a separate file. Is there a way to determine the format of an embedded image in Word? I'm not aware of any way to do that.
    – Andrew
    Commented May 18 at 19:51
  • 2
    Make a copy of the DOCX, rename the extension to .ZIP and navigate the XML structure until you find the embedded images Commented May 21 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.