Esempio n. 1
0
        public static Dictionary <ImagePixel, double> LocateHotPixels(AstroImage image, int averageNTopCandidates)
        {
            var rv = LocateHotPixels(image, s_OriginalSample, s_OriginalSampleMedian);

            if (averageNTopCandidates > 0)
            {
                var allCenters = averageNTopCandidates < s_Candidates.Length
                    ? s_Candidates.Take(averageNTopCandidates)
                    : s_Candidates;

                // Horrible hack !!!
                s_CombinedSample     = new uint[7, 7];
                s_NumSamplesCombined = 1;

                foreach (var pixel in allCenters)
                {
                    var model = image.GetPixelsArea(pixel.X, pixel.Y, 7);
                    RegisterHotPixelSample(model, image.Pixelmap.MaxSignalValue);
                }

                rv = LocateHotPixels(image, s_CombinedSample, s_CombinedSampleMedian);
            }

            return(rv);
        }
Esempio n. 2
0
        public static Dictionary <ImagePixel, double> LocateHotPixels(AstroImage image, uint[,] model, uint modelMedian)
        {
            var rv = new Dictionary <ImagePixel, double>();

            if (s_NumSamplesCombined > 0)
            {
                int  width        = image.Pixelmap.Width;
                int  height       = image.Pixelmap.Height;
                uint abv          = model[3, 3] - modelMedian;
                uint minPeakLevel = (uint)(modelMedian + PEAK_PIXEL_LEVEL_REQUIRED * abv);
                EnumeratePeakPixels(image.Pixelmap.GetPixelsCopy(), width, height, minPeakLevel, Rectangle.Empty,
                                    (x, y, z) =>
                {
                    if (x >= 3 && x < width - 3 && y >= 3 && y < height - 3)
                    {
                        var newPix = new ImagePixel((int)z, x, y);
                        if (!rv.Keys.ToArray().Any(p => p.DistanceTo(newPix) < 5))
                        {
                            rv.Add(newPix, long.MinValue);
                        }
                    }
                });

                foreach (ImagePixel center in rv.Keys.ToArray())
                {
                    uint[,] testArea = image.GetPixelsArea(center.X, center.Y, 7);
                    var score = ScoreArea(testArea);
                    rv[center] = score.Item1;
                }

                var positions = rv.Keys.ToArray();
                var scores    = rv.Values.ToArray();
                Array.Sort(scores, positions);
                s_Candidates      = positions;
                s_CandidateScores = scores;
            }

            return(rv);
        }