I am creating kind of color tool and this tool should tell me if color is close to other color, For example:
Color[] colors = new colors[] { Color.FromArgb(0,0,255), Color.FromArgb(0,109,251)};
//colors[0] IS BLUE
//colors[1] IS BRIGHTER BLUE (#006DFB)
bool TheyClose = ColorsAreClose(colors[0],colors[1]); //TRUE BLUE IS CLOSE
//TheyColse Should Be = TURE
How should ColorsAreClose() Function Look?
How about something like this?
(I just guessed at the default threshold, but you should set it to what you want.)
Basically this just computes, on average, whether the three color channels are close enough between the two colors.
This is somewhat subjective and not scientific, I used the following procedure on a project once.
You can calculate the 3-D color space distance as
or you can calculate the hue difference as
A more thorough discussion can be found here.
If talking just about hue you could compare the difference in RGB values separately and if the total difference is under a set amount set by you then you could call them close.
You can start with:
For more info about the hue see: http://en.wikipedia.org/wiki/Hue
A simple way, measeure RGB distance:
Threshold is a constant wit hthe maximum deviation you want to consider close.