Package net.sourceforge.jiu.color.quantization

Examples of net.sourceforge.jiu.color.quantization.RGBColor


      case(METHOD_REPR_COLOR_AVERAGE):
      {
        int num = index2 - index1 + 1;
        for (int i = index1; i <= index2; i++)
        {
          RGBColor color = list.getColor(i);
          temp[0] += color.getSample(0);
          temp[1] += color.getSample(1);
          temp[2] += color.getSample(2);
        }
        result[0] = (int)(temp[0] / num);
        result[1] = (int)(temp[1] / num);
        result[2] = (int)(temp[2] / num);
        return result;
      }
      case(METHOD_REPR_COLOR_WEIGHTED_AVERAGE):
      {
        long num = 0;
        for (int i = index1; i <= index2; i++)
        {
          RGBColor color = list.getColor(i);
          int counter = color.getCounter();
          temp[0] += color.getSample(0) * counter;
          temp[1] += color.getSample(1) * counter;
          temp[2] += color.getSample(2) * counter;
          num += counter;
        }
        if (num == 0)
        {
          //System.out.println("ERROR IN FINDREPRESENTATIVECOLOR (WEIGHTED AVERAGE): ZERO COUNTER");
          return null;
        }
        result[0] = (int)(temp[0] / num);
        result[1] = (int)(temp[1] / num);
        result[2] = (int)(temp[2] / num);
        return result;
      }
      case(METHOD_REPR_COLOR_MEDIAN):
      {
        RGBColor color = list.getColor((index1 + index2) / 2);
        result[0] = color.getSample(0);
        result[1] = color.getSample(1);
        result[2] = color.getSample(2);
        return result;
      }
      default: throw new IllegalStateException("Unknown method for determining a representative color.");
    }
  }
View Full Code Here


   
    list.sortByAxis(node.getLeftIndex(), node.getRightIndex(), node.getAxisOfLargestDistribution());
    int middleIndex = node.getMiddleIndex();
    int leftIndex = node.getLeftIndex();
    int rightIndex = node.getRightIndex();
    RGBColor color = list.getColor(middleIndex);
    int axis = node.getAxisOfLargestDistribution();
    int medianValue = color.getSample(axis);
    node.setMedianValue(medianValue);
    if (leftIndex == rightIndex)
    {
      throw new IllegalArgumentException("Cannot split leaf that only holds one color. This should never happen.");
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.jiu.color.quantization.RGBColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.