public static Mat FindPoints(Mat mat, double threshold) { mat = NormalizationHelper.Normalization(mat); var result = new Mat(mat.Width, mat.Height); for (var x = 0; x < mat.Width; x++) { for (var y = 0; y < mat.Height; y++) { if (mat.GetAt(x, y) <= threshold || HasBetterNeighbour(mat, x, y)) { continue; } result.Set(x, y, mat.GetAt(x, y)); } } return(result); }