Skip to content

Commit

Permalink
Fix bug concerning assigning colour codes to spectrogram types
Browse files Browse the repository at this point in the history
Issue #332 There was a limited number of colours to use as tags for different spectrogram types. By adding two new spectrograms, there was an insufficient number of colours. Changed the colour palette.
  • Loading branch information
towsey committed Jul 30, 2020
1 parent d9688f9 commit 68a0ba2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Acoustics.Shared/ColorScales/Palette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class Palette

public List<Color[]> Colors { get; internal set; }

public Color[] ForClassCount(int classCount) => this.Colors.FirstOrDefault(x => x.Length == classCount);
public Color[] ForClassCount(int classCount) => this.Colors.FirstOrDefault(x => x.Length >= classCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static SpectrogramGenerator()
{
var values = (SpectrogramImageType[])Enum.GetValues(typeof(SpectrogramImageType));
ImageTags = values
.Zip(ColorBrewer.Qualitative.Dark.ForClassCount(values.Length))
.Zip(ColorBrewer.Qualitative.Set1.ForClassCount(values.Length))
.ToImmutableDictionary(x => x.First, x => x.Second);
}

Expand Down Expand Up @@ -75,6 +75,7 @@ public static AudioToSonogramResult GenerateSpectrogramImages(
// EXTRACT ENVELOPE and SPECTROGRAM FROM RECORDING SEGMENT
var dspOutput1 = DSP_Frames.ExtractEnvelopeAndFfts(recordingSegment, frameSize, frameStep);

// This constructor initalises default values for Melscale and Mfcc spectrograms and other parameters.
var sonoConfig = new SonogramConfig()
{
epsilon = recordingSegment.Epsilon,
Expand Down Expand Up @@ -191,6 +192,7 @@ public static AudioToSonogramResult GenerateSpectrogramImages(
}

// IMAGE 6) Mel-frequency Spectrogram
// The default spectrogram has 64 frequency bands.
if (@do.Contains(MelScaleSpectrogram))
{
images.Add(
Expand Down

0 comments on commit 68a0ba2

Please sign in to comment.