fixed grammar error and changed some code for debugging
This commit is contained in:
parent
d322503403
commit
d227dfbc66
@ -33,7 +33,7 @@ public class ImageScanner {
|
|||||||
|
|
||||||
// The following line might be incorrect; TODO double check and write a test
|
// The following line might be incorrect; TODO double check and write a test
|
||||||
Point2D brightPoints[] = brightSpots.stream()
|
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);
|
.toArray(Point2D.Double[]::new);
|
||||||
|
|
||||||
Point2D brightestSpot = new PointInterpolator(brightPoints).getCenter();
|
Point2D brightestSpot = new PointInterpolator(brightPoints).getCenter();
|
||||||
@ -56,16 +56,18 @@ public class ImageScanner {
|
|||||||
double BRdistance = brightestBlueSpot.distanceSq(brightestRedSpot);
|
double BRdistance = brightestBlueSpot.distanceSq(brightestRedSpot);
|
||||||
|
|
||||||
PointInterpolator brightestSpot;
|
PointInterpolator brightestSpot;
|
||||||
|
|
||||||
|
brightestSpot = new PointInterpolator(brightestRedSpot);
|
||||||
|
|
||||||
// Get the center between the two closest points; a better implementation would
|
// // Get the center between the two closest points; a better implementation would
|
||||||
// work with a confidentnes-value
|
// // work on a confidentnes-value
|
||||||
if (RGdistance < GBdistance && RGdistance < BRdistance) {
|
// if (RGdistance < GBdistance && RGdistance < BRdistance) {
|
||||||
brightestSpot = new PointInterpolator(brightestRedSpot, brightestGreenSpot);
|
// brightestSpot = new PointInterpolator(brightestRedSpot, brightestGreenSpot);
|
||||||
} else if (GBdistance < RGdistance && GBdistance < BRdistance) {
|
// } else if (GBdistance < RGdistance && GBdistance < BRdistance) {
|
||||||
brightestSpot = new PointInterpolator(brightestGreenSpot, brightestBlueSpot);
|
// brightestSpot = new PointInterpolator(brightestGreenSpot, brightestBlueSpot);
|
||||||
} else {
|
// } else {
|
||||||
brightestSpot = new PointInterpolator(brightestBlueSpot, brightestRedSpot);
|
// brightestSpot = new PointInterpolator(brightestBlueSpot, brightestRedSpot);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return brightestSpot.getCenter();
|
return brightestSpot.getCenter();
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ public class PointInterpolator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Point2D getCenter() {
|
Point2D getCenter() {
|
||||||
int xSum = 0;
|
double xSum = 0;
|
||||||
int ySum = 0;
|
double ySum = 0;
|
||||||
|
|
||||||
for(int i = 0; i < points.length; i++) {
|
for(int i = 0; i < points.length; i++) {
|
||||||
xSum += points[i].getX();
|
xSum += points[i].getX();
|
||||||
|
Loading…
Reference in New Issue
Block a user