Class SpectralClustering
Inheritance
SpectralClustering
Assembly: AudioAnalysisTools.dll
public static class SpectralClustering
Fields
|
Improve this Doc
View Source
Declaration
public const double DefaultBinaryThreshold = 0.12
Field Value
|
Improve this Doc
View Source
Declaration
public const double DefaultBinaryThresholdInDecibels = 6
Field Value
|
Improve this Doc
View Source
Declaration
public const int DefaultHitThreshold = 3
Field Value
|
Improve this Doc
View Source
Declaration
public const int DefaultReductionFactor = 3
Field Value
|
Improve this Doc
View Source
Declaration
public const double DefaultRowSumThreshold = 2
Field Value
Methods
|
Improve this Doc
View Source
this method is used only to visualize the clusters and which frames they hit.
Create a new spectrogram of same size as the passed spectrogram.
Later on it is superimposed on a detailed spectrogram.
Declaration
public static int[, ] AssembleClusterSpectrogram(double[, ] spectrogram, int lowerBinBound, ClusterInfo clusterInfo, SpectralClustering.TrainingDataInfo data)
Parameters
Type |
Name |
Description |
Double[,] |
spectrogram |
spectrogram used to derive spectral richness indices. Orientation is row=frame.
|
Int32 |
lowerBinBound |
bottom N freq bins are excluded because likely to contain traffic and wind noise.
|
ClusterInfo |
clusterInfo |
information about accumulated clusters.
|
SpectralClustering.TrainingDataInfo |
data |
training data.
|
Returns
Type |
Description |
Int32[,] |
|
|
Improve this Doc
View Source
Clusters the spectra in a spectrogram. USED to determine the spectral diversity and persistence of spectral types.
The spectrogram is passed as a matrix. Note that the spectrogram is in amplitude values in [0, 1].
Declaration
public static ClusterInfo ClusterAnalysis(List<double[]> trainingData, double wtThreshold, int hitThreshold, bool[] selectedFrames)
Parameters
Returns
|
Improve this Doc
View Source
This CLUSTERING method is called only from IndexCalculate.cs
and TESTMETHOD_SpectralClustering(string wavFilePath, string outputDir, int frameSize)
It estimates the number of spectral clusters in a spectrogram,
and outputs two summary indices: cluster count (also called spectral diversity) and the threegram count.
IMPORTANT NOTE: The passed spectrogram MUST be already noise reduced.
This clustering algorithm is a highly reduced version of binary ART, Adaptive resonance Theory, designed for speed.
Declaration
public static ClusterInfo ClusterTheSpectra(double[, ] spectrogram, int lowerBinBound, int upperBinBound, double binaryThreshold)
Parameters
Type |
Name |
Description |
Double[,] |
spectrogram |
a collection of spectra that are to be clustered.
|
Int32 |
lowerBinBound |
lower end of the bird-band.
|
Int32 |
upperBinBound |
upper end of the bird-band.
|
Double |
binaryThreshold |
used to convert real value spectrum to binary.
|
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] ConvertOverlayToSpectrogramSize(double[, ] dataMatrix, int lowerBinBound, int newRowCount, int newColumnCount)
Parameters
Returns
|
Improve this Doc
View Source
Overlays the spectral cluster IDs on a spectrogram from which the clusters derived.
Declaration
public static Image DrawClusterSpectrogram(BaseSonogram sonogram, ClusterInfo clusterInfo, SpectralClustering.TrainingDataInfo data, int lowerBinBound)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image |
|
|
Improve this Doc
View Source
Declaration
public static Image DrawSonogram(BaseSonogram sonogram, Plot scores, List<AcousticEvent> poi, double eventThreshold, double[, ] overlay)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image |
|
|
Improve this Doc
View Source
Declaration
public static double[, ] GetAmplitudeSpectrogramNoiseReduced(AudioRecording recording, int frameSize)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static double[, ] GetDecibelSpectrogramNoiseReduced(AudioRecording recording, int frameSize)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static SpectrogramStandard GetStandardSpectrogram(AudioRecording recording, int frameSize)
Parameters
Returns
|
Improve this Doc
View Source
First convert spectrogram to Binary using threshold. An amplitude threshold of 0.03 = -30 dB. An amplitude threhold of 0.05 = -26dB.
Declaration
public static SpectralClustering.TrainingDataInfo GetTrainingDataForClustering(double[, ] spectrogram, SpectralClustering.ClusteringParameters cp)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static void IncludeSpectrumInSpectrogram(double[, ] trainingDataAsBinarySpectrogram, int row, double[] binarySpectrum, int reductionFactor)
Parameters
Type |
Name |
Description |
Double[,] |
trainingDataAsBinarySpectrogram |
|
Int32 |
row |
|
Double[] |
binarySpectrum |
|
Int32 |
reductionFactor |
|
|
Improve this Doc
View Source
displays a histogram of cluster counts.
the argument clusters is an array of integer. Indicates cluster assigned to each binary frame.
Declaration
public static void OutputClusterAndWeightInfo(int[] clusters, List<double[]> wts, string imagePath)
Parameters
|
Improve this Doc
View Source
Declaration
public static double[] RestoreFullLengthSpectrum(double[] ipSpectrum, int fullLength, int lowOffset)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public static void SaveAndViewSpectrogramImage(Image image, string opDir, string fName, string imageViewer)
Parameters
Type |
Name |
Description |
SixLabors.ImageSharp.Image |
image |
|
String |
opDir |
|
String |
fName |
|
String |
imageViewer |
|
|
Improve this Doc
View Source
Declaration
public static double[, ] SuperImposeHitsOnSpectrogram(double[, ] spectrogram, int lowBinBound, double[, ] trainingDataAsSpectrogram)
Parameters
Type |
Name |
Description |
Double[,] |
spectrogram |
|
Int32 |
lowBinBound |
|
Double[,] |
trainingDataAsSpectrogram |
|
Returns
|
Improve this Doc
View Source
Declaration
public static void TESTMETHOD_SpectralClustering()
|
Improve this Doc
View Source
This method was set up as a TESTMETHOD in May 2017 but has not yet been debugged.
It was transferred from Sandpit.cls. It is several years old.
Updated May 2017.
Declaration
public static void TESTMETHOD_SpectralClustering(string wavFilePath, string outputDir, int frameSize)
Parameters