public class HistogramSerialization
extends java.lang.Object
System.out
) are used to store the histogram information.
Hint: When creating a PrintStream
object yourself, set the autoFlush
argument of the constructor to false
.
You should also wrap your OutputStream
object into a BufferedOutputStream
object.
That may speed things up.
A simple format is used for storing the histograms. The first line holds the number of components. This would be 3 for a three-dimensional histogram, e.g.for RGB color images, or 1 for a one-dimensional histogram as used for a grayscale image.
Next, as many lines as dimensions follow. Each line holds the maximum value allowed for that component. The minimum value is always zero. Typically, the maximum values are all the same, e.g. 255 for each component of a 24 bit RGB truecolor image.
Following these header lines is the actual histogram. Each line holds a non-zero counter value for one pixel. The counter is always the last integer value in the line.
Example:
34 0 55 4033For the histogram of an RGB24Image, this would mean that the pixel red=34, green=0, blue=55 occurs 4033 times.
0 2For the histogram of any one channel image, this means that the value 0 occurs twice.
Modifier | Constructor and Description |
---|---|
private |
HistogramSerialization() |
Modifier and Type | Method and Description |
---|---|
static void |
save(Histogram1D hist,
java.io.PrintStream out)
Saves a one-dimensional histogram to a text output stream.
|
static void |
save(Histogram3D hist,
java.io.PrintStream out)
Saves a three-dimensional histogram to a text output stream.
|
public static void save(Histogram1D hist, java.io.PrintStream out)
hist
- the histogram that will be written to a streamout
- the stream that will be written topublic static void save(Histogram3D hist, java.io.PrintStream out)
hist
- the histogram to be savedout
- the output stream where the histogram will be saved to