Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Determine Get Retrieve Color Range RGB Pixel
black #000000 navy #000080 blue #0000FF green #008000 teal #008080 lime #00FF00 aqua #00FFFF maroon #800000 purple #800080 olive #808000 gray #808080 silver #C0C0C0 red #FF0000 fuchsia #FF00FF yellow #FFFF00 white #FFFFFFI would guess you can define a red range like this?
From (red-((red-silver)/2)) To (red+((fuchsia-red)/2)-1)But better read there ...
An RGB triplet (r,g,b) represents the three-dimensional coordinate of the point of the given color within the cube or its faces or along its edges. This approach allows computations of the color similarity of two given RGB colors by simply calculating the distance between them: the shorter the distance, the higher the similarity.
Having a digital 8-bit per channel RGB triplet, each item of red, green, blue has an integer value ramge from 0 to 255 resp. a hex value range from x00 to xFF.
As I understand Wikipedia's description of the three-dimensional Euclidean space, the distance between two points in this space can be evaluated by the formula
Euclidean_Distance_RGB = Sqrt ( (r1 - r2) ** 2 + (g1 - g2) ** 2 + (b1 - b2) ** 2 )Here comes a small WinBatch script to demonstrate the calculation (my first attempt to this theme ever). How to interprete the results is left to you.
; (c)Detlev Dalitz.20091121. ; In the three-dimensional Euclidean RGB space ... ; the distance between two points (r1, g1, b1) and (r2, g2, b2) is ... ; Euclidean_Distance_RGB = Sqrt ( (r1 - r2) ** 2 + (g1 - g2) ** 2 + (b1 - b2) ** 2 ) #DefineFunction udfEuclideanDistanceRGB (intR1, intG1, intB1, intR2, intG2, intB2) Return Sqrt ((intR1 - intR2) ** 2 + (intG1 - intG2) ** 2 + (intB1 - intB2) ** 2) #EndFunction ; 1: pure red color. intColor1R = 255 intColor1G = 0 intColor1B = 0 ; 2: red looking color. intColor2R = 255 intColor2G = 0 intColor2B = 32 ; 3: red looking color. intColor3R = 255 intColor3G = 64 intColor3B = 32 ; 4: color with red amount. intColor4R = 128 intColor4G = 64 intColor4B = 32 fltColorDistance_1_2 = udfEuclideanDistanceRGB (intColor1R, intColor1G, intColor1B, intColor2R, intColor2G, intColor2B); 32.000000 fltColorDistance_1_3 = udfEuclideanDistanceRGB (intColor1R, intColor1G, intColor1B, intColor3R, intColor3G, intColor3B); 71.554175 fltColorDistance_1_4 = udfEuclideanDistanceRGB (intColor1R, intColor1G, intColor1B, intColor4R, intColor4G, intColor4B); 145.770367 fltColorDistance_2_3 = udfEuclideanDistanceRGB (intColor2R, intColor2G, intColor2B, intColor3R, intColor3G, intColor3B); 64.000000 fltColorDistance_4_3 = udfEuclideanDistanceRGB (intColor4R, intColor4G, intColor4B, intColor3R, intColor3G, intColor3B); 127.000000 Exit
Article ID: W17924
Filename: Determine Color Range.txt
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38