Results 1 to 3 of 3

Thread: How to find closest overall color match

  1. #1
    IV Amateur
    Join Date
    Jan 2017
    32-bit Win XP Pro SP3
    CPU Cores

    Default How to find closest overall color match

    I want to create an image made up of many separate images of similar but different flowers. I want to select the ones that are the closest in overall color to each other. I can do this by just looking at them, but I wondered if there might be a formula I could use to assess them mathematically.

    The IV Histogram feature is handy for finding the average RGB values over a selected area. If I do that for each image, is there a formula that will allow me to calculate some sort of difference between each image and some target?

    In the table below, the target RGB values are in row 4 (100 150 200 = blue). In rows 6-12, various RGB values are compared. Column F has a simple sum of differences. Column G has a sum of the squares of those differences (least squares).

    R/C C D E F G H
    3 R G B Comments
    4 100 150 200 Target values
    5 R G B Sum(Diff) Sum(Sqrs)
    6 100 150 200 0 0 =Target
    7 200 250 0 0 245 Reverse of target
    8 101 151 201 +3 2 +1 each
    9 99 149 199 -3 2 -1 each
    10 101 149 201 +1 2 +1 or -1 each
    11 130 150 200 +30 30 +30 in R
    12 110 160 210 +30 17 +10 each
    13 110 140 210 +10 17 +10 -10 +10

    Row 6 has the target values and both errors are zero.

    Row 7 has R & G at +100 and B at -200, so the sum of differences (F7) is zero. I think this disqualifies that method.

    Rows 8-10 play with differences of 1 (plus or minus).

    Rows 11-13 play with a total difference of 30 either all in one value or spread around.

    The sum of differences seems like a crude measure. The sum of squares seems somewhat better.

    Is there a metric that I can (easily) apply to a collection of images to determine whine ones will appear to the eye as the most similar in overall color?


  2. #2
    Power User j7n's Avatar
    Join Date
    Jun 2006
    IrfanView 4.51
    32-bit Win Server 2003 SP1
    CPU Cores


    This is a hard problem. Looks like you ultimately want to use Lab color space. Maybe the square root of squared differences in a/b is good enough.

    If you move across a basic RGB(HSL) color picker, you can see flat areas on it that change the numbers a lot, but look about the same (for example, large green/cyan area, which would encompass green leaves). But next to it is sharp yellow/red containing a lot of hues. The RGB space is clearly not perceptually uniform.

    230,170,030 ████
    205,230,030 ████ = 65 diff RGB

    075,050,072 ████
    087,-24,081 ████ = 76 diff Lab, 75 Lab (just a/b)

    089,230,030 ████
    030,230,070 ████ = 71 diff RGB

    081,-63,073 ████
    080,-70,061 ████ = 14 diff Lab, 14 Lab (just a/b)

    Maybe crop the middle portion of each picture to crudely separate the subject flower from the background and downsample to 1 pixel to obtain the average color of it. Downsampling should be done in linear gamma.

    Square root of squares is the right method. But the less sophisticated column F method should probably use sum of absolute differences (squaring makes differences positive for you).
    Last edited by j7n; 12.06.2018 at 02:47 PM.

  3. #3
    IV Amateur
    Join Date
    Jan 2017
    32-bit Win XP Pro SP3
    CPU Cores


    Quote Originally Posted by j7n View Post
    This is a hard problem....
    Wow, great information. I think my least squares method is good enough for me for now. But when I get some free time, I want to check out some of the point you make.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts