My engineering project colorblindness!

Hello! I'm currently in 8th grade, I have an engineering project due soon and would love some guides. Mines based on colorblindness, its using RBG as its color detect and can only detect the colors red and green.. Most of the colors aren't red or green lol. Anyways! I don't want to delete my WHOLE CODE.. But I'm trying to make something more accurate, I'm trying to figure out a way to use HSL.. (Hue, saturation, lightness) please! If any tips would be appreciated! My goal is to make state! Please any recommendations, guides, tips leave them down below. Thank you!!

What do you mean? Do you have a color sensor that returns an RGB value?
Explain a little more your project...

Do you need a formula for comparison of how close one color is to another?

Use the sum of the squares of the differences between the corresponding R,G,B components of the two colors.

You might remember this from the Pythagorean Formula.

Read Chapter 21all the way through if you are new to procedures.

If you are able to use extensions, have a look here, selecting the Color category, might be something there that helps...

PuraVidaApps App Inventor Extensions

Try

https://www.sciencebuddies.org/science-fair-projects/project-ideas/CompSci_p075/computer-science/color-detector-app-for-colorblind-people

Thats exactly what ive been using, its just it only detects red and green, i want it to detect all colors

Basically, this is the whole code.. This is just a prototype. I was hoping it would detect more colors. Right now, it only detect red or green, meaning if there was a black remote, it would detect it has “red”.

Ok, not easy to "decode" color names from RGB values.
As you say, should be easier to do it from HSV values.
So you need to convert RGB values to HSV ( not very complex math but it should be done correctly ).
Are you able to do this ( I think so )?

Step-by-Step Conversion Formula ( you have to calculate in sequence R1, B1... )

  1. Normalize RGB values from the range [0, 255] to [0, 1]:
    R1=R/255
    G1=G/255
    B1=B/255

  2. Find the maximum and minimum values among R1, G1, B1:
    Cmax=max (R1,G1,B1)
    Cmin=min (R1,G1,B1)
    Delta =Cmax-Cmin

  3. Calculate Value (V) expressed as percentage 0-100%:
    V=Cmax*100

  4. Calculate Saturation (S) expressed as percentage 0-100%:
    if Cmax=0 S=0
    if Cmax<>0 S=Delta/Cmax

  5. Calculate Hue (H) expressed in degrees 0-360°:
    if Delta=0 H=0
    if Cmax=R1 H=60*(((G1-B1)/Delta) mod 6)
    if Cmax=G1 H=60*(((B1-R1)/Delta) + 2)
    if Cmax=B1 H=60*(((R1-G1)/Delta) + 4)
    (If H < 0, add 360°)* [1, 2]

You have an empty socket.

Also, this is a sorting problem for a two column table:

"Red",123
"Green",123
"Blue",123

Sort in descending order by column 2.

Then select row 1, the biggest.

AI2 has advanced sorting blocks.

All colors is virtually impossible because standard 24-bit RGB has 16,777,216 possible combinations Here are a lot more RGB

You can determine more; here is one way to determine almost any RGB color:

approxColorDetect_colornames2_fixed.aia (1.3 MB). I am sorry, I can’t find where I got the original code I had to modify. :nauseated_face:

1 Like