internal static List <PotentialStarStruct> GetPeakPixelsInArea( uint[,] data, out uint[,] lpdData, int bpp, uint maxSignalValue, uint aboveNoiseLevelRequired, double minDistanceInPixels, bool useLPDFilter, Rectangle excludeArea) { if (useLPDFilter) { lpdData = ImageFilters.LowPassDifferenceFilter(data, bpp, false); } else { lpdData = data; } int nWidth = lpdData.GetLength(0); int nHeight = lpdData.GetLength(1); List <PotentialStarStruct> potentialStars = new List <PotentialStarStruct>(); ExaminePeakPixelCandidate examinePixelCallback = delegate(int x, int y, uint z) { bool tooClose = false; // Local maximum, test for a star foreach (PotentialStarStruct prevStar in potentialStars) { double dist = Math.Sqrt((prevStar.X - x) * (prevStar.X - x) + (prevStar.Y - y) * (prevStar.Y - y)); if (dist <= minDistanceInPixels) { tooClose = true; if (prevStar.Z < z) { prevStar.Z = z; prevStar.X = x; prevStar.Y = y; } break; } } if (!tooClose) { potentialStars.Add(new PotentialStarStruct() { X = x, Y = y, Z = z }); } // An early return if too many peak pixels have been found return(potentialStars.Count <= TangraConfig.Settings.Special. StarFinderMaxNumberOfPotentialStars); }; if (useLPDFilter) { CheckAllPixels(lpdData, nWidth, nHeight, aboveNoiseLevelRequired, excludeArea, examinePixelCallback); } else { CheckPixelsFromBrightToFaint(lpdData, nWidth, nHeight, bpp, maxSignalValue, aboveNoiseLevelRequired, excludeArea, examinePixelCallback); } return(potentialStars); }