Package net.sourceforge.jiu.color.io
Class HistogramSerialization
java.lang.Object
net.sourceforge.jiu.color.io.HistogramSerialization
This class has static methods for saving histograms.
Text files (actually, any PrintStream, so you could write to standard output
using
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
save
(Histogram1D hist, PrintStream out) Saves a one-dimensional histogram to a text output stream.static void
save
(Histogram3D hist, PrintStream out) Saves a three-dimensional histogram to a text output stream.
-
Constructor Details
-
HistogramSerialization
private HistogramSerialization()
-
-
Method Details
-
save
Saves a one-dimensional histogram to a text output stream.- Parameters:
hist
- the histogram that will be written to a streamout
- the stream that will be written to
-
save
Saves a three-dimensional histogram to a text output stream.- Parameters:
hist
- the histogram to be savedout
- the output stream where the histogram will be saved to
-