Skip to content

Commit

Permalink
Clean up some build problems
Browse files Browse the repository at this point in the history
and other minor changes
  • Loading branch information
towsey authored and atruskie committed Aug 22, 2019
1 parent 734954b commit 70277d4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
11 changes: 10 additions & 1 deletion src/AnalysisPrograms/Sandpit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,12 +1207,21 @@ public static void ReadSpectralIndicesFromTwoFalseColourSpectrogramRibbons()
//string[] colourKeys2 = { "BGN", "PMN", "XXX" };
var image1 = Image.FromFile(path1.FullName);
var image2 = Image.FromFile(path2.FullName);

// default time values are for complete image width.
var matrix = LdSpectrogramRibbons.ReadSpectralIndicesFromTwoFalseColourSpectrogramRibbons(image1, image2);

//var startTime = TimeSpan.Zero;
//var duration = TimeSpan.FromMinutes(image1.Width);
var startTime = TimeSpan.FromHours(2);
var duration = TimeSpan.FromMinutes(60);
//var matrix = LdSpectrogramRibbons.ReadSpectralIndicesFromTwoFalseColourSpectrogramRibbons(image1, image2, startTime, duration);

//MatrixTools.WriteMatrix2File(matrix, outputPath.FullName);
Csv.WriteMatrixToCsv(outputPath, matrix);
}

// TODO: need to check that can recover ribbon image from reading this matrix.
}

/// <summary>
/// read a set of Spectral index files and extract values from frequency band
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PteropusSpecies.cs" company="QutEcoacoustics">
// <copyright file="LdSpectrogramRibbons.cs" company="QutEcoacoustics">
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group).
// </copyright>
// <summary>
Expand All @@ -9,11 +9,10 @@ namespace AudioAnalysisTools.LongDurationSpectrograms
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Drawing;
using System.IO;
using Acoustics.Shared.Csv;
using System.Linq;
using MoreLinq.Extensions;
using TowseyLibrary;

Expand All @@ -22,20 +21,13 @@ public static class LdSpectrogramRibbons
public const string SpectralRibbonTag = ".SpectralRibbon";
public const int RibbonPlotHeight = 32;

/// <summary>
/// Reads.
/// </summary>
public static void ReadSpectralIndicesFromTwoFalseColourSpectrogramRibbons()
{
}

/// <summary>
/// Reads the entire length of spectral ribbon images into a matrix of spectral indices.
/// IMPORTANT: Assume that the two images both have a time scale, that is, one pixel = one minute AND
/// IMPORTANT: Assume that the two images both have the same time scale, that is, one pixel = one minute AND
/// ASSUME they have the same pixel width i.e. span the same number of minutes.
/// </summary>
/// <param name="image1">spectrogram ribbon 1</param>
/// <param name="image2">spectrogram ribbon 2</param>
/// <param name="image1">spectrogram ribbon 1.</param>
/// <param name="image2">spectrogram ribbon 2.</param>
/// <returns>matrix of normalised spectral indices corresponding to those used to construct the ribbon images.</returns>
public static double[,] ReadSpectralIndicesFromTwoFalseColourSpectrogramRibbons(Image image1, Image image2)
{
Expand Down Expand Up @@ -133,17 +125,17 @@ public static List<double[,]> ReadSpectralIndicesFromFalseColourSpectrogram(Bitm
endMinute = image.Width;
}

var dataWidth = endMinute - startMinute + 1;
var dataWidth = endMinute - startMinute;
var height = image.Height;
var red = new double[dataWidth, height];
var grn = new double[dataWidth, height];
var blu = new double[dataWidth, height];

for (int w = startMinute; w < endMinute; w++)
for (int w = 0; w < dataWidth; w++)
{
for (int h = 0; h < height; h++)
{
var pixel = image.GetPixel(w, height - h - 1);
var pixel = image.GetPixel(w + startMinute, height - h - 1);
red[w, h] = pixel.R / 255D;
grn[w, h] = pixel.G / 255D;
blu[w, h] = pixel.B / 255D;
Expand All @@ -161,7 +153,7 @@ public static List<double[,]> ReadSpectralIndicesFromFalseColourSpectrogram(Bitm
}

/// <summary>
/// returns a Long Duration spectrogram of same image length as the full-scale LDspectrogram but the frequency scale reduced to the passed vlaue of height.
/// returns a Long Duration spectrogram of same image length as the full-scale LdSpectrogram but the frequency scale reduced to the passed vlaue of height.
/// This produces a LD spectrogram "ribbon" which can be used in circumstances where the full image is not appropriate.
/// Note that if the height passed is a power of 2, then the full frequency scale (also a power of 2 due to FFT) can be scaled down exactly.
/// A height of 32 is quite good - small but still discriminates frequency bands.
Expand Down

0 comments on commit 70277d4

Please sign in to comment.