TeamCode/src/main/java/org/firstinspires/ftc/teamcode/libraries/CameraLib.java
public static int dominantColor(int pix) {
            final float n = 1.5F;    // dominance factor threshold
            int domClr = 0;     // default is white (i.e. shades of gray)
            if (red(pix)>n*green(pix) && red(pix)>n*blue(pix))
                domClr = 1;     // red
            else
            if (green(pix)>n*red(pix) && green(pix)>n*blue(pix))
                domClr = 3;     // green
            else
            if (blue(pix)>n*red(pix) && blue(pix)>n*green(pix))
                domClr = 5;     // blue
            else
            if (blue(pix)>n*red(pix) && green(pix)>n*red(pix))
                domClr = 4;     // cyan
            else
            if (blue(pix)>n*green(pix) && red(pix)>n*green(pix))
                domClr = 6;     // magenta
            else
            if (red(pix)>n*blue(pix) && green(pix)>n*blue(pix))
                domClr = 2;     // yellow
            // if it has no discernible hue, encode its gray level 0-7
            if (domClr == 0) {
                float value = red(pix)*0.2f + green(pix)*0.7f + blue(pix)*0.1f; // 0..255
                domClr = (int)(value / 32 + 7);  // return Value discretized to 8 levels (7..14)
            }
            return domClr;
        }
// return "dominant color" of an RGB pixel if it has one (or white if it doesn't)
return "dominant color" of an RGB pixel if it has one (or white if it doesn't)
return " dominant color " of an RGB pixel if it has one ( or white if it doesn ' t )
public static int dominantColor(int pix) {
            final float n = 1.5F;    
            int domClr = 0;     
            if (red(pix)>n*green(pix) && red(pix)>n*blue(pix))
                domClr = 1;     
            else
            if (green(pix)>n*red(pix) && green(pix)>n*blue(pix))
                domClr = 3;     
            else
            if (blue(pix)>n*red(pix) && blue(pix)>n*green(pix))
                domClr = 5;     
            else
            if (blue(pix)>n*red(pix) && green(pix)>n*red(pix))
                domClr = 4;     
            else
            if (blue(pix)>n*green(pix) && red(pix)>n*green(pix))
                domClr = 6;     
            else
            if (red(pix)>n*blue(pix) && green(pix)>n*blue(pix))
                domClr = 2;     
            if (domClr == 0) {
                float value = red(pix)*0.2f + green(pix)*0.7f + blue(pix)*0.1f; 
                domClr = (int)(value / 32 + 7);  
            }
            return domClr;
        }
public static int dominantColor ( int pix ) { final float n = 1.5F ; int domClr = 0 ; if ( red ( pix ) > n * green ( pix ) && red ( pix ) > n * blue ( pix ) ) domClr = 1 ; else if ( green ( pix ) > n * red ( pix ) && green ( pix ) > n * blue ( pix ) ) domClr = 3 ; else if ( blue ( pix ) > n * red ( pix ) && blue ( pix ) > n * green ( pix ) ) domClr = 5 ; else if ( blue ( pix ) > n * red ( pix ) && green ( pix ) > n * red ( pix ) ) domClr = 4 ; else if ( blue ( pix ) > n * green ( pix ) && red ( pix ) > n * green ( pix ) ) domClr = 6 ; else if ( red ( pix ) > n * blue ( pix ) && green ( pix ) > n * blue ( pix ) ) domClr = 2 ; if ( domClr == 0 ) { float value = red ( pix ) * 0.2f + green ( pix ) * 0.7f + blue ( pix ) * 0.1f ; domClr = ( int ) ( value / 32 + 7 ) ; } return domClr ; }
return "dominant color" of an RGB pixel if it has one (or white if it doesn't)
return " dominant color " of an RGB pixel if it has one ( or white if it doesn ' t )
// dominance factor threshold // default is white (i.e. shades of gray) // red // green // blue // cyan // magenta // yellow // if it has no discernible hue, encode its gray level 0-7 // 0..255 // return Value discretized to 8 levels (7..14)