/// <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());
        }
示例#2
0
        }//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()
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Image_MultiTrack Sonogram2MultiTrackImage(BaseSonogram sonogram, Dictionary <string, string> configDict)
        {
            bool doHighlightSubband = false;

            //check if doing a reduced sonogram
            //int timeReductionFactor = 1;
            //if (configDict.ContainsKey(Keys.TIME_REDUCTION_FACTOR))
            //    timeReductionFactor = ConfigDictionary.GetInt(Keys.TIME_REDUCTION_FACTOR, configDict);
            //int freqReductionFactor = 1;
            //if (configDict.ContainsKey(Keys.FREQ_REDUCTION_FACTOR))
            //    freqReductionFactor = ConfigDictionary.GetInt(Keys.FREQ_REDUCTION_FACTOR, configDict);
            //if (!((timeReductionFactor == 1) && (freqReductionFactor == 1)))
            //{
            //    sonogram.Data = ReduceDimensionalityOfSpectrogram(sonogram.Data, timeReductionFactor, freqReductionFactor);
            //    return sonogram.GetImage(doHighlightSubband, add1kHzLines);
            //}

            // (iii) NOISE REDUCTION
            //bool doNoiseReduction = false;
            //if (configDict.ContainsKey(AnalysisKeys.NoiseDoReduction))
            //    doNoiseReduction = ConfigDictionary.GetBoolean(AnalysisKeys.NoiseDoReduction, configDict);
            //if (doNoiseReduction)
            //{
            //    //LoggedConsole.WriteLine("PERFORMING NOISE REDUCTION");
            //    double bgThreshold = 3.0;
            //    if (configDict.ContainsKey(AnalysisKeys.NoiseBgThreshold))
            //        bgThreshold = ConfigDictionary.GetDouble(AnalysisKeys.NoiseBgThreshold, configDict);
            //    var tuple = SNR.NoiseReduce(sonogram.Data, NoiseReductionType.STANDARD, bgThreshold);
            //    sonogram.Data = tuple.Item1;   // store data matrix
            //}

            //ADD time and frequency scales
            bool addScale = false;

            if (configDict.ContainsKey(AnalysisKeys.AddTimeScale))
            {
                addScale = ConfigDictionary.GetBoolean(AnalysisKeys.AddTimeScale, configDict);
            }
            else
            if (configDict.ContainsKey(AnalysisKeys.AddAxes))
            {
                addScale = ConfigDictionary.GetBoolean(AnalysisKeys.AddAxes, configDict);
            }

            Image            img = sonogram.GetImage(doHighlightSubband, add1KHzLines: addScale, doMelScale: false);
            Image_MultiTrack mti = new Image_MultiTrack(img);

            if (addScale)
            {
                mti.AddTrack(ImageTrack.GetTimeTrack(sonogram.Duration, sonogram.FramesPerSecond)); //add time scale
            }

            bool addSegmentationTrack = false;

            //add segmentation track
            if (configDict.ContainsKey(AnalysisKeys.AddSegmentationTrack))
            {
                addSegmentationTrack = ConfigDictionary.GetBoolean(AnalysisKeys.AddSegmentationTrack, configDict);
            }

            if (addSegmentationTrack)
            {
                mti.AddTrack(ImageTrack.GetSegmentationTrack(sonogram)); //add segmentation track
            }

            return(mti);

            //mti.AddTrack(ImageTrack.GetWavEnvelopeTrack(sonogram)); //add segmentation track
        }//Sonogram2MultiTrackImage()