battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programming a forum for elite programmers with extreme will power to sharpen theire skills
HomeSearchRegisterLog in
Post new topic   Reply to topic

 upgraded pixel color recognition

Go down 
Moti Barski
Moti Barski

Posts : 445
Join date : 2011-08-02

upgraded pixel color recognition Empty
PostSubject: upgraded pixel color recognition   upgraded pixel color recognition EmptyThu May 07, 2020 1:49 am

refer to the AEye class :

public char getPixelColorV2(int pixel) {
        //  r= red, g = green, b = blue
        int r =;
        int g =;
        int b =;
        //black or white
        if(bigTosmall(r+6,g,r-6)&&bigTosmall(r+6,b,r-6)){if(miner(100,r,g,b)==100){return 'w';}else if(maxer(100,r,g,b)==100){return 'k';}}
        if(maxer(65,r,g,b)==65){return 'k';}
        if(bigTosmall(g,r,b)||bigTosmall(g,b,r)){return 'g';}//green
        if(bigTosmall(b+6,g,b-6)&&(maxer(r,g,b)==r)){return 'r';}//red
        if(bigTosmall(g+6,r,g-6)&&bigTosmall(r+6,g,b)){return  'y';}//yellow
        if(bigTosmall(r,g,b)){return  'o';}//orange
        if(bigTosmall(b+6,g,b-6)&&(bigTosmall(b+6,g,r))){return 'a';}//azure
        if(bigTosmall(b,g,r)||bigTosmall(b,r,g)){return  'b';}//blue
        if(bigTosmall(b+6,r,b-6)&&bigTosmall(r+6,b,g+50)){return 'v';}//violet
        if(bigTosmall(r,b,g)){return 'p';}//pink
        return 'w';//white

tested and working


MB over and out emp it up
Back to top Go down

Posts : 204
Join date : 2012-04-17

upgraded pixel color recognition Empty
PostSubject: Re: upgraded pixel color recognition   upgraded pixel color recognition EmptyThu May 07, 2020 1:57 am

using varargs I can also check if a group of numbers are ranged from
big to small.
something has : if n1<n2<n3
in java you had to do : if (n1<n2)&&(n2<n3))
moreover with more numbers the work increases, so...
kuchiyouse no jutsu :


public static Boolean bigTosmall(int... a)
   for (int i = 0; i < a.length - 1; i++) {
      if (!(a[i] > a[i + 1])) {
            return false;
   return true;

miner returns array minimum
maxer returns int array maximum

top evil kek cool pepe
Back to top Go down
upgraded pixel color recognition
Back to top 
Page 1 of 1

Permissions in this forum:You can reply to topics in this forum
battle programmers alliance :: battle programming alliance :: the LivinGrimoire-
Post new topic   Reply to topicJump to: