Package net.sourceforge.jiu.color.quantization

# Class RGBColorList

java.lang.Object
net.sourceforge.jiu.color.quantization.RGBColorList

All Implemented Interfaces:
  `RGBIndex`

public class RGBColorList extends Object implements RGBIndex
Holds an array of `RGBColor` objects.

Author:
  Marco Schmidt

## Field Summary

Fields
Modifier and Type
Field
Description
`private RGBColor[]`
`list`
`private final int`
`numEntries`

### Fields inherited from interface net.sourceforge.jiu.data.RGBIndex

`INDEX_BLUE, INDEX_GREEN, INDEX_RED`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`RGBColorList(int NUM_ENTRIES)`
Creates a color list with room for a fixed number of entries.
``
`RGBColorList(Histogram3D hist)`
Creates a new list and initializes it with the argument histogram.

## Method Summary

Modifier and Type
Method
Description
`int[]`
`findExtrema(int i1, int i2)`
In a given interval of the list this method searches for the color axis that has the largest distribution of values.
`RGBColor`
`getColor(int index)`
Returns an `RGBColor` object from this list, given by its zero-based index value.
`int`
`getNumEntries()`
Returns the number of color objects in this list.
`void`
`sortByAxis(int index1, int index2, int axis)`
Sorts an interval of the array of colors by one of the three components (RGB).
`void`
`sortByCounter(int index1, int index2)`
Sorts an interval of the array of colors by their counters.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### list

private RGBColor[] list

### numEntries

private final int numEntries

## Constructor Details

### RGBColorList

private RGBColorList(int NUM_ENTRIES)
Creates a color list with room for a fixed number of entries.

Parameters:
  `numberOfEntries` - the number of entries in the new list (must be larger than zero)
Throws:
  `IllegalArgumentException` - if the argument is smaller than one

### RGBColorList

public RGBColorList(Histogram3D hist)
Creates a new list and initializes it with the argument histogram. All values from the histogram with a counter larger than zero will be added to the list (which will include all colors that appear at least once in the image on which the histogram was created).

Parameters:
  `hist` - the histogram from which the list will be initialized
Throws:
  `IllegalArgumentException` - thrown if no histogram entry has a non-zero counter

## Method Details

### findExtrema

public int[] findExtrema(int i1, int i2)
In a given interval of the list this method searches for the color axis that has the largest distribution of values. Returns a pair of int values; the first value is the component (0, 1 or 2), the second value is the difference between the minimum and maximum value found in the list. Only checks colors from index i1 to i2 of the list.

### getColor

public RGBColor getColor(int index)
Returns an `RGBColor` object from this list, given by its zero-based index value.

Parameters:
  `index` - zero-based index into the list; must be smaller than `getNumEntries()`
Returns:
  the color object

### getNumEntries

public int getNumEntries()
Returns the number of color objects in this list.

Returns:
  number of colors in the list

### sortByAxis

public void sortByAxis(int index1, int index2, int axis)
Sorts an interval of the array of colors by one of the three components (RGB).

Parameters:
  `index1` - the index of the first element in the interval
  `index2` - the index of the last element in the interval
  `axis` - the color component by which the interval is to be sorted, `RGBIndex.INDEX_RED`, `RGBIndex.INDEX_GREEN` or `RGBIndex.INDEX_BLUE`

### sortByCounter

public void sortByCounter(int index1, int index2)
Sorts an interval of the array of colors by their counters.

Parameters:
  `index1` - the index of the first element in the interval
  `index2` - the index of the last element in the interval