Java Doc for Histogram.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » javax » media » jai » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » javax.media.jai 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.media.jai.Histogram

Histogram
public class Histogram implements Serializable(Code)
This class represents a histogram accumulated from a RenderedImage.

A "bin" is a container, where each element stores the total number of pixel samples of an image whose values lie within a given range. A histogram of an image consists of a list of such bins whose range does not overlap with each other (mutually exclusive). For an image that has multiple samples per pixel (multi-banded images), a separate list of bins represents each individual band.

A "low-value" specifies the lowest inclusive pixel value to be checked, and a "high-value" specifies the highest exclusive pixel value to be checked. Therefore, the width of a bin (binWidth) is determined by (highValue - lowValue) / numberOfBins. The range of bin i is defined as from lowValue + i * binWidth inclusive to lowValue + (i + 1) * binWidth exclusive.

The image may have any data type. Its histogram may be accumulated over the entire image, or over a specific region-of-interest (ROI) within the image's bounds. Furthermore, the horizontal and vertical subsampling factors specify the rate of sampling in the two directions, so that only every nth pixel will be counted. This allows the accuracy of the histogram to be traded for the speed of the computation. Of course a subsampling rate of 1 means every pixel will be counted.

The "Histogram" operator generates the histogram data of an image and uses this object to store the final pixel counts. The operator returns an instance of this class when a request is made via the getProperty method for the "histogram" property. The actual bins may be obtained by calling the getBins method.
See Also:   ROI
See Also:   javax.media.jai.operator.HistogramDescriptor




Constructor Summary
public  Histogram(int[] numBins, double[] lowValue, double[] highValue)
     Constructor.

This constructor should be used when numBins, lowValue, and/or highValues are different for each band of the image.

public  Histogram(int[] numBins, double[] lowValue, double[] highValue, int numBands)
     Constructor.

This constructor should be used when numBins, lowValue, and/or highValues may be different for each band of the image.

public  Histogram(int numBins, double lowValue, double highValue, int numBands)
     Constructor.

Method Summary
public  voidclearHistogram()
     Resets the values of all bins to zero.
public  voidcountPixels(Raster raster, ROI roi, int xStart, int yStart, int xPeriod, int yPeriod)
     Accumulates the histogram of the pixels within a specific region-of-interest (ROI) by counting them based on the indicated horizontal and vertical sampling period.
public  doublegetBinLowValue(int band, int bin)
     Returns the lowest inclusive pixel value of a given bin for a specific band.
public  intgetBinSize(int band, int bin)
     Returns the number of pixel samples found in a given bin for a specific band.
public synchronized  int[][]getBins()
     Returns the array of bands of bins, each bin is the histogram for a band, i.e., the format of the returned array is int[bands][bins].
public  int[]getBins(int band)
     Returns the bins of the histogram for a specific band by reference.
public  double[]getEntropy()
     Returns the entropy of the histogram.
public  HistogramgetGaussianSmoothed(double standardDeviation)
     Computes a Gaussian smoothed version of the histogram.

Each band of the histogram is smoothed by discrete convolution with a kernel approximating a Gaussian impulse response with the specified standard deviation.
Parameters:
  standardDeviation - The standard deviation of the Gaussiansmoothing kernel which must be non-negative or anIllegalArgumentException will be thrown.

public  double[]getHighValue()
     Returns the highest exclusive pixel value checked for all bands.
public  doublegetHighValue(int band)
     Returns the highest exclusive pixel value checked for a specific band.
public  double[]getIterativeThreshold()
     Calculates the threshold using iterative bisection.

For each band an initial threshold is defined to be the midpoint of the range of data represented by the histogram.

public  double[]getLowValue()
     Returns the lowest inclusive pixel value checked for all bands.
public  doublegetLowValue(int band)
     Returns the lowest inclusive pixel value checked for a specific band.
public  double[]getMaxEntropyThreshold()
     Calculates the threshold which maximizes the entropy.

The entropy of a range of gray levels is defined to be the negation of the sum of products of the probability and the logarithm thereof over all gray levels in the range.

public  double[]getMaxVarianceThreshold()
     Calculates the threshold which maximizes the ratio of the between-class variance to the within-class variance for each band.
public  double[]getMean()
     Returns the mean values for all bands of the histogram.
public  double[]getMinErrorThreshold()
     Calculates the threshold which minimizes the probability of error.

For each band the histogram is modeled as the sum of two Gaussian distributions and the threshold which minimizes the misclassification error is computed.

public  double[]getMinFuzzinessThreshold()
     Calculates the threshold which minimizes the fuzziness.
public  double[]getModeThreshold(double power)
     Calculates the threshold using the mode method.

The threshold is defined to be the minimum between two peaks. The first peak is the highest peak in the histogram.

public  double[]getMoment(int moment, boolean isAbsolute, boolean isCentral)
     Returns a specified (absolute) (central) moment of the histogram.

The ith moment in each band is defined to be the mean of the image pixel values raised to the ith power in that band.

public  intgetNumBands()
     Returns the number of bands of the histogram.
public  int[]getNumBins()
     Returns the number of bins of the histogram for all bands.
public  intgetNumBins(int band)
     Returns the number of bins of the histogram for a specific band.
public  double[]getPTileThreshold(double p)
     Calculates the p-tile threshold.

Computes thresholds such that a specified proportion of the sample values in each band are below the threshold.
Parameters:
  p - The proportion of samples in each band which should be belowthe threshold in the band.

public  HistogramgetSmoothed(boolean isWeighted, int k)
     Computes a smoothed version of the histogram.

Each band of the histogram is smoothed by averaging over a moving window of a size specified by the method parameter: if the value of the parameter is k then the width of the window is 2*k + 1.

public  double[]getStandardDeviation()
     Returns the standard deviation for all bands of the histogram.
public  intgetSubTotal(int band, int minBin, int maxBin)
     Returns the total bin count for the specified sub-range (via "min" and "max" bin) of the indicated band.
public  int[]getTotals()
     Returns the total bin count over all bins for all bands.

An array which stores the total bin count is kept in this class and a reference to this array is returned by this method for performance reasons.



Constructor Detail
Histogram
public Histogram(int[] numBins, double[] lowValue, double[] highValue)(Code)
Constructor.

This constructor should be used when numBins, lowValue, and/or highValues are different for each band of the image. The length of the arrays indicates the number of bands the image has, and the three arrays must have the same length.

Since this constructor has no way of knowing the actual number of bands of the image, the length of the arrays is not checked against anything. Therefore, it is very important that the caller supplies the correct arrays of correct lengths, or errors will occur.
Parameters:
  numBins - The number of bins for each band of the image.The length of this array indicates the number of bands forthis histogram.
Parameters:
  lowValue - The lowest inclusive pixel value checked foreach band.
Parameters:
  highValue - The highest exclusive pixel value checked foreach band.
throws:
  IllegalArgumentException - If numBins,lowValue, or highValue isnull.
throws:
  IllegalArgumentException - If the array length of the threearguments are not the same, or any array length is 0.
throws:
  IllegalArgumentException - If the number of bins for any bandis less than or equal to 0.
throws:
  IllegalArgumentException - If the low-value of any band isgreater than or equal to its corresponding high-value.




Histogram
public Histogram(int[] numBins, double[] lowValue, double[] highValue, int numBands)(Code)
Constructor.

This constructor should be used when numBins, lowValue, and/or highValues may be different for each band of the image. The number of bands in the image is provided explicitly. If any of the arrays provided has a length which is less than the number of bands, the first element in that array is used to fill out the array to a length of numBands.
Parameters:
  numBins - The number of bins for each band of the image.
Parameters:
  lowValue - The lowest inclusive pixel value checked foreach band.
Parameters:
  highValue - The highest exclusive pixel value checked foreach band.
Parameters:
  numBands - The number of bands in the image.
throws:
  IllegalArgumentException - If numBins,lowValue, or highValue isnull.
throws:
  IllegalArgumentException - If any array length is 0.
throws:
  IllegalArgumentException - If the number of bins for any bandis less than or equal to 0.
throws:
  IllegalArgumentException - If the low-value of any band isgreater than or equal to its corresponding high-value.
throws:
  IllegalArgumentException - If numBands is lessthan or equal to 0.
since:
   JAI 1.1




Histogram
public Histogram(int numBins, double lowValue, double highValue, int numBands)(Code)
Constructor.

The same numBins, lowValue, and highValue is applied to every band of the image.
Parameters:
  numBins - The number of bins for all bands of the image.
Parameters:
  lowValue - The lowest inclusive pixel value checked forall bands.
Parameters:
  highValue - The highest exclusive pixel value checked forall bands.
Parameters:
  numBands - The number of bands of the image.
throws:
  IllegalArgumentException - If numBins ornumBands is less than or equal to 0.
throws:
  IllegalArgumentException - If lowValueis less than or equal to highValue.
since:
   JAI 1.1





Method Detail
clearHistogram
public void clearHistogram()(Code)
Resets the values of all bins to zero. If bins has not been initialized (null), this method does nothing.



countPixels
public void countPixels(Raster raster, ROI roi, int xStart, int yStart, int xPeriod, int yPeriod)(Code)
Accumulates the histogram of the pixels within a specific region-of-interest (ROI) by counting them based on the indicated horizontal and vertical sampling period. The result is stored in the bins array and may be obtained by calling the getBins method.

The ROI specifies the region within which the pixels are counted. If it is null, the entire Raster is counted. If it is not null and does not intersect with the Raster, then this method returns without changing the bins.

The set of pixels to be counted may be obtained by intersecting the grid (xStart + i * xPeriod, yStart + j * yPeriod); i, j >= 0 with the ROI and the bounding rectangle of the Raster.
Parameters:
  raster - The Raster that contains the pixels to be counted.
Parameters:
  roi - The region-of-interest within which the pixels are counted.
Parameters:
  xStart - The initial X sample coordinate.
Parameters:
  yStart - The initial Y sample coordinate.
Parameters:
  xPeriod - The X sampling period.
Parameters:
  yPeriod - The Y sampling period.
throws:
  IllegalArgumentException - If raster isnull.
throws:
  IllegalArgumentException - If the pixels stored in theraster do not have the same number of bands(samples per pixel) as this histogram's bins.




getBinLowValue
public double getBinLowValue(int band, int bin)(Code)
Returns the lowest inclusive pixel value of a given bin for a specific band.
Parameters:
  band - The index of the band-of-interest.
Parameters:
  bin - The index of the bin whose lowValueis to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid bandindex is specified.



getBinSize
public int getBinSize(int band, int bin)(Code)
Returns the number of pixel samples found in a given bin for a specific band.
Parameters:
  band - The index of the band-of-interest.
Parameters:
  bin - The index of the bin whose value is to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band orbin index is specified.



getBins
public synchronized int[][] getBins()(Code)
Returns the array of bands of bins, each bin is the histogram for a band, i.e., the format of the returned array is int[bands][bins].



getBins
public int[] getBins(int band)(Code)
Returns the bins of the histogram for a specific band by reference.
Parameters:
  band - The index of the band whose binsare to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band indexis specified.



getEntropy
public double[] getEntropy()(Code)
Returns the entropy of the histogram.

The histogram entropy is defined to be the negation of the sum of the products of the probability associated with each bin with the base-2 log of the probability. The entropy of the histogram.
since:
   JAI 1.1




getGaussianSmoothed
public Histogram getGaussianSmoothed(double standardDeviation)(Code)
Computes a Gaussian smoothed version of the histogram.

Each band of the histogram is smoothed by discrete convolution with a kernel approximating a Gaussian impulse response with the specified standard deviation.
Parameters:
  standardDeviation - The standard deviation of the Gaussiansmoothing kernel which must be non-negative or anIllegalArgumentException will be thrown. If zero, thehistogram object will be returned with no smoothing applied. A Gaussian smoothed version of the histogram.
since:
   JAI 1.1




getHighValue
public double[] getHighValue()(Code)
Returns the highest exclusive pixel value checked for all bands.



getHighValue
public double getHighValue(int band)(Code)
Returns the highest exclusive pixel value checked for a specific band.
Parameters:
  band - The index of the band whose highValueis to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band indexis specified.



getIterativeThreshold
public double[] getIterativeThreshold()(Code)
Calculates the threshold using iterative bisection.

For each band an initial threshold is defined to be the midpoint of the range of data represented by the histogram. The mean value is calculated for each sub-histogram and a new threshold is defined as the arithmetic mean of the two sub-histogram means. This process is repeated until the threshold value no longer changes. The requested thresholds.
since:
   JAI 1.1




getLowValue
public double[] getLowValue()(Code)
Returns the lowest inclusive pixel value checked for all bands.



getLowValue
public double getLowValue(int band)(Code)
Returns the lowest inclusive pixel value checked for a specific band.
Parameters:
  band - The index of the band whose lowValueis to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band indexis specified.



getMaxEntropyThreshold
public double[] getMaxEntropyThreshold()(Code)
Calculates the threshold which maximizes the entropy.

The entropy of a range of gray levels is defined to be the negation of the sum of products of the probability and the logarithm thereof over all gray levels in the range. The maximum entropy threshold is defined to be that value which maximizes the sum of the entropy of the two ranges which are above and below the threshold, respectively. This computation is effected for each band. The requested thresholds.
since:
   JAI 1.1




getMaxVarianceThreshold
public double[] getMaxVarianceThreshold()(Code)
Calculates the threshold which maximizes the ratio of the between-class variance to the within-class variance for each band. The requested thresholds.
since:
   JAI 1.1



getMean
public double[] getMean()(Code)
Returns the mean values for all bands of the histogram.
since:
   JAI 1.1



getMinErrorThreshold
public double[] getMinErrorThreshold()(Code)
Calculates the threshold which minimizes the probability of error.

For each band the histogram is modeled as the sum of two Gaussian distributions and the threshold which minimizes the misclassification error is computed. If the underlying histogram is unimodal the mean value of each band will be returned as the threshold. The bimodality of the histogram for that band will be identically zero. The requested thresholds.
since:
   JAI 1.1




getMinFuzzinessThreshold
public double[] getMinFuzzinessThreshold()(Code)
Calculates the threshold which minimizes the fuzziness.
since:
   JAI 1.1



getModeThreshold
public double[] getModeThreshold(double power)(Code)
Calculates the threshold using the mode method.

The threshold is defined to be the minimum between two peaks. The first peak is the highest peak in the histogram. The second peak is the highest peak in the histogram weighted by a specified power of the distance from the first peak.
Parameters:
  power - The exponent of the distance weighting from thefirst peak. The requested thresholds.
since:
   JAI 1.1




getMoment
public double[] getMoment(int moment, boolean isAbsolute, boolean isCentral)(Code)
Returns a specified (absolute) (central) moment of the histogram.

The ith moment in each band is defined to be the mean of the image pixel values raised to the ith power in that band. For central moments the average of the ith power of the deviation from the mean is used. For absolute moments the absolute value of the exponentiated term is used.

Note that the mean is the first moment, the average energy the second central moment, etc.
Parameters:
  moment - The moment number or index which must be positive oran IllegalArgumentException will be thrown.
Parameters:
  isAbsolute - Whether to calculate the absolute moment.
Parameters:
  isCentral - Whether to calculate the central moment. The requested (absolute) (central) moment of the histogram.
since:
   JAI 1.1




getNumBands
public int getNumBands()(Code)
Returns the number of bands of the histogram. This value is the same as the number of bands of the bins, bins.length.



getNumBins
public int[] getNumBins()(Code)
Returns the number of bins of the histogram for all bands.



getNumBins
public int getNumBins(int band)(Code)
Returns the number of bins of the histogram for a specific band.
Parameters:
  band - The index of the band whose numBinsis to be returned.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band indexis specified.



getPTileThreshold
public double[] getPTileThreshold(double p)(Code)
Calculates the p-tile threshold.

Computes thresholds such that a specified proportion of the sample values in each band are below the threshold.
Parameters:
  p - The proportion of samples in each band which should be belowthe threshold in the band. If p is not in the range(0.0, 1.0) an IllegalArgumentException will be thrown. The requested p-tile thresholds.
since:
   JAI 1.1




getSmoothed
public Histogram getSmoothed(boolean isWeighted, int k)(Code)
Computes a smoothed version of the histogram.

Each band of the histogram is smoothed by averaging over a moving window of a size specified by the method parameter: if the value of the parameter is k then the width of the window is 2*k + 1. If the window runs off the end of the histogram only those values which intersect the histogram are taken into consideration. The smoothing may optionally be weighted to favor the central value using a "triangular" weighting. For example, for a value of k equal to 2 the central bin would have weight 1/3, the adjacent bins 2/9, and the next adjacent bins 1/9.
Parameters:
  isWeighted - Whether bins will be weighted using a triangularweighting scheme favoring bins near the central bin.
Parameters:
  k - The smoothing parameter which must be non-negative or anIllegalArgumentException will be thrown. If zero, thehistogram object will be returned with no smoothing applied. A smoothed version of the histogram.
since:
   JAI 1.1




getStandardDeviation
public double[] getStandardDeviation()(Code)
Returns the standard deviation for all bands of the histogram. This is a convenience method as the returned values could be calculated using the first and second moments which are available via the moment generation function. The standard deviation values for all bands.
since:
   JAI 1.1



getSubTotal
public int getSubTotal(int band, int minBin, int maxBin)(Code)
Returns the total bin count for the specified sub-range (via "min" and "max" bin) of the indicated band. The sub-ragne must fall within the actual range of the bins.
Parameters:
  band - The index of the band-of-interest.
Parameters:
  minBin - The minimum bin index to be counted.
Parameters:
  maxBin - The maximum bin index to be counted.
throws:
  ArrayIndexOutOfBoundsException - If an invalid band indexis specified.
throws:
  IllegalArgumentException - If minBin is greater thanmaxBin.
since:
   JAI 1.1



getTotals
public int[] getTotals()(Code)
Returns the total bin count over all bins for all bands.

An array which stores the total bin count is kept in this class and a reference to this array is returned by this method for performance reasons. The elements of the returned array should not be modified or undefined errors may occur. The array format is int[numBands].
since:
   JAI 1.1




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.