|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jiu.color.data.OnDemandHistogram3D
A data class for a three-dimensional histogram, creating counters on demand only, not allocating counters for all possible entries at the beginning. The creation on demand happens to save space. A naive implementation can become huge - for eight bits per component, you'd need 2(8 + 8 + 8) = 224 = 16,777,216 int values (64 MB), while a typical 24 bit image uses only a fraction of these possible colors.
Constructor Summary | |
OnDemandHistogram3D(int maxValue)
Creates a new object of this class with the argument as maximum value for all three index positions and the component values 0, 1, 2. |
|
OnDemandHistogram3D(int maxValue1,
int maxValue2,
int maxValue3)
Creates a new object of this class with maximum values as specified by the arguments and the component values 0, 1, 2. |
|
OnDemandHistogram3D(int maxValue1,
int maxValue2,
int maxValue3,
int c1,
int c2,
int c3)
Creates a new object of this class with specified maximum values for all three indexes. |
Method Summary | |
void |
clear()
Resets all counters to zero. |
int |
getEntry(int index1,
int index2,
int index3)
Returns counter for the argument color given by its red, green and blue intensity. |
int |
getMaxValue(int index)
Returns the maximum index value for one of the three indexes. |
int |
getNumUsedEntries()
Returns the number of entries in this histogram with a counter value of one or higher (in other words: the number of colors that are in use). |
void |
increaseEntry(int red,
int green,
int blue)
Increases the counter for the color given by the arguments red, green and blue. |
void |
setEntry(int r,
int g,
int b,
int newValue)
Sets one counter to a new value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public OnDemandHistogram3D(int maxValue1, int maxValue2, int maxValue3, int c1, int c2, int c3) throws IllegalArgumentException
maxValue1
- the maximum value for the first indexmaxValue2
- the maximum value for the second indexmaxValue3
- the maximum value for the third indexc1
- the top level component for the internal treec2
- the second-level component for the internal treec3
- the third-level component for the internal treepublic OnDemandHistogram3D(int maxValue1, int maxValue2, int maxValue3)
this(maxValue1, maxValue2, maxValue3, 0, 1, 2);
maxValue1
- the maximum value for the first indexmaxValue2
- the maximum value for the second indexmaxValue3
- the maximum value for the third indexpublic OnDemandHistogram3D(int maxValue)
this(maxValue, maxValue, maxValue);
maxValue
- the maximum value for all indexesMethod Detail |
public void clear()
clear
in interface Histogram3D
public int getEntry(int index1, int index2, int index3) throws IllegalArgumentException
getEntry
in interface Histogram3D
index1
- the first value of the indexindex2
- index3
-
IllegalArgumentException
- this exception is thrown if the
argument color is not in the valid interval, i.e., if at least one
of the components is not from 0 .. maxpublic int getMaxValue(int index) throws IllegalArgumentException
Histogram3D
getMaxValue
in interface Histogram3D
IllegalArgumentException
- if the index formed by the arguments is invalidpublic int getNumUsedEntries()
getNumUsedEntries
in interface Histogram3D
public void increaseEntry(int red, int green, int blue) throws IllegalArgumentException
setEntry(red, green, blue, getEntry(red, green, blue) + 1);However, this is not done to avoid slow-downs by accessing a counter value twice.
increaseEntry
in interface Histogram3D
red
- the red intensity of the color entry whose counter will be increasedgreen
- the green intensity of the color entry whose counter will be increasedblue
- the blue intensity of the color entry whose counter will be increased
IllegalArgumentException
- if the argument color is not valid
(minimum is 0, maximum is defined for each component independently)public void setEntry(int r, int g, int b, int newValue) throws IllegalArgumentException
setEntry
in interface Histogram3D
r
- red componentg
- green componentb
- blue componentnewValue
- the new value for the counter
IllegalArgumentException
- if the components do not form a valid color
|
JIU 0.12.0 Homepage | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |