no.hiof.imagepr.features
Class Histogram

java.lang.Object
  extended byno.hiof.imagepr.features.Histogram

public class Histogram
extends java.lang.Object

A Histogram represents the histogram of an IntensityImage. The histogram of an image contains the amount of pixels of each value in the interval 0-255. (This class could easily be extended to accept other intervals of pixel values).

This class is adopted to version 2 of the API by Per-Olav Rus�s

Author:
David Ellingsen, Roar Hauger, Bj�rnar Henriksen, Nils-Edvard Lileng Holene, Ola Oddvar Myhren Juliussen

Constructor Summary
Histogram(short[][] matrix)
          Set the matrix with pixel values and calculate the histogram.
 
Method Summary
 double[] calcCumNormHistogram()
          Calculate the cumulative normalized histogram.
 double[] calcNormHistogram()
          Calculate and return the normalized histogram for the image.
 void draw(boolean cumulative, java.awt.Graphics g, int x0, int y0, int height, int space)
          Draw the histogram of the image.
 IntensityImage drawHistogram(boolean cumulative)
          Draw the histogram of the image on an IntensityImage.
 IntensityImage drawHistogram(boolean cumulative, int height, int space)
          Draw the histogram of the image on an IntensityImage with a given height and spacing between the bars.
 int[] getHistogram()
          Get the histogram as an integer array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Histogram

public Histogram(short[][] matrix)
Set the matrix with pixel values and calculate the histogram.

Parameters:
matrix - The matrix
Method Detail

getHistogram

public int[] getHistogram()
Get the histogram as an integer array. Each element contains the number of pixels in the image of the value equal to the index of the element.

Returns:
The histogram

calcNormHistogram

public double[] calcNormHistogram()
Calculate and return the normalized histogram for the image. The normalized histogram is represented by an array of 256 doubles. Each element gives the relative amount of pixels in the image of the value equal to the index of the element.

Returns:
The normalized histogram.

calcCumNormHistogram

public double[] calcCumNormHistogram()
Calculate the cumulative normalized histogram. In this histogram element with index i gives the relative number of pixels having value less than or equal to i.

Returns:
The cumulative normalized histogram.

drawHistogram

public IntensityImage drawHistogram(boolean cumulative)
Draw the histogram of the image on an IntensityImage.

Parameters:
cumulative - Set to true for cumulative histogram.

drawHistogram

public IntensityImage drawHistogram(boolean cumulative,
                                    int height,
                                    int space)
Draw the histogram of the image on an IntensityImage with a given height and spacing between the bars.

Parameters:
cumulative - Set to true for cumulative histogram.
height - The heigth of the histogram.
space - The space between the bars of the histogram.
Returns:
An IntensityImage containing the image of the histogram.

draw

public void draw(boolean cumulative,
                 java.awt.Graphics g,
                 int x0,
                 int y0,
                 int height,
                 int space)
Draw the histogram of the image.

Parameters:
g - The Graphics object to draw the histogram on.
x0 - The horizonal coordinate of the histogram.
y0 - The vertical coordinate of the histogram.
height - The heigth of the histogram.
space - The space between the bars of the histogram.