Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear Experts
 
I need to build a simple application to match a color with a reference standard. to be more specific i will scan a tagged color palate of 36 colors (will serve as a reference standard) I will scan the test color on the same scanner (to avoid inter-device variations). The application should compare the color to the standard palette and alert if there is a match. I wonder if visual studio has a tool to do the color comparison.
 
Thanks in advance
Posted 16-Feb-13 20:32pm
Edited 16-Feb-13 22:38pm
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Color comparison can never be very accurate since there are a number of factors like capability of the scanner to capture brightness, the surrounding light etc involved. You also have factors like alpha correction etc, which although calculable, can make the calculations quite complex.
 
An easy solution, thought not always accurate, is to use hue, saturation and luminosity[^] to compare and contrast pixel colors.
 
Comparing based on HSL is described ^] and it forms an interesting read.
Color Difference[^] provides some explanations.
  Permalink  
v2
Comments
MohamedKamalPharm at 17-Feb-13 5:09am
   
thanks Abhinav S.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

To my knowledge there is no built-in component to do that.
You would have to compare the encoding of the colour at a given point in the test image and find the same colour in an array of the colours in the standard.
 
You might want to look at, Manipulating colors in .NET - Part 1[^], it's not what you want but has some stuff in it that you might find useful.
 
You may also want to consider doing the matching with a colour space such as CIE XYZ[^] rather than using colour models, like .Net RGB, which is harder since conversions between models and spaces is not necessarily easy, however spaces represent real colours, models are just that, models and what colour a given point is depends on the output device.
 
Mike
  Permalink  
Comments
MohamedKamalPharm at 17-Feb-13 5:39am
   
thanks Mike
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

In an article I wrote [^], there is a section on color difference equations. I think the Delta E 2000 equation may be helpful.
  Permalink  
v2
Comments
MohamedKamalPharm at 18-Feb-13 6:02am
   
Excellent Sir !
this is ALMOST what I need
I just need to use my own color palette
How can i use my own set of colors ?
gggustafson at 18-Feb-13 11:13am
   
Note that the delta_e_2000 method expects two CLILab colors for comparison. I am going to assume that your 36 colors are GDI Colors. What I would suggest:
 
1. Convert your 36 GDI colors into a List of Extended_Color, calling the list, say, reference colors. The definition for Extended_Color is found in the article. You will need to convert a GDI Color into an XYZ color and then convert the XYZ color into a CIELab color.
2. Convert the GDI color of interest into a CIELab Color (the algorithm in the article stores the value in a class global variable).
3. The method nearest_known_color_name in the class Known_Colors_Palette provides the way in which the comparison might work. Simply, a record of the "shortest distance" is kept and at its conclusion, the closest matching color name is returned. You can modify the method to return whatever you want. For your case, assuming that the delta_e_2000 method is chosen, the foreach loop can be made quite simple.
 
If you have problems, you can contact me through email (gggustafson at gmail dot com).
 
Please remember to mark one of the answers as the accepted solution.
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,775
1 OriginalGriff 6,696
2 CPallini 5,345
3 George Jonsson 3,599
4 Gihan Liyanage 2,751


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100