net.sourceforge.jiu.color.data

Class NaiveHistogram3D

Implemented Interfaces:
Histogram3D

public class NaiveHistogram3D
extends java.lang.Object
implements Histogram3D

A class for a three-dimensional histogram that allocates one int value 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

Field Summary

private int[][][]
data
private int[]
values

Constructor Summary

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

void
clear()
Sets all counters to zero.
int
getEntry(int index1, int index2, int index3)
Returns the counter value of (index1, index2, index3).
int
getMaxValue(int index)
int
getNumUsedEntries()
Returns the number of used entries (those entries with a counter value larger than zero).
void
increaseEntry(int index1, int index2, int index3)
Increases the counter value of (index1, index2, index3) by one.
void
setEntry(int index1, int index2, int index3, int newValue)
Sets the counter value of (index1, index2, index3) to newValue.

Field Details

data

private int[][][] data

values

private int[] values

Constructor Details

NaiveHistogram3D

public NaiveHistogram3D(int numValues)
            throws IllegalArgumentException,
                   OutOfMemoryError
Parameters:
numValues - the number of levels for all three dimensions

NaiveHistogram3D

public NaiveHistogram3D(int numValuesLevel1,
                        int numValuesLevel2,
                        int numValuesLevel3)
            throws IllegalArgumentException,
                   OutOfMemoryError
Creates a histogram

Method Details

clear

public void clear()
Sets all counters to zero.
Specified by:
clear in interface Histogram3D

getEntry

public int getEntry(int index1,
                    int index2,
                    int index3)
            throws IllegalArgumentException
Returns the counter value of (index1, index2, index3).
Specified by:
getEntry in interface Histogram3D
Parameters:
index1 - first of the three values forming the threedimensional index
index2 - second of the three values forming the threedimensional index
index3 - three of the three values forming the threedimensional index
Returns:
the counter value of the desired index

getMaxValue

public int getMaxValue(int index)
            throws IllegalArgumentException
Specified by:
getMaxValue in interface Histogram3D

getNumUsedEntries

public int getNumUsedEntries()
Returns the number of used entries (those entries with a counter value larger than zero).
Specified by:
getNumUsedEntries in interface Histogram3D
Returns:
number of non-zero counter values

increaseEntry

public void increaseEntry(int index1,
                          int index2,
                          int index3)
            throws IllegalArgumentException
Increases the counter value of (index1, index2, index3) by one. This method can easily be implemented by the one-liner setEntry(index1, index2, index3, getEntry(index1, index2, index3) + 1); However, this method is expected to be faster in some contexts.
Specified by:
increaseEntry in interface Histogram3D
Parameters:
index1 - first of the three values forming the threedimensional index
index2 - second of the three values forming the threedimensional index
index3 - three of the three values forming the threedimensional index

setEntry

public void setEntry(int index1,
                     int index2,
                     int index3,
                     int newValue)
            throws IllegalArgumentException
Sets the counter value of (index1, index2, index3) to newValue.
Specified by:
setEntry in interface Histogram3D
Parameters:
index1 - first of the three values forming the threedimensional index
index2 - second of the three values forming the threedimensional index
index3 - three of the three values forming the threedimensional index
newValue - the counter value that is assigned to the argument index