internal Dictionary <TrackingMarker, Point2D> IdentifyMarkers(Frame frame)
        {
            int x0 = searchSpace.RangeX.Low, x1 = searchSpace.RangeX.High;
            int y0 = searchSpace.RangeY.Low, y1 = searchSpace.RangeY.High;
            int clipWidth  = x1 - x0;
            int clipHeight = y1 - y0;

            var output = new Dictionary <TrackingMarker, Point2D>();

            foreach (TrackingMarker marker in this.markers)
            {
                // threshold
                var hueTolerance = marker.HueTolerance;
                var thresh       = ClipAndThreshold(
                    frame.Colour,
                    FormatConvertor.PixelWidth(frame.ColourFormat),
                    FormatConvertor.PixelHeight(frame.ColourFormat),
                    x0, x1, y0, y1,
                    marker.Hue - hueTolerance,
                    marker.Hue + hueTolerance);

                if (DebugSettings.Default.DebugMode)
                {
                    ImageWriter.WritePPM(
                        thresh, clipWidth, clipHeight, DebugSettings.Default.LogRoot + @"\cv\" +
                        marker.Name.ToString() + ".thresh" + frame.FrameNumber + ".ppm", 1);
                }

                // remove outliers
                var cleanThresh = CleanImage(thresh, clipWidth, clipHeight);

                if (DebugSettings.Default.DebugMode)
                {
                    ImageWriter.WritePPM(
                        cleanThresh, clipWidth, clipHeight, DebugSettings.Default.LogRoot + @"\cv\" +
                        marker.Name.ToString() + ".thresh" + frame.FrameNumber + ".clean.ppm", 1);
                }

                // calculate centre
                var momentX = CalcMomentXOrder1(cleanThresh, clipWidth, clipHeight);
                var momentY = CalcMomentYOrder1(cleanThresh, clipWidth, clipHeight);
                var momentAv = CalcMomentXYOrder00(cleanThresh, clipWidth, clipHeight);
                int x = (int)(momentX / momentAv); int y = (int)(momentY / momentAv);
                var pointXY = new Point2D(x0 + x, y0 + y);

                // test confidence
                var count = CountPixelsSet(cleanThresh);
                if (count > ImageAnalysis.Settings.Default.MinimumThresholdPixels)
                {
                    output.Add(marker, pointXY);
                }
            }
            return(output);
        }