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 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 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 Details

    • HistogramSerialization

      private HistogramSerialization()
  • Method Details

    • 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 stream
      out - 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 saved
      out - the output stream where the histogram will be saved to