java.lang.Object
imagingbook.common.histogram.HistogramUtils
This class defines static methods related to histograms. See Ch. 2 of [1] for additional details.
[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction, 3rd ed, Springer (2022).
- Version:
- 2022/08/24
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]
cdf
(int[] h) Calculates and returns the cumulative distribution function (cdf) for the given histogram.static int
count
(int[] h) Calculates and returns the total population (sum of all bin counts) of a histogram.static int
count
(int[] h, int lo, int hi) Calculates and returns the population (sum of bin counts) of a histogram over the specified range of indexes.static int[]
cumulate
(int[] h) Calculates and returns the cumulative histogram from a given histogram.static int[]
matchHistograms
(int[] hA, int[] hR) Histogram matching.static int[]
matchHistograms
(int[] hA, PiecewiseLinearCdf PR) Histogram matching to a reference cumulative distribution function that is piecewise linear.static double
max
(double[] h) Returns the maximum bin value (count) of the given frequency distribution (histogram).static int
max
(int[] h) Returns the maximum bin value (count) of the given histogram.static double
mean
(int[] h) Calculates and returns the intensity mean (average) of the distribution represented by the given histogram.static double
mean
(int[] h, int lo, int hi) Calculates and returns the intensity mean (average) of the distribution represented by the given histogram, limited to the specified intensity range.static int
median
(int[] h) Calculates and returns the intensity median of the distribution represented by the given histogram.static double[]
normalizeMax
(double[] h) Returns a normalized frequency distribution for the given histogram whose maximum entry is 1 (double
version).static double[]
normalizeMax
(int[] h) Returns a normalized frequency distribution for the given histogram whose maximum entry is 1 (int
version).static double[]
pdf
(int[] h) Calculates and returns the probability distribution function (pdf) for the given histogram.static double
variance
(int[] h) Calculates and returns the intensity variance (σ2) of the distribution represented by the given histogram.static double
variance
(int[] h, int lo, int hi) Calculates and returns the intensity variance (σ2) of the distribution represented by the given histogram, limited to the specified intensity range (fast version).static double
varianceSlow
(int[] h, int lo, int hi)
-
Method Details
-
count
Calculates and returns the total population (sum of all bin counts) of a histogram.- Parameters:
h
- a histogram- Returns:
- the histogram's total count
-
count
Calculates and returns the population (sum of bin counts) of a histogram over the specified range of indexes. The range is automatically clipped.- Parameters:
h
- a histogramlo
- the lower index (inclusive)hi
- the upper index (inclusive)- Returns:
- the population count
-
max
Returns the maximum bin value (count) of the given histogram.- Parameters:
h
- a histogram- Returns:
- the maximum bin value
-
max
Returns the maximum bin value (count) of the given frequency distribution (histogram).- Parameters:
h
- a histogram- Returns:
- the maximum bin value
-
cumulate
Calculates and returns the cumulative histogram from a given histogram.- Parameters:
h
- a histogram- Returns:
- the cumulative histogram
-
pdf
Calculates and returns the probability distribution function (pdf) for the given histogram. The resultingdouble
array has the same length as the original histogram. Its values sum to 1.- Parameters:
h
- a histogram- Returns:
- the probability distribution function
-
cdf
Calculates and returns the cumulative distribution function (cdf) for the given histogram. The resultingdouble
array has the same length as the original histogram. Its maximum value is 1.- Parameters:
h
- a histogram- Returns:
- the cumulative distribution function
-
mean
Calculates and returns the intensity mean (average) of the distribution represented by the given histogram.- Parameters:
h
- a histogram- Returns:
- the mean intensity
-
mean
Calculates and returns the intensity mean (average) of the distribution represented by the given histogram, limited to the specified intensity range. The range is automatically clipped.- Parameters:
h
- a histogramlo
- the lower index (inclusive)hi
- the upper index (inclusive)- Returns:
- the mean intensity
-
variance
Calculates and returns the intensity variance (σ2) of the distribution represented by the given histogram.- Parameters:
h
- a histogram- Returns:
- the intensity variance
-
variance
Calculates and returns the intensity variance (σ2) of the distribution represented by the given histogram, limited to the specified intensity range (fast version). The range is automatically clipped.- Parameters:
h
- a histogramlo
- the lower index (inclusive)hi
- the upper index (inclusive)- Returns:
- the intensity variance
-
varianceSlow
-
median
Calculates and returns the intensity median of the distribution represented by the given histogram.- Parameters:
h
- a histogram- Returns:
- the intensity median
-
normalizeMax
Returns a normalized frequency distribution for the given histogram whose maximum entry is 1 (int
version). Mainly intended for displaying histograms.- Parameters:
h
- a histogram- Returns:
- the max-normalized frequency distribution
-
normalizeMax
Returns a normalized frequency distribution for the given histogram whose maximum entry is 1 (double
version). Mainly intended for displaying histograms.- Parameters:
h
- a histogram- Returns:
- the max-normalized frequency distribution
-
matchHistograms
Histogram matching. Given are two histograms: the histogram hA of the target image IA and a reference histogram hR, both of size K. The result is a discrete mapping f which, when applied to the target image, produces a new image with a distribution function similar to the reference histogram.- Parameters:
hA
- histogram of the target imagehR
- reference histogram (the same size as hA)- Returns:
- a discrete mapping f to be applied to the values of a target image
-
matchHistograms
Histogram matching to a reference cumulative distribution function that is piecewise linear.- Parameters:
hA
- histogram of the target imagePR
- a piecewise linear reference cumulative distribution function (PiecewiseLinearCdf
)- Returns:
- a discrete mapping f to be applied to the values of a target image
- See Also:
-