Changed the SideScanner API to be more maintainable
This commit is contained in:
parent
ffd38dcd85
commit
aa45c6926f
@ -0,0 +1,62 @@
|
||||
package com.cringe_studios.christmastreescanning.scanning;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class MultiColoredSideScanner extends SideScanner{
|
||||
private BufferedImage sideImagesRed[];
|
||||
private BufferedImage sideImagesGreen[];
|
||||
private BufferedImage sideImagesBlue[];
|
||||
|
||||
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
||||
double baseline = 0.0;
|
||||
double minX = Double.NEGATIVE_INFINITY;
|
||||
double maxX = Double.POSITIVE_INFINITY;
|
||||
|
||||
boolean useDefaultValues;
|
||||
|
||||
Point2D foundPoints[] = null;
|
||||
|
||||
public MultiColoredSideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
this.sideImagesRed = imagesRed;
|
||||
this.sideImagesGreen = imagesGreen;
|
||||
this.sideImagesBlue = imagesBlue;
|
||||
|
||||
this.gammaDelta = gammaDelta;
|
||||
this.baseline = baseline;
|
||||
this.minX = minX;
|
||||
this.maxX = maxX;
|
||||
|
||||
this.useDefaultValues = false;
|
||||
}
|
||||
|
||||
public MultiColoredSideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue) {
|
||||
if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
|
||||
this.sideImagesRed = imagesRed;
|
||||
this.sideImagesGreen = imagesGreen;
|
||||
this.sideImagesBlue = imagesBlue;
|
||||
|
||||
this.useDefaultValues = true;
|
||||
}
|
||||
|
||||
public void scan() {
|
||||
int imagesLength = this.sideImagesRed.length;
|
||||
|
||||
foundPoints = new Point2D[imagesLength];
|
||||
|
||||
for(int i = 0; i < imagesLength; i++) {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(this.sideImagesRed[i], this.sideImagesGreen[i], this.sideImagesBlue[i], this.gammaDelta);
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D[] getPoints() {
|
||||
return foundPoints;
|
||||
}
|
||||
|
||||
public void normalizePoints() {
|
||||
if(foundPoints == null); //TODO error
|
||||
//TODO
|
||||
}
|
||||
}
|
@ -3,93 +3,93 @@ package com.cringe_studios.christmastreescanning.scanning;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class SideScanner {
|
||||
private BufferedImage sideImages[];
|
||||
private BufferedImage sideImagesRed[];
|
||||
private BufferedImage sideImagesGreen[];
|
||||
private BufferedImage sideImagesBlue[];
|
||||
public abstract class SideScanner {
|
||||
// private BufferedImage sideImages[];
|
||||
// private BufferedImage sideImagesRed[];
|
||||
// private BufferedImage sideImagesGreen[];
|
||||
// private BufferedImage sideImagesBlue[];
|
||||
//
|
||||
protected byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
||||
protected double baseline = 0.0;
|
||||
protected double minX = Double.NEGATIVE_INFINITY;
|
||||
protected double maxX = Double.POSITIVE_INFINITY;
|
||||
|
||||
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
||||
double baseline = 0.0;
|
||||
double minX = Double.NEGATIVE_INFINITY;
|
||||
double maxX = Double.POSITIVE_INFINITY;
|
||||
protected boolean useDefaultValues;
|
||||
|
||||
boolean useDefaultValues;
|
||||
protected Point2D foundPoints[] = null;
|
||||
//
|
||||
// public SideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
// this.sideImages = images;
|
||||
//
|
||||
// this.gammaDelta = gammaDelta;
|
||||
// this.baseline = baseline;
|
||||
// this.minX = minX;
|
||||
// this.maxX = maxX;
|
||||
//
|
||||
// this.useDefaultValues = false;
|
||||
// }
|
||||
//
|
||||
// public SideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
// if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
// this.sideImagesRed = imagesRed;
|
||||
// this.sideImagesGreen = imagesGreen;
|
||||
// this.sideImagesBlue = imagesBlue;
|
||||
//
|
||||
// this.gammaDelta = gammaDelta;
|
||||
// this.baseline = baseline;
|
||||
// this.minX = minX;
|
||||
// this.maxX = maxX;
|
||||
//
|
||||
// this.useDefaultValues = false;
|
||||
// }
|
||||
//
|
||||
// // Everything default values
|
||||
// public SideScanner(BufferedImage[] images) {
|
||||
// this.sideImages = images;
|
||||
//
|
||||
// this.useDefaultValues = true;
|
||||
// }
|
||||
//
|
||||
// public SideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue) {
|
||||
// if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
//
|
||||
// this.sideImagesRed = imagesRed;
|
||||
// this.sideImagesGreen = imagesGreen;
|
||||
// this.sideImagesBlue = imagesBlue;
|
||||
//
|
||||
// this.useDefaultValues = true;
|
||||
// }
|
||||
|
||||
Point2D foundPoints[] = null;
|
||||
public abstract void scan();// {
|
||||
// int imagesLength = 0;
|
||||
// if(this.sideImages != null) {
|
||||
// imagesLength = this.sideImages.length;
|
||||
// }else {
|
||||
// imagesLength = this.sideImagesRed.length;
|
||||
// }
|
||||
//
|
||||
// foundPoints = new Point2D[imagesLength];
|
||||
//
|
||||
// for(int i = 0; i < imagesLength; i++) {
|
||||
// if(this.sideImages != null) {
|
||||
// if(this.useDefaultValues) {
|
||||
// foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i]);
|
||||
// }else {
|
||||
// foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i], this.gammaDelta);
|
||||
// }
|
||||
// }else {
|
||||
// foundPoints[i] = ImageScanner.getBrightestSpot(this.sideImagesRed[i], this.sideImagesGreen[i], this.sideImagesBlue[i], this.gammaDelta);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public SideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
this.sideImages = images;
|
||||
|
||||
this.gammaDelta = gammaDelta;
|
||||
this.baseline = baseline;
|
||||
this.minX = minX;
|
||||
this.maxX = maxX;
|
||||
|
||||
this.useDefaultValues = false;
|
||||
}
|
||||
public abstract Point2D[] getPoints(); //{
|
||||
// return foundPoints;
|
||||
// }
|
||||
|
||||
public SideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
this.sideImagesRed = imagesRed;
|
||||
this.sideImagesGreen = imagesGreen;
|
||||
this.sideImagesBlue = imagesBlue;
|
||||
|
||||
this.gammaDelta = gammaDelta;
|
||||
this.baseline = baseline;
|
||||
this.minX = minX;
|
||||
this.maxX = maxX;
|
||||
|
||||
this.useDefaultValues = false;
|
||||
}
|
||||
|
||||
// Everything default values
|
||||
public SideScanner(BufferedImage[] images) {
|
||||
this.sideImages = images;
|
||||
|
||||
this.useDefaultValues = true;
|
||||
}
|
||||
|
||||
public SideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue) {
|
||||
if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
|
||||
|
||||
this.sideImagesRed = imagesRed;
|
||||
this.sideImagesGreen = imagesGreen;
|
||||
this.sideImagesBlue = imagesBlue;
|
||||
|
||||
this.useDefaultValues = true;
|
||||
}
|
||||
|
||||
public void scan() {
|
||||
int imagesLength = 0;
|
||||
if(this.sideImages != null) {
|
||||
imagesLength = this.sideImages.length;
|
||||
}else {
|
||||
imagesLength = this.sideImagesRed.length;
|
||||
}
|
||||
|
||||
foundPoints = new Point2D[imagesLength];
|
||||
|
||||
for(int i = 0; i < imagesLength; i++) {
|
||||
if(this.sideImages != null) {
|
||||
if(this.useDefaultValues) {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i]);
|
||||
}else {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i], this.gammaDelta);
|
||||
}
|
||||
}else {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(this.sideImagesRed[i], this.sideImagesGreen[i], this.sideImagesBlue[i], this.gammaDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D[] getPoints() {
|
||||
return foundPoints;
|
||||
}
|
||||
|
||||
public void normalizePoints() {
|
||||
if(foundPoints == null); //TODO error
|
||||
//TODO
|
||||
}
|
||||
public abstract void normalizePoints(); //{
|
||||
// if(foundPoints == null); //TODO error
|
||||
// //TODO
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.cringe_studios.christmastreescanning.scanning;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class SingleColoredSideScanner extends SideScanner {
|
||||
private BufferedImage sideImages[];
|
||||
|
||||
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
||||
double baseline = 0.0;
|
||||
double minX = Double.NEGATIVE_INFINITY;
|
||||
double maxX = Double.POSITIVE_INFINITY;
|
||||
|
||||
boolean useDefaultValues;
|
||||
|
||||
Point2D foundPoints[] = null;
|
||||
|
||||
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX,
|
||||
double maxX) {
|
||||
this.sideImages = images;
|
||||
|
||||
this.gammaDelta = gammaDelta;
|
||||
this.baseline = baseline;
|
||||
this.minX = minX;
|
||||
this.maxX = maxX;
|
||||
|
||||
this.useDefaultValues = false;
|
||||
}
|
||||
|
||||
// Everything default values
|
||||
public SingleColoredSideScanner(BufferedImage[] images) {
|
||||
this.sideImages = images;
|
||||
|
||||
this.useDefaultValues = true;
|
||||
}
|
||||
|
||||
public void scan() {
|
||||
int imagesLength = this.sideImages.length;
|
||||
|
||||
foundPoints = new Point2D[imagesLength];
|
||||
|
||||
for (int i = 0; i < imagesLength; i++) {
|
||||
if (this.useDefaultValues) {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i]);
|
||||
} else {
|
||||
foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i], this.gammaDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Point2D[] getPoints() {
|
||||
return foundPoints;
|
||||
}
|
||||
|
||||
public void normalizePoints() {
|
||||
if (foundPoints == null)
|
||||
; // TODO error
|
||||
// TODO
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class ExampleTest {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
try {
|
||||
BufferedImage image = ImageIO.read(ExampleTest.class.getResourceAsStream("/0_" + i + ".png"));
|
||||
Point2D p = ImageScanner.getBrightestSpot(image);
|
||||
Point2D p = ImageScanner.getBrightestSpot(image, (byte)(0.1 * 255));
|
||||
for (int j = -2; j < 2; j++) {
|
||||
for (int k = -2; k < 2; k++) {
|
||||
if ((int) p.getX() + j > 0 && (int) p.getX() + j < image.getWidth()
|
||||
|
Loading…
Reference in New Issue
Block a user