0

I've been trying to find the nearest known color like

dim nearestcolor as color= bitmap.getpixel(point.x,point.y)
if nearestcolor.toknowncolor = color.red then 

end if

I need something like that, I need to find if nearestcolor is looking like red

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85

2 Answers2

0

Not sure if this is your answer but you could think of the rgb values of your colour as points in an x, y,z plane and use geometry to calculate the distance between your known colours and the colour of the pixel. http://freespace.virgin.net/hugo.elias/routines/r_dist.htm

Gavin
  • 491
  • 3
  • 5
0
Sub HoldCol()
    Dim colC, CC&
' all thanks to Mr Chip Pearson
    colC = Array("UNNAMED", _
                 "Black", "White", "Red", "Bright Green", "Blue", "Yellow", "Pink", "Turquoise", _
                 "Dark Red", "Green", "Dark Blue", "Dark Yellow", "Violet", "Teal", "Gray 25%", "Gray 50%", _
                 "UNNAMED", "UNNAMED", "UNNAMED", "UNNAMED", "UNNAMED", "UNNAMED", "UNNAMED", "UNNAMED", _
                 "Dark Blue", "Pink", "Yellow", "Turquoise", "Violet", "Dark Red", "Teal", "Blue", _
                 "Sky Blue", "Light Turquoise", "Light Green", "Light Yellow", "Pale Blue", "Rose", "Lavender", "Tan", _
                 "Light Blue", "Aqua", "Lime", "Gold", "Light Orange", "Orange", "Blue Gray", "Gray 40%", _
                 "Dark Teal", "Sea Green", "Dark Green", "Olive Green", "Brown", "Plum", "Indigo", "Gray 80%")
    'cc  as collor to look at
    ' or use fill color to color cell

    CC = [m4].Interior.Color

    [m5].Interior.Color = CC    '[m4]  ' put color in cell   'out of need
    [m6] = [m5].Interior.ColorIndex    ' let vba find the nearest color index
    [n6] = CStr(colC([m6]))    ' get its name
    [m7].Interior.ColorIndex = [m6]
    ' may be offset 1 if you are using option base 1
    ' gets only close as you can see in cell "M7"
'use variable names   in reality

End Sub
kero
  • 10,647
  • 5
  • 41
  • 51
HarryS
  • 1