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());
        }
        static Image DrawSonogram(BaseSonogram sonogram, double[,] hits, double[] scores, List <AcousticEvent> predictedEvents, double eventThreshold)
        {
            Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage());

            //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.GetScoreTrack(scores, 0.0, 0.5, eventThreshold));
            }
            //if (hits != null) image.OverlayRedTransparency(hits);
            if (hits != null)
            {
                image.OverlayRainbowTransparency(hits);
            }
            if (predictedEvents.Count > 0)
            {
                image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
            }
            return(image.GetImage());
        } //DrawSonogram()
示例#3
0
        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);
            }
        }
示例#4
0
        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());
        }
        static Image DrawSonogram(BaseSonogram sonogram, double[,] hits, List <double[]> scores, List <AcousticEvent> predictedEvents, double eventThreshold)
        {
            bool             doHighlightSubband = false; bool add1kHzLines = true;
            int              maxFreq = sonogram.NyquistFrequency / 2;
            Image_MultiTrack image = new Image_MultiTrack(sonogram.GetImage(maxFreq, 1, doHighlightSubband, add1kHzLines));

            image.AddTrack(Image_Track.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond));
            if (scores != null)
            {
                foreach (double[] array in scores)
                {
                    image.AddTrack(Image_Track.GetScoreTrack(array, 0.0, 1.0, eventThreshold));
                }
            }
            if (hits != null)
            {
                image.OverlayRainbowTransparency(hits);
            }
            if (predictedEvents.Count > 0)
            {
                image.AddEvents(predictedEvents, sonogram.NyquistFrequency, sonogram.Configuration.FreqBinCount, sonogram.FramesPerSecond);
            }
            return(image.GetImage());
        } //DrawSonogram()