Exemple #1
0
        /// <summary>
        /// Attempts to recover a detection on an image.
        /// </summary>
        /// <returns>The recovered object.</returns>
        /// <param name="Location">Location which to check.</param>
        /// <param name="Radius">Maximum radius of the detection.</param>
        /// <param name="RecoveryImage">Image on which to perform the recovery.</param>
        private DotDetector.DotDetection Recover(PixelPoint Location, double Radius, Image RecoveryImage)
        {
            /* Area in the image to retrieve */
            System.Drawing.Rectangle r = new System.Drawing.Rectangle((int)Math.Round(Location.X) - HalfLength, (int)Math.Round(Location.Y) - HalfLength,
                                                                      2 * HalfLength, 2 * HalfLength);

            bool[,] Mask = new bool[2 * HalfLength, 2 * HalfLength];
            /* Mask areas outside Radius */
            for (int i = 0; i < 2 * HalfLength; i++)
            {
                for (int j = 0; j < 2 * HalfLength; j++)
                {
                    if (!InDisk(i, j, Radius))
                    {
                        Mask[i, j] = true;
                    }
                }
            }

            ImageData dt = RecoveryImage.LockData(r, true);

            /* Compute background level of the area */
            var sts = RecoveryImage.GetProperty <ImageStatistics>();

            ComputeSmartStats(dt.Data, 10 * sts.StDev, out double Median, out double MedSigma);

            /* Perform recovery */
            DotDetector.IntPoint Position = new DotDetector.IntPoint()
            {
                X = HalfLength, Y = HalfLength
            };
            var det = DotDetector.BitmapFill(dt.Data, Position, Mask, ThresholdMultiplier * MedSigma, r.X, r.Y);

            RecoveryImage.ExitLock(dt);

            return(det);
        }