Class IndexImage.Cube

java.lang.Object
org.apache.batik.ext.awt.image.rendered.IndexImage.Cube
Enclosing class:
IndexImage

private static class IndexImage.Cube extends Object
Used to define a cube of the colorspace. The cube can be split approximagely in half to generate two cubes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
     
    (package private) final IndexImage.Counter[][]
    the colors-array is not modified - in fact, all cubes use the same colors-array.
    (package private) int
    the number of color-points in this cube.
    (package private) boolean
     
    (package private) static final int
     
    (package private) int[]
     
    (package private) int[]
     
    (package private) static final int
     
    (package private) static final byte[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cube(IndexImage.Counter[][] colors, int count)
    Define a new cube.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the average color for this cube (no alpha).
    byte[]
    averageColorRGB(byte[] rgb)
    Returns the average color for this cube
    private int[]
    computeCounts(int splitChannel, int c0, int c1)
    create an array, which contains the number of pixels for each point along the splitChannel (between min and max of this cube).
    private boolean
    contains(int[] val)
    check, if the color defined by val[] is inside this cube.
    boolean
    If this returns true then the cube can not be subdivided any further
    private void
    normalize(int splitChannel, int[] counts)
    Adjust (normalize) min/max of this cube so that they span the actual content.
    (package private) IndexImage.Cube
    Splits the cube into two parts.
    (package private) IndexImage.Cube
    splitChannel(int splitChannel, int c0, int c1)
    Splits the image according to the parameters.
    convert the cube-content to String-representation for logging.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • RGB_BLACK

      static final byte[] RGB_BLACK
    • min

      int[] min
    • max

      int[] max
    • done

      boolean done
    • colors

      final IndexImage.Counter[][] colors
      the colors-array is not modified - in fact, all cubes use the same colors-array. The Counter contains the rgb-color-code and the count of pixels with this color.
    • count

      int count
      the number of color-points in this cube.
    • RED

      static final int RED
      See Also:
    • GRN

      static final int GRN
      See Also:
    • BLU

      static final int BLU
      See Also:
  • Constructor Details

    • Cube

      Cube(IndexImage.Counter[][] colors, int count)
      Define a new cube.
      Parameters:
      colors - contains the 3D color histogram to be subdivided
      count - the total number of pixels in the 3D histogram.
  • Method Details

    • isDone

      public boolean isDone()
      If this returns true then the cube can not be subdivided any further
    • contains

      private boolean contains(int[] val)
      check, if the color defined by val[] is inside this cube.
      Parameters:
      val - int[ 3 ] containing r,g,b-values
      Returns:
      true when color is inside this cube
    • split

      Splits the cube into two parts. This cube is changed to be one half and the returned cube is the other half. This tries to pick the right channel to split on.
    • normalize

      private void normalize(int splitChannel, int[] counts)
      Adjust (normalize) min/max of this cube so that they span the actual content. This method is called on the two cubes resulting from a split.
      We search the counts[] from min to max for the leftmost non-null entry. That is the new min. Then we search counts[] from max to min for the rightmost non-null entry. That is the new max.
      This requires, that computeCounts(int, int, int) really computes all counts-values (and does not stop after the necessary number of points for a split is found, as it was done in the previous version of this class).
      Parameters:
      splitChannel - the color used for the last split
      counts - contains the number of points along the splitChannel - only counts[ min .. max ] is valid.
    • splitChannel

      IndexImage.Cube splitChannel(int splitChannel, int c0, int c1)
      Splits the image according to the parameters. It tries to find a location where half the pixels are on one side and half the pixels are on the other.
    • computeCounts

      private int[] computeCounts(int splitChannel, int c0, int c1)
      create an array, which contains the number of pixels for each point along the splitChannel (between min and max of this cube).
      Parameters:
      splitChannel - one of RED | GRN | BLU
      c0 - one of the other channels
      c1 - the third channel
      Returns:
      an int[ 255 ] where only int[ min .. max ] contain valid counts.
    • toString

      public String toString()
      convert the cube-content to String-representation for logging.
      Overrides:
      toString in class Object
      Returns:
      the min/max-boundarys of the rgb-channels and pixel-count of this Cube.
    • averageColor

      public int averageColor()
      Returns the average color for this cube (no alpha).
    • averageColorRGB

      public byte[] averageColorRGB(byte[] rgb)
      Returns the average color for this cube