public LasPoint.ClassificationType[] Classify(LasFile file) { var sw = Stopwatch.StartNew(); LasPointDataRecords points = file.LasPointDataRecords; int pointsCount = points.Count(); LasPoint.ClassificationType[] output = new LasPoint.ClassificationType[pointsCount]; Statistics stats = new Statistics(); stats.Count = pointsCount; OpenTK.Vector3[] slopeVector = new OpenTK.Vector3[pointsCount]; Parallel.For(0, pointsCount, (i) => { slopeVector[i] = LinearRegression.ComputeRegressionPoint(file, points[i], regressionCount, regressionRange); if (i % 1000 == 0) { Console.WriteLine("ComputeRegression " + i); } }); for (int i = 0; i < pointsCount; i++) { LasPoint3Short point = (LasPoint3Short)points[i]; double distanceFromPlane = Utills.DistanceFromPlane(point, slopeVector[i]); double green = point.Green - (point.Red + point.Blue) / 2; output[i] = Utills.ClassificationClasses[knn.Compute(new double[] { green, file.LasHeader.ScaleZ(point.Z), point.Intensity, slopeVector[i].X, slopeVector[i].Y, slopeVector[i].Z, distanceFromPlane })]; if (output[i] != points[i].Classification) { stats.ClassErrors[(int)points[i].Classification]++; } stats.ClassCount[(int)output[i]]++; stats.ClassRealCount[(int)points[i].Classification]++; stats.PredictionMatrix[(int)points[i].Classification, (int)output[i]]++; if (i % 1000 == 0) { Console.WriteLine(i); } } Console.Write(stats.ToString()); sw.Stop(); Console.WriteLine("Czas trwania [" + sw.Elapsed.TotalSeconds.ToString() + "s]"); stats.SaveMatrixAsCSV(); return(output); }
public LasPoint.ClassificationType[] Classify(LasFile file) { var sw = Stopwatch.StartNew(); LasPointDataRecords points = file.LasPointDataRecords; int pointsCount = points.Count(); LasPoint.ClassificationType[] output = new LasPoint.ClassificationType[pointsCount]; Statistics stats = new Statistics(); stats.Count = pointsCount; for (int i = 0; i < pointsCount; i++) { LasPoint3Short point = (LasPoint3Short)points[i]; double green = point.Green - (point.Red + point.Blue) / 2; output[i] = Utills.ClassificationClasses[knn.Compute(new double[] { file.LasHeader.ScaleZ(point.Z), point.Intensity, green })]; if (output[i] != points[i].Classification) { stats.ClassErrors[(int)points[i].Classification]++; } stats.ClassCount[(int)output[i]]++; stats.ClassRealCount[(int)points[i].Classification]++; stats.PredictionMatrix[(int)points[i].Classification, (int)output[i]]++; if (i % 1000 == 0) { Console.WriteLine(i); } } Console.Write(stats.ToString()); sw.Stop(); Console.WriteLine("Czas trwania [" + sw.Elapsed.TotalSeconds.ToString() + "s]"); stats.SaveMatrixAsCSV(); return(output); }