Пример #1
0
        /// <summary>
        /// Creates a new ImageDetection by merging the blobs of other detections. Requires the input ImageDetections to have <see cref="ObjectPoints"/> property.
        /// </summary>
        /// <param name="Detections">The list of input detections to merge.</param>
        /// <returns>A new instance of ImageDetection.</returns>
        public static ImageDetection MergeStandardDetections(ImageDetection[] Detections)
        {
            List <PixelPoint> Pixels   = new List <PixelPoint>();
            List <double>     Values   = new List <double>();
            PairingProperties KeptProp = null;

            foreach (ImageDetection imd in Detections)
            {
                if (imd.TryFetchProperty(out ObjectPoints ojp))
                {
                    Pixels.AddRange(ojp.PixelPoints);
                    Values.AddRange(ojp.PixelValues);
                    imd.TryFetchProperty(out PairingProperties Kprop);
                    if (KeptProp == null)
                    {
                        KeptProp = Kprop;
                    }
                    else
                    {
                        KeptProp.Algorithm |= Kprop.Algorithm;
                    }
                }
            }

            if (Pixels.Count == 0)
            {
                if (Detections.Length != 1)
                {
                    if (KeptProp == null)
                    {
                        KeptProp = new PairingProperties();
                    }
                    KeptProp.MultiNoPoints = true;
                }
                return(Detections[0]);
            }
            ImageDetection Result = StandardDetectionFactory.CreateDetection(Detections[0].ParentImage, Pixels, Values);

            if (KeptProp != null)
            {
                Result.SetResetProperty(KeptProp);
            }
            return(Result);
        }
Пример #2
0
        public bool PairPossible(ImageDetection a, ImageDetection b)
        {
            PairingProperties App = a.FetchOrCreate <PairingProperties>(), Bpp = b.FetchOrCreate <PairingProperties>();

            if (App.IsPaired || Bpp.IsPaired)
            {
                return(false);
            }
            if (App.StarPolluted || Bpp.StarPolluted)
            {
                return(false);
            }
            if (a.Time.Time == b.Time.Time)
            {
                return(false);
            }
            TimeSpan DeltaTime = a.Time.Time - b.Time.Time;
            //if ((a.LargestDistance + b.LargestDistance) * Math.Abs(DeltaTime.TotalSeconds) < (a.Barycenter.EP ^ b.Barycenter.EP) * (a.Time.Exposure.TotalSeconds + b.Time.Exposure.TotalSeconds) / 2) return false;

            SourceEllipse aPel = a.FetchProperty <ObjectSize>().PixelEllipse, bPel = b.FetchProperty <ObjectSize>().PixelEllipse;

            if (aPel.SemiaxisMajor > LongTrailHighThreshold * LongTrailHighThreshold)
            {
                if (bPel.SemiaxisMajor < LongTrailLowThreshold * LongTrailLowThreshold)
                {
                    return(false);
                }
            }
            double DeltaAngle = aPel.SemiaxisMajorAngle - bPel.SemiaxisMajorAngle;
            double Length     = aPel.SemiaxisMajor + bPel.SemiaxisMajor;

            if (DeltaAngle * DeltaAngle * Math.Sqrt(Length) > AngleDistanceDifferenceThreshold)
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
        static ImageDetection Transform(ObsEntry Entry, FitsImage AssociatedImage)
        {
            EquatorialPoint eqp = new EquatorialPoint()
            {
                RA = Entry.RA / 180 * Math.PI, Dec = Entry.Dec / 180 * Math.PI
            };
            PixelPoint pp = new PixelPoint()
            {
                X = Entry.X, Y = Entry.Y
            };
            Position       p   = new Position(eqp, pp);
            ImageDetection det = new ImageDetection(p, AssociatedImage.GetProperty <ObservationTime>(), AssociatedImage);

            bool       Ellipse = false;
            ObjectSize sz      = new ObjectSize();

            if (Entry.A.HasValue && Entry.B.HasValue)
            {
                sz.PixelEllipse = new SourceEllipse()
                {
                    SemiaxisMajor = Entry.A.Value, SemiaxisMinor = Entry.B.Value
                };
                Ellipse = true;
            }
            else if (Entry.FWHM.HasValue && Entry.Ellipticity.HasValue)
            {
                sz.PixelEllipse = new SourceEllipse()
                {
                    SemiaxisMajor = Entry.FWHM.Value / Math.Sqrt(1 - Entry.Ellipticity.Value),
                    SemiaxisMinor = Entry.FWHM.Value * Math.Sqrt(1 - Entry.Ellipticity.Value),
                };
                Ellipse = true;
            }
            if (Ellipse)
            {
                if (Entry.EllipseTheta.HasValue)
                {
                    sz.PixelEllipse.SemiaxisMajorAngle = Entry.EllipseTheta.Value / 180 * Math.PI;
                }
                det.AppendProperty(sz);
            }

            PairingProperties pprop = new PairingProperties()
            {
                IsDotDetection = Ellipse && (sz.PixelEllipse.SemiaxisMajor < 2 * sz.PixelEllipse.SemiaxisMinor),
                IsPaired       = false,
                PearsonR       = 0,
                StarPolluted   = false,
                Algorithm      = DetectionAlgorithm.SourceExtractor
            };

            det.AppendProperty(pprop);
            if (Entry.Flux.HasValue)
            {
                ObjectPhotometry oph = new ObjectPhotometry()
                {
                    Flux = Entry.Flux.Value, Magnitude = Entry.Mag.Value
                };
                det.AppendProperty(oph);
            }

            return(det);
        }