fixed grammar error and changed some code for debugging

This commit is contained in:
Paul Schaller 2023-11-20 14:47:40 +01:00
parent d322503403
commit d227dfbc66
2 changed files with 14 additions and 12 deletions

View File

@ -33,7 +33,7 @@ public class ImageScanner {
// The following line might be incorrect; TODO double check and write a test
Point2D brightPoints[] = brightSpots.stream()
.map(s -> new Point2D.Double(s.intValue() % grayScaleImage.getWidth(), s.intValue() / grayScaleImage.getWidth()))
.map(s -> new Point2D.Double(s.intValue() % grayScaleImage.getWidth(), s.intValue() / grayScaleImage.getWidth())) // https://softwareengineering.stackexchange.com/questions/212808/treating-a-1d-data-structure-as-2d-grid
.toArray(Point2D.Double[]::new);
Point2D brightestSpot = new PointInterpolator(brightPoints).getCenter();
@ -57,15 +57,17 @@ public class ImageScanner {
PointInterpolator brightestSpot;
// Get the center between the two closest points; a better implementation would
// work with a confidentnes-value
if (RGdistance < GBdistance && RGdistance < BRdistance) {
brightestSpot = new PointInterpolator(brightestRedSpot, brightestGreenSpot);
} else if (GBdistance < RGdistance && GBdistance < BRdistance) {
brightestSpot = new PointInterpolator(brightestGreenSpot, brightestBlueSpot);
} else {
brightestSpot = new PointInterpolator(brightestBlueSpot, brightestRedSpot);
}
brightestSpot = new PointInterpolator(brightestRedSpot);
// // Get the center between the two closest points; a better implementation would
// // work on a confidentnes-value
// if (RGdistance < GBdistance && RGdistance < BRdistance) {
// brightestSpot = new PointInterpolator(brightestRedSpot, brightestGreenSpot);
// } else if (GBdistance < RGdistance && GBdistance < BRdistance) {
// brightestSpot = new PointInterpolator(brightestGreenSpot, brightestBlueSpot);
// } else {
// brightestSpot = new PointInterpolator(brightestBlueSpot, brightestRedSpot);
// }
return brightestSpot.getCenter();
}

View File

@ -10,8 +10,8 @@ public class PointInterpolator {
}
Point2D getCenter() {
int xSum = 0;
int ySum = 0;
double xSum = 0;
double ySum = 0;
for(int i = 0; i < points.length; i++) {
xSum += points[i].getX();