} // CreateScorePlots() static Image DrawSonogram(BaseSonogram sonogram, double[,] hits, List <Plot> plots, List <AcousticEvent> predictedEvents) { bool doHighlightSubband = false; bool add1kHzLines = false; Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband, add1kHzLines)); //System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines); //img.Save(@"C:\SensorNetworks\temp\testimage1.png", System.Drawing.Imaging.ImageFormat.Png); //Image_MultiTrack image = new Image_MultiTrack(img); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (plots != null) { foreach (Plot plot in plots) { image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); } } //if (hits != null) image.OverlayRedTransparency(hits); if (hits != null) { image.OverlayRedMatrix(hits, 1.0); } if (predictedEvents.Count > 0) { image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(image.GetImage()); } //DrawSonogram()
private static Image DrawSonogram(BaseSonogram sonogram, double[,] hits, List <Plot> scores, List <Track> tracks) { Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage()); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (scores != null) { foreach (Plot plot in scores) { // assumes data normalized in 0,1 image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); } } if (tracks != null) { image.AddTracks(tracks, sonogram.FramesPerSecond, sonogram.FBinWidth); } if (hits != null) { image.OverlayRedMatrix(hits, 1.0); } return(image.GetImage()); }
public static Image DisplayDebugImage(BaseSonogram sonogram, List <AcousticEvent> events, List <Plot> scores, double[,] hits) { bool doHighlightSubband = false; bool add1kHzLines = true; Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband, add1kHzLines, doMelScale: false)); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); if (scores != null) { foreach (Plot plot in scores) { image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); //assumes data normalised in 0,1 } } if (hits != null) { image.OverlayRainbowTransparency(hits); } if (events.Count > 0) { foreach (AcousticEvent ev in events) // set colour for the events { ev.BorderColour = AcousticEvent.DefaultBorderColor; ev.ScoreColour = AcousticEvent.DefaultScoreColor; } image.AddEvents(events, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(image.GetImage()); }
/// <summary> /// THis method draws a sonogram with other useful information attached. /// </summary> /// <param name="sonogram">of BaseSonogram class.</param> /// <param name="events">a list of acoustic events.</param> /// <param name="plots">a list of plots relevant to the spectrogram scores.</param> /// <param name="hits">not often used - can be null.</param> public static Image GetSonogramPlusCharts(BaseSonogram sonogram, List <AcousticEvent> events, List <Plot> plots, double[,] hits) { var image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband: false, add1KHzLines: true, doMelScale: false)); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); if (plots != null) { foreach (var plot in plots) { image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); //assumes data normalised in 0,1 } } if (hits != null) { image.OverlayRainbowTransparency(hits); } if (events != null && events.Count > 0) { // set colour for the events foreach (AcousticEvent ev in events) { ev.BorderColour = AcousticEvent.DefaultBorderColor; ev.ScoreColour = AcousticEvent.DefaultScoreColor; } image.AddEvents(events, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(image.GetImage()); }
public void WriteDebugImage(string recordingFileName, DirectoryInfo outputDirectory, BaseSonogram sonogram, List <AcousticEvent> events, List <Plot> scores, double[,] hits) { //DEBUG IMAGE this recognizer only. MUST set false for deployment. bool displayDebugImage = MainEntry.InDEBUG; if (displayDebugImage) { bool doHighlightSubband = false; bool add1kHzLines = true; Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband, add1kHzLines, doMelScale: false)); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); if (scores != null) { foreach (Plot plot in scores) { image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); } //assumes data normalised in 0,1 } if (hits != null) { image.OverlayRainbowTransparency(hits); } if (events.Count > 0) { foreach (AcousticEvent ev in events) // set colour for the events { ev.BorderColour = AcousticEvent.DefaultBorderColor; ev.ScoreColour = AcousticEvent.DefaultScoreColor; } image.AddEvents( events, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } var debugImage = image.GetImage(); var debugPath = outputDirectory.Combine(FilenameHelpers.AnalysisResultName(Path.GetFileNameWithoutExtension(recordingFileName), this.Identifier, "png", "DebugSpectrogram")); debugImage.Save(debugPath.FullName); } }
protected virtual Image DrawSonogram( BaseSonogram sonogram, double[,] hits, List <Plot> scores, List <AcousticEvent> predictedEvents, double eventThreshold) { const bool doHighlightSubband = false; const bool add1KHzLines = true; var image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband, add1KHzLines, doMelScale: false)); ////System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines); ////img.Save(@"C:\SensorNetworks\temp\testimage1.png", System.Drawing.Imaging.ImageFormat.Png); ////Image_MultiTrack image = new Image_MultiTrack(img); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (scores != null) { foreach (var plot in scores) { image.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); } } if (hits != null) { image.OverlayRedTransparency(hits); } if (predictedEvents != null && predictedEvents.Count > 0) { image.AddEvents( predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } var result = image.GetImage(); return(result); }
/// <summary> /// Overlays the spectral cluster IDs on a spectrogram from which the clusters derived. /// </summary> public static Image DrawClusterSpectrogram(BaseSonogram sonogram, ClusterInfo clusterInfo, TrainingDataInfo data, int lowerBinBound) { using (var img = sonogram.GetImage(doHighlightSubband: false, add1KHzLines: true, doMelScale: false)) using (var image = new Image_MultiTrack(img)) { //image.AddTrack(ImageTrack.GetScoreTrack(DataTools.Bool2Binary(clusterInfo.selectedFrames),0.0, 1.0, 0.0)); //add time scale image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); // add cluster track, show ID of cluster of each frame string label = string.Format(clusterInfo.ClusterCount + " Clusters"); var scores = new Plot(label, DataTools.normalise(clusterInfo.ClusterHits2), 0.0); // location of cluster hits image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title)); // overlay cluster hits on spectrogram int[,] hits = AssembleClusterSpectrogram(sonogram.Data, lowerBinBound, clusterInfo, data); image.OverlayDiscreteColorMatrix(hits); return(image.GetImage()); }// using }
} // Analysis() private static Image DrawSonogram( BaseSonogram sonogram, double[,] hits, Plot scores, List <AcousticEvent> predictedEvents, double eventThreshold) { const bool DoHighlightSubband = false; const bool Add1KHzLines = true; var image = new Image_MultiTrack(sonogram.GetImage(DoHighlightSubband, Add1KHzLines)); ////System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines); ////img.Save(@"C:\SensorNetworks\temp\testimage1.png", System.Drawing.Imaging.ImageFormat.Png); ////Image_MultiTrack image = new Image_MultiTrack(img); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (scores != null) { image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title)); } if (hits != null) { image.OverlayRedTransparency(hits); } if ((predictedEvents != null) && (predictedEvents.Count > 0)) { image.AddEvents( predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(image.GetImage()); }
private static Image DrawSonogram( BaseSonogram sonogram, double[,] hits, Plot scores, List <AcousticEvent> predictedEvents, double eventThreshold) { var image = new Image_MultiTrack(sonogram.GetImage()); ////System.Drawing.Image img = sonogram.GetImage(doHighlightSubband, add1kHzLines); ////Image_MultiTrack image = new Image_MultiTrack(img); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (scores != null) { image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title)); } ////if (hits != null) image.OverlayRedTransparency(hits); if (hits != null) { image.OverlayRainbowTransparency(hits); } if (predictedEvents != null && predictedEvents.Count > 0) { image.AddEvents( predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(image.GetImage()); }
public static Image DrawSonogram(BaseSonogram sonogram, Plot scores, List <AcousticEvent> poi, double eventThreshold, double[,] overlay) { Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(doHighlightSubband: false, add1KHzLines: false, doMelScale: false)); image.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); image.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); if (scores != null) { image.AddTrack(ImageTrack.GetNamedScoreTrack(scores.data, 0.0, 1.0, scores.threshold, scores.title)); } if (poi != null && poi.Count > 0) { image.AddEvents(poi, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } if (overlay != null) { var m = MatrixTools.ThresholdMatrix2Binary(overlay, 0.5); image.OverlayDiscreteColorMatrix(m); } return(image.GetImage()); }
}//Sonogram2MultiTrackImage() public static Image Sonogram2Image(BaseSonogram sonogram, Dictionary <string, string> configDict, double[,] hits, List <Plot> scores, List <AcousticEvent> predictedEvents, double eventThreshold) { Image_MultiTrack multiTrackImage = Sonogram2MultiTrackImage(sonogram, configDict); if (scores != null) { foreach (Plot plot in scores) { multiTrackImage.AddTrack(ImageTrack.GetNamedScoreTrack(plot.data, 0.0, 1.0, plot.threshold, plot.title)); //assumes data normalised in 0,1 } } if (hits != null) { multiTrackImage.OverlayRainbowTransparency(hits); } if (predictedEvents.Count > 0) { multiTrackImage.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond); } return(multiTrackImage.GetImage()); } //Sonogram2Image()