Class Histogram
Represents a multi-dimensional histogram.
Namespace: OpenCV.Net
Assembly: OpenCV.Net.dll
Syntax
public sealed class Histogram : SafeHandleZeroOrMinusOneIsInvalid
Constructors
| Improve this Doc View SourceHistogram(Int32, Int32[], HistogramType, Single[][], Boolean)
Initializes a new instance of the Histogram class with the specified size.
Declaration
public Histogram(int dims, int[] sizes, HistogramType type, float[][] ranges = null, bool uniform = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dims | Number of histogram dimensions. |
| Int32[] | sizes | Array of the histogram dimension sizes. |
| HistogramType | type | Histogram representation format. |
| Single[][] | ranges | Array of ranges for the histogram bins. |
| Boolean | uniform | If true the histogram has evenly spaced bins and for each dimension, |
Properties
| Improve this Doc View SourceBins
Gets the multi-dimensional array of histogram data.
Declaration
public Arr Bins { get; }
Property Value
| Type | Description |
|---|---|
| Arr |
IsUniform
Gets a value indicating whether the histogram uses evenly spaced bins.
Declaration
public bool IsUniform { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Type
Gets the type of the histogram representation format.
Declaration
public HistogramType Type { get; }
Property Value
| Type | Description |
|---|---|
| HistogramType |
Methods
| Improve this Doc View SourceCalcArrBackProject(Arr[], Arr)
Calculates the back projection.
Declaration
public void CalcArrBackProject(Arr[] images, Arr dst)
Parameters
| Type | Name | Description |
|---|---|---|
| Arr[] | images | Source images. |
| Arr | dst | Destination back projection image of the same type as the source |
CalcArrBackProjectPatch(Arr[], Arr, Size, HistogramComparison, Double)
Locates a template within an image by using a histogram comparison.
Declaration
public void CalcArrBackProjectPatch(Arr[] images, Arr dst, Size range, HistogramComparison method, double factor)
Parameters
| Type | Name | Description |
|---|---|---|
| Arr[] | images | Source images. |
| Arr | dst | Destination image. |
| Size | range | Size of the patch slid though the source image. |
| HistogramComparison | method | The histogram comparison method. |
| Double | factor | Normalization factor for histograms. |
CalcArrHist(Arr[], Boolean, Arr)
Calculates the histogram of image(s).
Declaration
public void CalcArrHist(Arr[] images, bool accumulate = false, Arr mask = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Arr[] | images | Source images. |
| Boolean | accumulate | If true, the histogram is not cleared in the beginning. This feature allows the user to compute a single histogram from several images, or to update the histogram online. |
| Arr | mask | The operation mask, determines what pixels of the source images are counted. |
CalcProbDensity(Histogram, Histogram, Double)
Divides one histogram by another and stores the result in this instance.
Declaration
public void CalcProbDensity(Histogram hist1, Histogram hist2, double scale = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Histogram | hist1 | First histogram (the divisor). |
| Histogram | hist2 | Second histogram. |
| Double | scale | Scale factor. |
Clear()
Clears the histogram.
Declaration
public void Clear()
Clone()
Creates a new Histogram that is a copy of the current instance.
Declaration
public Histogram Clone()
Returns
| Type | Description |
|---|---|
| Histogram | A new Histogram that is a copy of this instance. |
Compare(Histogram, HistogramComparison)
Compares this histogram with another dense histogram.
Declaration
public double Compare(Histogram other, HistogramComparison method)
Parameters
| Type | Name | Description |
|---|---|---|
| Histogram | other | The second dense histogram. |
| HistogramComparison | method | The comparison method to be used. |
Returns
| Type | Description |
|---|---|
| Double | The distance between the two histograms. |
Copy(out Histogram)
Copies the histogram. The method copies this histogram’s bin values to the destination histogram and sets the same bin value ranges as this instance.
Declaration
public void Copy(out Histogram dst)
Parameters
| Type | Name | Description |
|---|---|---|
| Histogram | dst | The destination histogram. |
GetBinRanges()
Gets the bounds of the histogram bins.
Declaration
public float[][] GetBinRanges()
Returns
| Type | Description |
|---|---|
| Single[][] | The array of ranges for the histogram bins. |
GetMinMaxValue(out Single, out Single, Int32[], Int32[])
Finds the minimum and maximum histogram bins.
Declaration
public void GetMinMaxValue(out float minValue, out float maxValue, int[] minIdx = null, int[] maxIdx = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | minValue | The output minimum value of the histogram. |
| Single | maxValue | The output maximum value of the histogram. |
| Int32[] | minIdx | The array of coordinates for the minimum. |
| Int32[] | maxIdx | The array of coordinates for the maximum. |
Normalize(Double)
Normalizes the histogram such that the sum of the bins is equal to factor.
Declaration
public void Normalize(double factor)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | factor | Normalization factor. |
QueryValue(Int32)
Queries the value of the histogram bin.
Declaration
public double QueryValue(int idx0)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | idx0 | The index of the bin. |
Returns
| Type | Description |
|---|---|
| Double | The value of the specified bin. |
QueryValue(Int32, Int32)
Queries the value of the histogram bin.
Declaration
public double QueryValue(int idx0, int idx1)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | idx0 | The first index of the bin. |
| Int32 | idx1 | The second index of the bin. |
Returns
| Type | Description |
|---|---|
| Double | The value of the specified bin. |
QueryValue(Int32, Int32, Int32)
Queries the value of the histogram bin.
Declaration
public double QueryValue(int idx0, int idx1, int idx2)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | idx0 | The first index of the bin. |
| Int32 | idx1 | The second index of the bin. |
| Int32 | idx2 | The third index of the bin. |
Returns
| Type | Description |
|---|---|
| Double | The value of the specified bin. |
ReleaseHandle()
Executes the code required to free the native Histogram handle.
Declaration
protected override bool ReleaseHandle()
Returns
| Type | Description |
|---|---|
| Boolean | true if the handle is released successfully; otherwise, in the event of a catastrophic failure, false. |
SetBinRanges(Single[][], Boolean)
Sets the bounds of the histogram bins.
Declaration
public void SetBinRanges(float[][] ranges, bool uniform = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Single[][] | ranges | Array of ranges for the histogram bins. |
| Boolean | uniform | If true the histogram has evenly spaced bins and for each dimension, |
Threshold(Double)
Thresholds the histogram by clearing histogram bins that are below the
specified threshold.
Declaration
public void Threshold(double threshold)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | threshold | Threshold level. |