Package net.sourceforge.jiu.color.data
Class NaiveHistogram3D
- java.lang.Object
-
- net.sourceforge.jiu.color.data.NaiveHistogram3D
-
- All Implemented Interfaces:
Histogram3D
public class NaiveHistogram3D extends Object implements Histogram3D
A class for a three-dimensional histogram that allocates oneintvalue per counter at construction time. This means that a histogram with 8 bits for each channel will have 28 + 8 + 8 = 224 = 16,777,216 int values, making it 64 MB large.- Author:
- Marco Schmidt
-
-
Constructor Summary
Constructors Constructor Description NaiveHistogram3D(int numValues)Creates a histogram with the same number of values for all three dimensions.NaiveHistogram3D(int numValuesLevel1, int numValuesLevel2, int numValuesLevel3)Creates a histogram
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Sets all counters to zero.intgetEntry(int index1, int index2, int index3)Returns the counter value of (index1, index2, index3).intgetMaxValue(int index)Returns the maximum index value for one of the three indexes.intgetNumUsedEntries()Returns the number of used entries (those entries with a counter value larger than zero).voidincreaseEntry(int index1, int index2, int index3)Increases the counter value of (index1, index2, index3) by one.voidsetEntry(int index1, int index2, int index3, int newValue)Sets the counter value of (index1, index2, index3) to newValue.
-
-
-
Constructor Detail
-
NaiveHistogram3D
public NaiveHistogram3D(int numValuesLevel1, int numValuesLevel2, int numValuesLevel3) throws IllegalArgumentException, OutOfMemoryErrorCreates a histogram
-
NaiveHistogram3D
public NaiveHistogram3D(int numValues) throws IllegalArgumentException, OutOfMemoryErrorCreates a histogram with the same number of values for all three dimensions. Calls(int, int, int), repeatingnumValuesthree times.- Parameters:
numValues- the number of levels for all three dimensions- Throws:
IllegalArgumentExceptionOutOfMemoryError
-
-
Method Detail
-
clear
public void clear()
Sets all counters to zero.- Specified by:
clearin interfaceHistogram3D
-
getEntry
public int getEntry(int index1, int index2, int index3) throws IllegalArgumentExceptionReturns the counter value of (index1, index2, index3).- Specified by:
getEntryin interfaceHistogram3D- Parameters:
index1- first of the three values forming the threedimensional indexindex2- second of the three values forming the threedimensional indexindex3- three of the three values forming the threedimensional index- Returns:
- the counter value of the desired index
- Throws:
IllegalArgumentException- could be (read: need not necessarily) be thrown if the index formed by the arguments is invalid
-
getMaxValue
public int getMaxValue(int index) throws IllegalArgumentExceptionDescription copied from interface:Histogram3DReturns the maximum index value for one of the three indexes.- Specified by:
getMaxValuein interfaceHistogram3D- Throws:
IllegalArgumentException- if the index formed by the arguments is invalid
-
getNumUsedEntries
public int getNumUsedEntries()
Returns the number of used entries (those entries with a counter value larger than zero).- Specified by:
getNumUsedEntriesin interfaceHistogram3D- Returns:
- number of non-zero counter values
-
increaseEntry
public void increaseEntry(int index1, int index2, int index3) throws IllegalArgumentExceptionIncreases the counter value of (index1, index2, index3) by one. This method can easily be implemented by the one-linersetEntry(index1, index2, index3, getEntry(index1, index2, index3) + 1);However, this method is expected to be faster in some contexts.- Specified by:
increaseEntryin interfaceHistogram3D- Parameters:
index1- first of the three values forming the threedimensional indexindex2- second of the three values forming the threedimensional indexindex3- three of the three values forming the threedimensional index- Throws:
IllegalArgumentException- could be (read: need not necessarily) be thrown if the index formed by the arguments is invalid
-
setEntry
public void setEntry(int index1, int index2, int index3, int newValue) throws IllegalArgumentExceptionSets the counter value of (index1, index2, index3) to newValue.- Specified by:
setEntryin interfaceHistogram3D- Parameters:
index1- first of the three values forming the threedimensional indexindex2- second of the three values forming the threedimensional indexindex3- three of the three values forming the threedimensional indexnewValue- the counter value that is assigned to the argument index- Throws:
IllegalArgumentException- could be (read: need not necessarily) be thrown if the index formed by the first three arguments is invalid
-
-