Android Question Get Nearest Color

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

i get colors rgb with getpixel function. my problem is i analyzed picture file (jpg) with many x,y points.

its gave me alot of colors rgb with very close to each other.

is there function give some tolerance or find nearest color for make color list less than current.

for example ;
248,254,252 ' it is like light gray
248,254,253 ' it is like light gray
248,254,254 ' it is like light gray

replace with this three nearest color 248,254,252

i know that it is possible with .net platform . i use it

any help
 

NJDude

Expert
Licensed User
Longtime User
You could try this:
B4X:
r1 = 248
g1 = 254
b1 = 252
 
r2 = 248
g2 = 254
b2 = 254
 
Msgbox(Sqrt(Power((r2 - r1),2) + Power((g2 - g1),2) + Power((b2 - b1),2)), "")
The smaller the number, the nearer it is.
 
Last edited:
Upvote 0
Top