Class LDSpectrogramRGB
This class generates false-color spectrograms of long duration audio recordings.
Important properties are:
- the color map which maps three acoustic indices to RGB.
- The scale of the x and y axes which are determined by the sample rate, frame size etc.
In order to create false color spectrograms, copy the method
public static void DrawFalseColorSpectrograms(LDSpectrogramConfig configuration)
All the arguments can be passed through a config file.
Create the config file through an instance of the class LDSpectrogramConfig
and then call config.WritConfigToYAML(FileInfo path).
Then pass that path to the above static method.
Inheritance
LDSpectrogramRGB
Assembly: AudioAnalysisTools.dll
public class LDSpectrogramRGB
Constructors
|
Improve this Doc
View Source
Initializes a new instance of the LDSpectrogramRGB class.
No Arguments CONSTRUCTOR.
Declaration
public LDSpectrogramRGB()
|
Improve this Doc
View Source
Declaration
public LDSpectrogramRGB(LdSpectrogramConfig config, IndexGenerationData indexGenerationData, string colorMap)
Parameters
|
Improve this Doc
View Source
Declaration
public LDSpectrogramRGB(TimeSpan xScale, int sampleRate, string colorMap)
Parameters
|
Improve this Doc
View Source
Initializes a new instance of the LDSpectrogramRGB class.
CONSTRUCTOR
WARNING: Ths will create a linear Hertz scale spectrogram.
Declaration
public LDSpectrogramRGB(TimeSpan minuteOffset, TimeSpan xScale, int sampleRate, int frameWidth, string colorMap)
Parameters
Type |
Name |
Description |
TimeSpan |
minuteOffset |
minute of day at which the spectrogram starts.
|
TimeSpan |
xScale |
time scale : pixels per hour.
|
Int32 |
sampleRate |
recording sample rate which also determines scale of Y-axis.
|
Int32 |
frameWidth |
frame size - which also determines scale of Y-axis.
|
String |
colorMap |
acoustic indices used to assign the three color mapping.
|
Fields
|
Improve this Doc
View Source
Declaration
public static readonly string DefaultColorMap1
Field Value
|
Improve this Doc
View Source
Declaration
public static readonly string DefaultColorMap2
Field Value
|
Improve this Doc
View Source
Declaration
public Dictionary<string, double[, ]> SpectrogramMatrices
Field Value
|
Improve this Doc
View Source
Declaration
public const int TrackHeight = 18
Field Value
Properties
|
Improve this Doc
View Source
Declaration
public double BackgroundFilter { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets the ColorMap within current recording.
Declaration
public string ColorMap { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets POSITIVE or NEGATIVE.
Declaration
public string ColorMode { get; set; }
Property Value
|
Improve this Doc
View Source
Declaration
public List<GapsAndJoins> ErroneousSegments { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public string FileName { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets the frame width. Used only to calculate scale of Y-axis to draw grid lines.
Declaration
public int FrameWidth { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets the ColorMap within current recording.
Declaration
public FrequencyScale FreqScale { get; set; }
Property Value
|
Improve this Doc
View Source
Gets the 1 kHz intervals.
Declaration
public int GetYinterval { get; }
Property Value
|
Improve this Doc
View Source
Gets or sets the temporal duration of one sub-segment interval for which indices are calculated.
Declaration
public TimeSpan IndexCalculationDuration { get; set; }
Property Value
|
Improve this Doc
View Source
Gets index distribution statistics are now calulated after the indices have been calculated.
Declaration
public Dictionary<string, IndexDistributions.SpectralStats> IndexStats { get; }
Property Value
|
Improve this Doc
View Source
Declaration
public double? Latitude { get; set; }
Property Value
|
Improve this Doc
View Source
Declaration
public double? Longitude { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets the date and time at which the current LDspectrogram starts
This can be used to correctly.
Declaration
public DateTimeOffset RecordingStartDate { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets used where the spectrograms are derived from averages and want to do t-test of difference.
Declaration
public int SampleCount { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets the sample rate.
Declaration
public int SampleRate { get; set; }
Property Value
|
Improve this Doc
View Source
Declaration
public string SiteName { get; set; }
Property Value
|
Improve this Doc
View Source
Declaration
public string[] SpectrogramKeys { get; }
Property Value
|
Improve this Doc
View Source
Gets or sets the time at which the current LDFC spectrogram starts.
Declaration
public TimeSpan StartOffset { get; set; }
Property Value
|
Improve this Doc
View Source
Gets or sets a file from which can be obtained information about sunrise and sunset times for the recording site.
The csv file needs to be in the correct format and typically should contain 365 lines.
Have not attempted to deal with leap years!.
Declaration
[Obsolete]
public FileInfo SunriseDataFile { get; set; }
Property Value
|
Improve this Doc
View Source
Declaration
public TimeSpan XTicInterval { get; set; }
Property Value
Methods
|
Improve this Doc
View Source
Declaration
public static Color[] ColourChart2Array(Dictionary<string, Color> chart)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Color[] |
|
|
Improve this Doc
View Source
Declaration
public bool ContainsMatrixForKey(string key)
Parameters
Type |
Name |
Description |
String |
key |
|
Returns
|
Improve this Doc
View Source
Declaration
public bool ContainsMatrixForKeys(string keys)
Parameters
Type |
Name |
Description |
String |
keys |
|
Returns
|
Improve this Doc
View Source
Declaration
public Image<Rgb24> DrawBlendedFalseColourSpectrogram(string colorMap1, string colorMap2, double blendWt1, double blendWt2)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Returns an image of an array of color patches.
It shows the three primary colors and pairwise combinations.
Declaration
public static Image DrawColourScale(int maxScaleLength, int ht)
Parameters
Type |
Name |
Description |
Int32 |
maxScaleLength |
|
Int32 |
ht |
|
Returns
Type |
Description |
SixLabors.ImageSharp.Image |
|
|
Improve this Doc
View Source
Declaration
public Image<Rgb24> DrawDoubleSpectrogram(Image bmp1, Image bmp2, string colorMode)
Parameters
Type |
Name |
Description |
SixLabors.ImageSharp.Image |
bmp1 |
|
SixLabors.ImageSharp.Image |
bmp2 |
|
String |
colorMode |
|
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Draw a chromeless false colour spectrogram.
Chromeless means WITHOUT all the trimmings, such as title bar axis labels, grid lines etc.
However it does add in notated error segments.
Declaration
public Image<Rgb24> DrawFalseColorSpectrogramChromeless(string colorMode, string colorMap, double blueEnhanceParameter)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
A technique to derive a spectrogram from four different indices
same as above method but multiply index value by the amplitude value instead of squaring the value.
Declaration
public static Image DrawFourColorSpectrogram(double[, ] redM, double[, ] grnM, double[, ] bluM, double[, ] greM, bool doReverseColor)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image |
|
|
Improve this Doc
View Source
Assume calling method has done all the reality checks.
Declaration
public Image<Rgb24> DrawGreyscaleSpectrogramOfIndex(string key, ImageChrome chrome = ImageChrome.With)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Assume calling method has done all the reality checks.
Assume the Index Calculation Duration = 60 seconds.
Declaration
public static Image DrawGreyscaleSpectrogramOfIndex(string key, double[, ] matrix)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image |
|
|
Improve this Doc
View Source
draws only those spectrograms in the passed array of keys.
Declaration
public void DrawGreyScaleSpectrograms(DirectoryInfo opdir, string opFileName, string[] keys, ImageChrome chrome = ImageChrome.With)
Parameters
|
Improve this Doc
View Source
Declaration
public void DrawNegativeFalseColorSpectrogram(DirectoryInfo outputDirectory, string outputFileName, double blueEnhanceParameter)
Parameters
|
Improve this Doc
View Source
This method assumes that all the passed matrices are normalised and of the same dimensions.
The method implements a hack to enhance the blue color because the human eye is less sensitive to blue.
If there is a problem with one or more of the three rgb values, a gray pixel is substituted not a black pixel.
Black is a frequent color in LDFC spectrograms, but gray is highly unlikely,
and therefore its presence stands out as indicating an error in one or more of the rgb values.
Declaration
public static Image<Rgb24> DrawRgbColorMatrix(double[, ] redM, double[, ] grnM, double[, ] bluM, bool doReverseColor, double blueEnhanceParameter)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
This IS THE MAJOR STATIC METHOD FOR CREATING LD SPECTROGRAMS
IT CAN BE COPIED AND APPROPRIATELY MODIFIED BY ANY USER FOR THEIR OWN PURPOSE.
WARNING: Make sure the parameters in the CONFIG file are consistent with the CSV files.
Declaration
public static Tuple<Image<Rgb24>, string>[] DrawSpectrogramsFromSpectralIndices(DirectoryInfo inputDirectory, DirectoryInfo outputDirectory, LdSpectrogramConfig ldSpectrogramConfig, FileInfo indexPropertiesConfigPath, IndexGenerationData indexGenerationData, string basename, string analysisType, Dictionary<string, double[, ]> indexSpectrograms = null, SummaryIndexBase[] summaryIndices = null, Dictionary<string, IndexDistributions.SpectralStats> indexStatistics = null, SiteDescription siteDescription = null, FileInfo sunriseDataFile = null, List<GapsAndJoins> segmentErrors = null)
Parameters
Type |
Name |
Description |
DirectoryInfo |
inputDirectory |
inputDirectory.
|
DirectoryInfo |
outputDirectory |
outputDirectory.
|
LdSpectrogramConfig |
ldSpectrogramConfig |
config for drawing FCSs.
|
FileInfo |
indexPropertiesConfigPath |
The indices Config Path.
|
IndexGenerationData |
indexGenerationData |
indexGenerationData.
|
String |
basename |
stem name of the original recording.
|
String |
analysisType |
will usually be "Towsey.Acoustic".
|
Dictionary<String, Double[,]> |
indexSpectrograms |
Optional spectra to pass in. If specified the spectra will not be loaded from disk.
|
SummaryIndexBase[] |
summaryIndices |
an array of summary index results.
|
Dictionary<String, IndexDistributions.SpectralStats> |
indexStatistics |
Info about the distributions of the spectral statistics.
|
SiteDescription |
siteDescription |
Optionally specify details about the site where the audio was recorded.
|
FileInfo |
sunriseDataFile |
This is only available for locations near Brisbane, Austalia.
|
List<GapsAndJoins> |
segmentErrors |
Note that these segment errors were derived from previous analysis of the summary indices.
|
Returns
Type |
Description |
Tuple<SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24>, String>[] |
|
|
Improve this Doc
View Source
Declaration
public static Image<Rgb24> DrawTitleBarOfFalseColourSpectrogram(string title, int width)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Declaration
public static Image<Rgb24> DrawTitleBarOfGrayScaleSpectrogram(string title, int width)
Parameters
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Frames a false-colourspectrogram.
That is, it creates the title bar and the time scale. Also adds frequency grid lines to the image.
Note that to call this method, the field cs.Freqscale MUST NOT = null.
Declaration
public static Image<Rgb24> FrameFalseColourSpectrogram(Image<Rgb24> bmp1, Image<Rgb24> titleBar, LDSpectrogramRGB cs)
Parameters
Type |
Name |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
bmp1 |
|
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
titleBar |
|
LDSpectrogramRGB |
cs |
|
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Frames a false-color spectrogram.
Creates the title bar and the time scale. Also adds frequency grid lines to the image.
Note that the 'nyquist' and 'hertzGridInterval' arguments are used ONLY if the cs.FreqScale field==null.
Also note that in this case, the frequency scale will be linear.
Declaration
public static Image<Rgb24> FrameLDSpectrogram(Image<Rgb24> bmp1, Image<Rgb24> titleBar, LDSpectrogramRGB cs, int nyquist, int hertzInterval)
Parameters
Type |
Name |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
bmp1 |
|
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
titleBar |
|
LDSpectrogramRGB |
cs |
|
Int32 |
nyquist |
|
Int32 |
hertzInterval |
|
Returns
Type |
Description |
SixLabors.ImageSharp.Image<SixLabors.ImageSharp.PixelFormats.Rgb24> |
|
|
Improve this Doc
View Source
Declaration
public static string[] GetArrayOfAvailableKeys()
Returns
|
Improve this Doc
View Source
Declaration
public int GetCountOfSpectrogramMatrices()
Returns
|
Improve this Doc
View Source
Declaration
public int GetCountOfStandardDeviationMatrices()
Returns
|
Improve this Doc
View Source
Call this method to access a spectrogram matrix.
Declaration
public double[, ] GetMatrix(string key)
Parameters
Type |
Name |
Description |
String |
key |
|
Returns
|
Improve this Doc
View Source
returns a matrix of acoustic indices whose values are normalised.
In addition, small background values are reduced as per filter coefficient. 1.0 = unchanged.
NOTE: The matrix is oriented as it would appear in the spectrogram image; i.e. rows = freq bins.
Declaration
public double[, ] GetNormalisedSpectrogramMatrix(string key)
Parameters
Type |
Name |
Description |
String |
key |
|
Returns
|
Improve this Doc
View Source
Declaration
public Dictionary<string, IndexProperties> GetSpectralIndexProperties()
Returns
|
Improve this Doc
View Source
Declaration
public double[, ] GetSpectrogramMatrix(string key)
Parameters
Type |
Name |
Description |
String |
key |
|
Returns
|
Improve this Doc
View Source
Declaration
public double[, ] GetStandarDeviationMatrix(string key)
Parameters
Type |
Name |
Description |
String |
key |
|
Returns
|
Improve this Doc
View Source
Call this method if already have a dictionary of Matrix spectorgrams and wish to load directly
For example, call this method from AnalyseLongRecordings.
Declaration
public void LoadSpectrogramDictionary(Dictionary<string, double[, ]> dictionary)
Parameters
|
Improve this Doc
View Source
Declaration
public bool ReadCsvFiles(DirectoryInfo ipdir, string fileName)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public bool ReadCsvFiles(DirectoryInfo ipdir, string fileName, string[] keys)
Parameters
Returns
|
Improve this Doc
View Source
Declaration
public bool ReadStandardDeviationSpectrogramCsvs(DirectoryInfo ipdir, string fileName)
Parameters
Returns
|
Improve this Doc
View Source
This method sets default indices to use if passed Dictionary = null.
This may not be a good idea. Trying it out. Maybe better to crash!.
Declaration
public void SetSpectralIndexProperties(Dictionary<string, IndexProperties> dictionaryOfSpectralIndexProperties)
Parameters
Extension Methods