-1

I'm trying to work out how to go about creating an on-the-fly simplification of incoming RGB values.

I'm trying to write an android app that utilizes a live camera view and sample colors. I've worked out how to detect and save individual color values, but my aim is to simplify these incoming values using clear ranges.

Example: When we detect Firebrick Red 178,34,34 it would recognize that value within a predefined range defined as Red and will be converted to a simple 255,0,0 upon saving the color.

The app is being put together in unity. If anyone has read a guide that goes over the process that would be ideal, so I can learn what is going on and how it is achieved. I'm stumped.

Thanks in advance for any help.

karthik
  • 528
  • 4
  • 19

1 Answers1

0

So the problem is its hard to define what "red" is. Its not just that different people have different definitions, different cultures also have an effect (some cultures don't consider red and yellow to be different colors. In fact at least one tribal culture still present today has no word for colors. See https://www.sapiens.org/language/color-perception/) on what we think colors are. So doing this is always a best effort type deal.

One simple thing you could do is just do a least difference algorithm. Have a set of color references, and see which one has the smallest delta between it and the color you're looking up. Then treat it as the reference color. That will work- kinda. If you have enough colors in your set to not get too far.

That will only kind of work though- rgb aren't actually equally distinct to the human eye, and some differences matter more than others- its non linear. A difference of 10 in green is more important than in red. A difference of 10 in the range [0,20] may be more or less stark than a difference of 10 in the range [100,120]. If you need this to work really well you may need to talk to someone who's studied color and how the human eye works to come up with a custom algorithm. Having worked on printers once upon a time, we had teams of experts figuring out the definition of digital colors to ink. Its much the same here.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • I'm sticking with rgb values. So red = 225,0,0. People might see that colour differently, but the idea is that the app reads the colour value as the camera sees it and using the range determines that a pale red is still red as its rgb value falls inside the range and it therefore defaults to 225,0,0. The end result isn't being printed, it just gets added as a red count in the app memory. – Jensen Wilder Sep 14 '18 at 15:15
  • @JensenWilder Except no it doesn't. That's the highest intensity of the red channel. That's not "red" because the color "red" isn't well defined. And if you were to show a dozen different varieties of red with some green and blue mixed in, people would actually pick one of those as "red" rather than pure red. That's part of the difficult of what you're trying to do. Which is why if you want to do this well, rather than a bad approximation, you need to talk to people who have studied this. – Gabe Sechan Sep 14 '18 at 15:20
  • Like in the article I posted (which you should read)- there are large groups of people who don't think red and yellow are different colors- and they have no physical defects like color blindness. When you're dealing with a concept that amorphous its very hard to accurately decide what's red, and what's actually another color. – Gabe Sechan Sep 14 '18 at 15:22
  • I understand you. 255,0,0 is not 'Red' according to a human because a human can define many shades as red, but 255,0,0 is the rgb value for red that I am setting as the app's red. The thing you point at is exactly what i want the app to do, make a very simple appraisal of the colour it is pointed at and deciding (like a human would) that whatever shade of red it is looking at is read a recording a rgb value of 255,0,0 regardless. – Jensen Wilder Sep 14 '18 at 15:24
  • The idea is that i don't want the app to see a shade and approximate an rgb value and record that value. I want it to look at a colour, register an rgb value like 178,34,34 and then consult where that value sits in a set range. If it falls within the range i have set for 'red' (between 255,0,0 - 255,204,204) then it ignores the detected rgb value and records the colour as 255,0,0 – Jensen Wilder Sep 14 '18 at 15:28
  • I do totally get that someone using the app will point it at something they think is their idea of red and the rgb value will say it is yellow, but that's a different hurdle. For now i just want rgb value simplification. Once all shades of colours are simplified down to their basic ranges, i can then look into ways of display adjustment for people who are colour blind or might not agree with the colour names used. BUT for now, any human (colour blind or not) that points a digital camera at a colour will get the same rgb coded result. The camera records colours in a universal digital format – Jensen Wilder Sep 14 '18 at 15:33
  • @JensenWilder Right. And my point is that 1: to figure out those ranges, you more or less need a decade in color science. 2: those ranges are culture specific. 3: those ranges depend on the use of the color and context of other colors around it. What you're trying to do is actually really hard. Like thesis level hard. – Gabe Sechan Sep 14 '18 at 15:33
  • No, every human who points a camera at a color will not get the same RGB value. Even thinking that shows you don't understand how digitial cameras work and the number of smoothing algorithms used on top of it, or the effect of light on color. – Gabe Sechan Sep 14 '18 at 15:34
  • An app like Colour grab (colour detector) on an android phone. It records the colours from the image and then i hand it to a friend and they do the same (assuming light and all other variables are the same) and they would get a different value set..... I highly doubt that. Look, i think you're WAY over complicating the idea here. Bringing in culture & colour theory to a question about pointing a camera, recording an approx rgb value and then converting that value into a different value using a range as a key. I can't pull this over into a chat, too low ranked. Thank you for trying to help. – Jensen Wilder Sep 14 '18 at 15:44
  • @JensenWilder And having done this kind of thing professionally, I KNOW that what you're trying to do is going to give really shitty results because you aren't willing to listen. – Gabe Sechan Sep 14 '18 at 15:46
  • I have three ducks. Each duck is a different colour, but they are all ducks. I, as a human, look at those ducks and identify them all as ducks. So i point the app at those ducks and it says DUCK1 DUCK2 DUCK3 because they all have different values. I tell the app to see Duck1-3 as DUCK. Problem solved. The app now looks at DUCK1 and says DUCK. The app doesn't show an image of any ducks to any human, it just records the ducks it sees as DUCK no matter who point it where. If there are errors, that's fine, but my issue is solved. – Jensen Wilder Sep 14 '18 at 15:52
  • @JensenWilder Amusingly your analogy, computer vision, is one of the hardest problems in the world right now. Classifying something as a duck requires a tremendous amount of work by AI specialists. Your really showing your ignorance. – Gabe Sechan Sep 14 '18 at 15:55
  • And if you aren't going to show the data to humans, why is the app doing it? Because it will use that information somehow. And depending on how it uses that information, what those ranges are would be very different. Which is part of why this is a hard problem to solve correctly. – Gabe Sechan Sep 14 '18 at 15:57
  • Just a metaphor to help explain. Really only interested in working out how to make an incoming value be detected inside a range and be output as a set value according to that range. No actual ducks are being viewed. The camera just points at a colour, it registers an RGB value and then that value is checked and converted into a simplified RGB. It doesn't matter what colour the user thinks is scanned or what it means culturally. The incoming light is just recognised by a sensor, given an RGB value and then that is converted. If you can't suggest a way of helping, that's ok. Have a great day. – Jensen Wilder Sep 14 '18 at 16:01
  • If you really just need help comparing something to a range- I suggest looking into an Intro to Programming course. Its literally one if statement with one boolean operator. If you're actually looking for color classification, you're simplifying the problem to a point where useful results are not possible. – Gabe Sechan Sep 14 '18 at 16:04
  • I'm having issues pulling and using live values rather than a static recorded value. – Jensen Wilder Sep 14 '18 at 16:10