# How to find a single RGB color triplet from an antialiased raster image?

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

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.

• does it really matter? Commented May 16 at 3:32
• ^^^ 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

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 =
hextocol[colors]
``````

and running this results in:

``````{"#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).

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).

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.

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. Commented May 18 at 18:42
• @Andrew is your original a JPEG image? 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. Commented May 18 at 19:51
• 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