public static int saturation(int color)
    {
        int red = (color & RED_MASK) >> 16; 
        int green = (color & GREEN_MASK) >> 8;
        int blue = (color & BLUE_MASK);

        int saturation = 0;
        if(!( red == green && green == blue)) {

            int max = red;
            int min = red;
            List<Integer> d = Arrays.asList(red,green,blue);
            for(int c : d) {
                if(c > max) max = c;
                if(c < min) min = c;
            }

            saturation = 255 * (max - min) / (max + min); //also try 255 * (M - m) / (511 - (M + m))
        }

        
        return saturation;
    }