protected RGB GetMostProminentRGB(int degrade, RGB rgbMatch) {
        weights.Clear();
        int count = 0;

        foreach (Pixel pixel in pixels.Values) {
          int weight = pixel.weight * pixel.count;
          count++;

          if (pixel.DoesRgbMatch(rgbMatch)) {
            String key = (pixel.r >> degrade) + "," + (pixel.g >> degrade) + "," + (pixel.b >> degrade);
            if (weights.ContainsKey(key)) {
              weights[key] += weight;
            }
            else {
              weights.Add(key, weight);
            }
          }
        }

        RGB rgb = new RGB();
        rgb.d = degrade;

        foreach (String key in weights.Keys) {
          if (count <= weights[key])
            continue;

          String[] data = key.Split(',');
          rgb.count = count;
          rgb.r = int.Parse(data[0]);
          rgb.g = int.Parse(data[1]);
          rgb.b = int.Parse(data[2]);
        }

        return rgb;
      }
 public bool DoesRgbMatch(RGB rgb) {
   if (null == rgb)
     return true;
   int r = this.r >> rgb.d;
   int g = this.g >> rgb.d;
   int b = this.b >> rgb.d;
   return rgb.r == r && rgb.g == g && rgb.b == b;
 }
 protected override void DoTask() {
   var rgb = helper.GetMostProminentColor(Color.Pixels);
   if (RGB == null || rgb.r > 50 && rgb.g > 50 && rgb.b > 50) { RGB = rgb; }
 }