JIGL
v1.6

jigl.image
Class Histogram

java.lang.Object
  |
  +--jigl.image.Histogram
Direct Known Subclasses:
CumulativeHistogram

public class Histogram
extends Object

Histogram keeps track of histogram information for an image. The range of histogram's grayscale starts from min() and ends with max(). Supports only GrayImage and RealGrayImage.


Field Summary
protected  float inc
          The "bucket" size for the histogram
protected  float max
          The minimum grayscale value in the histogram
protected  float min
          The maximum grayscale value in the histogram
protected  int[] values
          An array stors the counts for every grayscale
 
Constructor Summary
Histogram(Image image, int interval)
          Creates a Histogram from image.
Histogram(Image image, int interval, int int_min, int int_max)
          Creates a Histogram from image.
Histogram(Image image, int interval, ROI r)
          Creates a Histogram from this image over a Region of Interest.
Histogram(int[] data, int min, int max, int interval)
          Creates a histogram from data.
Histogram(int min, int max, int interval)
          Creates an empty Histogram of size (max-min)/interval + 1.
 
Method Summary
 int count(int value)
          Returns the count at the given value.
 void decrement(int value)
          Decrements at the given value.
 int[] getData()
          Returns a deep copy of the histogram data.
 float inc()
          Returns the incrementation value (interval).
 void increment(int value)
          Increments at the given value.
 int length()
          Returns the size of the data array
 float max()
          Returns the maximum grayscale value for this histogram.
 float min()
          Returns the minimum grayscale value for this histogram.
 void setCount(int value, int count)
          Sets the count for a histogram value.
 RealSignal toSignal()
          Turns this Histogram into a signal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected int[] values
An array stors the counts for every grayscale


min

protected float min
The maximum grayscale value in the histogram


max

protected float max
The minimum grayscale value in the histogram


inc

protected float inc
The "bucket" size for the histogram

Constructor Detail

Histogram

public Histogram(Image image,
                 int interval)
          throws ImageNotSupportedException
Creates a Histogram from image. image can only be GrayImage or RealGrayImage.

Parameters:
image - GrayImage or RealGrayImage to create histogram from.
interval - the "bucket" size for the histogram. A value of 1 with a GrayImage will leave a bucket for every grayscale value between image.max() and image.min().
Throws:
ImageNotSupportedException - if image is null or not a GrayImage or RealGrayImage.

Histogram

public Histogram(Image image,
                 int interval,
                 int int_min,
                 int int_max)
          throws ImageNotSupportedException
Creates a Histogram from image. image can only be GrayImage or RealGrayImage.

Parameters:
image - GrayImage or RealGrayImage to create histogram from.
interval - the "bucket" size for the histogram. A value of 1 with a GrayImage will leave a bucket for every grayscale value between image.max() and image.min().
int_min - minimum value in the histogram
int_max - maximum value in the histogram
Throws:
ImageNotSupportedException - if image is null or not a GrayImage or RealGrayImage.

Histogram

public Histogram(Image image,
                 int interval,
                 ROI r)
          throws ImageNotSupportedException
Creates a Histogram from this image over a Region of Interest. image can only be GrayImage or RealGrayImage.

Parameters:
image - GrayImage or RealGrayImage to create histogram from.
interval - the "bucket" size for the histogram. A value of 1 with a GrayImage will leave a bucket for every grayscale value between image.max() and image.min().
r - defines the interest region in the image.
Throws:
ImageNotSupportedException - if image is null or not a GrayImage or RealGrayImage.

Histogram

public Histogram(int min,
                 int max,
                 int interval)
Creates an empty Histogram of size (max-min)/interval + 1.

Parameters:
min - minimum grayscale value.
max - maximum grayscale value.
interval - grayscale values per bucket.

Histogram

public Histogram(int[] data,
                 int min,
                 int max,
                 int interval)
          throws InvalidArgumentException,
                 NullPointerException
Creates a histogram from data. data must be of length (max-min)/interval + 1. If data is null, a NullPointerException will be thrown.

Parameters:
data - histogram data.
min - minimum grayscale value.
max - maximum grayscale value.
interval - grayscale values per bucket.
Throws:
InvalidArgumentException - if data is not the exact length.
NullPointerException
Method Detail

getData

public int[] getData()
Returns a deep copy of the histogram data.


increment

public void increment(int value)
Increments at the given value. Please note, all calculations are internal. For Example, suppose min=-20 and max=20, if you want to increment the value at -20 then pass in -20 not 0.


decrement

public void decrement(int value)
Decrements at the given value. Please note, all calculations are internal. value should be between min and max.

For Example, suppose min=-20 and max=20, if you want to decrement the value at -20 then pass in -20 not 0.


setCount

public void setCount(int value,
                     int count)
Sets the count for a histogram value. value should be between min and max.


count

public int count(int value)
Returns the count at the given value. Please note, all calculations are internal. For Example, suppose min=-20 and max=20, if you want to get the value at -20 then pass in -20 not 0.


toSignal

public RealSignal toSignal()
Turns this Histogram into a signal. The length of this signal is (int)((max-min)/inc) + 1 and may not be 255.


min

public float min()
Returns the minimum grayscale value for this histogram.


max

public float max()
Returns the maximum grayscale value for this histogram.


inc

public float inc()
Returns the incrementation value (interval).


length

public int length()
Returns the size of the data array


JIGL
v1.6

Submit a bug or feature
Revised in May 2002 by Weiming Liu