net.sourceforge.jiu.color.quantization
Class RGBColor
java.lang.Object
net.sourceforge.jiu.color.quantization.RGBColor
- RGBIndex
public class RGBColor
extends java.lang.Object
Encapsulates a single color from RGB (red, green, blue) color space plus a frequency counter.
Each of the three RGB samples is of type int.
Also stores a counter of type int.
private int | counter - Stores how many times this colors appears in a certain image.
|
private int[] | samples - The intensity values that make up the color.
|
RGBColor(int red, int green, int blue) - Creates an instance of this class and initializes it to the given
intensity values.
|
RGBColor(int red, int green, int blue, int counter) - Creates an instance of this class and initializes it to the given
intensity values.
|
int | compareTo(RGBColor c, int sortOrder) - Compares this color to the argument color, using the sortOrder argument (which is one of the
three index values defined in
RGBIndex .
|
static double | computeDistance(int r1, int g1, int b1, int r2, int g2, int b2) - For two RGB triplets (r1, g1, b1) and (r2, g2, b2) this will return
the distance between those colors in RGB color space.
|
boolean | equals(Object obj) - Compares this color with another instance of RGBColor and returns true
if all intensity values are equal, false otherwise.
|
int | getCounter()
|
int | getSample(int index)
|
String | toString()
|
counter
private int counter
Stores how many times this colors appears in a certain image.
samples
private int[] samples
The intensity values that make up the color.
RGBColor
public RGBColor(int red,
int green,
int blue)
Creates an instance of this class and initializes it to the given
intensity values.
The internal color counter is set to zero.
RGBColor
public RGBColor(int red,
int green,
int blue,
int counter)
Creates an instance of this class and initializes it to the given
intensity values.
Also sets the internal color counter to the given parameter.
compareTo
public int compareTo(RGBColor c,
int sortOrder)
Compares this color to the argument color, using the sortOrder argument (which is one of the
three index values defined in
RGBIndex
.
That way, the two sample values for one component (e.g. red if sortOrder == INDEX_RED) are
compared.
c
- the color to which this color is comparedsortOrder
- the component used for the comparison
- relation between this color and the argument color
computeDistance
public static double computeDistance(int r1,
int g1,
int b1,
int r2,
int g2,
int b2)
For two RGB triplets (r1, g1, b1) and (r2, g2, b2) this will return
the distance between those colors in RGB color space.
equals
public boolean equals(Object obj)
Compares this color with another instance of RGBColor and returns true
if all intensity values are equal, false otherwise.
getCounter
public int getCounter()
getSample
public int getSample(int index)
toString
public String toString()