3

I've a picture of an static object correctly balanced and exposed: purple


I would like to sample the nearest color from my own palette of 9 RGB or Lab using Photoshop: enter image description here

Colour palette:

#8270a4
#aa83cb
#62487c
#b8b2fb
#785cb4
#304384
#8372a6
#8270a4
#9faae5
  • break HSB colors to rgb then compare values – Dodie Eslava Dec 27 '17 at 11:22
  • 2
    The problem is that nearest color is not very well defined scientifically so any method you choose may be correct for your application. There is some talk about this in wikipedia. So do you mean to calculate delta E or just eucidiean distance of somekind – joojaa Dec 27 '17 at 11:56
  • I'm not a Photoshop user, but can't you create an action which will use a pixel to create a new 1x1 image and converts it to gif (or similar) with your exact palette? Photoshop (or the format implementation) will figure out which color to chose (is closest) from the palette and replace it with that. – Prinzhorn Dec 27 '17 at 21:26
  • I thing that there is something better for achieving my goal. For example there are scripts able to calculate delta e. Just an example here [GitHub Nearest Color] (github.com/dtao/nearest-color) – Borexino Dec 28 '17 at 7:37
2

You can use this nice script to get your Delta-E values.

You can find it here on pastebin. Just copy the code into notepad, or another text editor like notepad++, and save it out as a .jsx file.

enter image description here

Then, you can run it by dropping the script into your Photoshop scripts folder found under:

C: \ Program Files \ Adobe \ Your Photoshop Version \ Presets

Then:

  1. Load your image in PS
  2. With the Pen tool P draw a perimeter that will correspond to the four corner marks of the chart, starting with the upper left corner, then the lower left, the lower right, the upper right and closing in the upper left like so:

enter image description here

  1. Run the script by going to File>Scripts>color-analysis

enter image description here

  1. The script will run, leaving a series of black circles for each measurement, to show where the measurement was, and what area it occupied.
  2. In the same directory that the evaluated image occupies, a file will be created with the same name as the image processed with _color_analysis.txt added to the end.
  • That is a sizable script ... Is a link to a downloadable version possible? Copying it out of a post may be problematic for some users (not to mention you'll be asked to provide ironclad foolproof instructions: "no you cannot use Word to save it", "no you can't paste this directly into Photoshop", et cetera 😀). – usr2564301 Dec 28 '17 at 22:58
  • @usr2564301Good point, added a Pastebin link! – Ovaryraptor Dec 29 '17 at 15:29
4

Because the nearest color isn't universally accepted concept, I give my own formula.

enter image description here

The problematic color is in the bottom layer and the palette is above it. The palette layer has blending mode = difference. Find the darkest piece in the palette. That's the nearest color. Use the color picker and watch the brightness values. In this case the nearest color is in the middle of your palette.

This method compares the numbers. Subjectively nearest as you see it on your screen can be found by having blending mode = normal in both layers and watching what color in the palette mixes first to the background when you walk further from the display or zoom the image smaller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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