Package net.sourceforge.jiu.color.io
Class HistogramSerialization
- java.lang.Object
-
- net.sourceforge.jiu.color.io.HistogramSerialization
-
public class HistogramSerialization extends Object
This class has static methods for saving histograms. Text files (actually, any PrintStream, so you could write to standard output usingSystem.out
) are used to store the histogram information. Hint: When creating aPrintStream
object yourself, set theautoFlush
argument of the constructor tofalse
. You should also wrap yourOutputStream
object into aBufferedOutputStream
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 4033
For the histogram of an RGB24Image, this would mean that the pixel red=34, green=0, blue=55 occurs 4033 times.0 2
For the histogram of any one channel image, this means that the value 0 occurs twice.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
HistogramSerialization()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
save
public static void save(Histogram1D hist, PrintStream out)
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
public static void save(Histogram3D hist, PrintStream out)
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
-
-