|
|
|
@ -26,14 +26,17 @@ public class Operation {//进行计算
|
|
|
|
|
private MatrixBack matrixBack = new MatrixBack();
|
|
|
|
|
private ImageBack imageBack = new ImageBack();
|
|
|
|
|
private OutBack outBack;
|
|
|
|
|
private int dif;
|
|
|
|
|
|
|
|
|
|
public Operation(TempleConfig templeConfig) {
|
|
|
|
|
this.templeConfig = templeConfig;
|
|
|
|
|
dif = templeConfig.getShrink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Operation(TempleConfig templeConfig, OutBack outBack) {
|
|
|
|
|
this.templeConfig = templeConfig;
|
|
|
|
|
this.outBack = outBack;
|
|
|
|
|
dif = templeConfig.getShrink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Double> convolution(Matrix matrix, Map<Integer, Double> tagging) throws Exception {
|
|
|
|
@ -59,20 +62,22 @@ public class Operation {//进行计算
|
|
|
|
|
|
|
|
|
|
public void colorStudy(ThreeChannelMatrix threeChannelMatrix, int tag, List<Specifications> specificationsList) throws Exception {
|
|
|
|
|
Watershed watershed = new Watershed(threeChannelMatrix.getMatrixRGB(), specificationsList, templeConfig);
|
|
|
|
|
RegionBody regionBody = watershed.rainfall().get(0);
|
|
|
|
|
int minX = regionBody.getMinX();
|
|
|
|
|
int minY = regionBody.getMinY();
|
|
|
|
|
int maxX = regionBody.getMaxX();
|
|
|
|
|
int maxY = regionBody.getMaxY();
|
|
|
|
|
List<RegionBody> regionBodies = watershed.rainfall();
|
|
|
|
|
RegionBody regionBody = regionBodies.get(0);
|
|
|
|
|
int minX = regionBody.getMinX() + dif;
|
|
|
|
|
int minY = regionBody.getMinY() + dif;
|
|
|
|
|
int maxX = regionBody.getMaxX() - dif;
|
|
|
|
|
int maxY = regionBody.getMaxY() - dif;
|
|
|
|
|
int xSize = maxX - minX;
|
|
|
|
|
int ySize = maxY - minY;
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
|
|
|
|
|
// convolution.filtering(threeChannelMatrix1);//光照过滤
|
|
|
|
|
int times = templeConfig.getTimes();
|
|
|
|
|
for (int i = 0; i < times; i++) {
|
|
|
|
|
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
|
|
|
|
|
templeConfig.getFeatureNub());
|
|
|
|
|
if (templeConfig.isShowLog()) {
|
|
|
|
|
System.out.println(feature);
|
|
|
|
|
System.out.println(tag + ":" + feature);
|
|
|
|
|
}
|
|
|
|
|
//System.out.println("=====================================");
|
|
|
|
|
int classifier = templeConfig.getClassifier();
|
|
|
|
@ -125,13 +130,14 @@ public class Operation {//进行计算
|
|
|
|
|
List<RegionBody> regionList = watershed.rainfall();
|
|
|
|
|
for (RegionBody regionBody : regionList) {
|
|
|
|
|
MaxPoint maxPoint = new MaxPoint();
|
|
|
|
|
int minX = regionBody.getMinX();
|
|
|
|
|
int minY = regionBody.getMinY();
|
|
|
|
|
int maxX = regionBody.getMaxX();
|
|
|
|
|
int maxY = regionBody.getMaxY();
|
|
|
|
|
int minX = regionBody.getMinX() + dif;
|
|
|
|
|
int minY = regionBody.getMinY() + dif;
|
|
|
|
|
int maxX = regionBody.getMaxX() - dif;
|
|
|
|
|
int maxY = regionBody.getMaxY() - dif;
|
|
|
|
|
int xSize = maxX - minX;
|
|
|
|
|
int ySize = maxY - minY;
|
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
|
|
|
|
|
//convolution.filtering(threeChannelMatrix1);//光照过滤
|
|
|
|
|
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
|
|
|
|
|
templeConfig.getFeatureNub());
|
|
|
|
|
if (templeConfig.isShowLog()) {
|
|
|
|
@ -812,6 +818,49 @@ public class Operation {//进行计算
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double isCover(ThreeChannelMatrix threeChannelMatrix) throws Exception {//固定背景覆盖率计算
|
|
|
|
|
ThreeChannelMatrix backGround = templeConfig.getBackGround();
|
|
|
|
|
double minCover = templeConfig.getMinCover();
|
|
|
|
|
double maxCover = templeConfig.getMaxCover();
|
|
|
|
|
double errorBack = templeConfig.getBackGroundError();
|
|
|
|
|
if (backGround != null && maxCover > minCover && errorBack >= 0 && errorBack <= 255) {
|
|
|
|
|
Matrix matrixR = threeChannelMatrix.getMatrixR();
|
|
|
|
|
Matrix matrixG = threeChannelMatrix.getMatrixG();
|
|
|
|
|
Matrix matrixB = threeChannelMatrix.getMatrixB();
|
|
|
|
|
Matrix matrixRBg = backGround.getMatrixR();
|
|
|
|
|
Matrix matrixGBg = backGround.getMatrixG();
|
|
|
|
|
Matrix matrixBBg = backGround.getMatrixB();
|
|
|
|
|
int x = matrixR.getX();
|
|
|
|
|
int y = matrixR.getY();
|
|
|
|
|
double size = x * y;
|
|
|
|
|
double cover = 0;
|
|
|
|
|
if (x == matrixRBg.getX() && y == matrixRBg.getY()) {
|
|
|
|
|
for (int i = 0; i < x; i++) {
|
|
|
|
|
for (int j = 0; j < y; j++) {
|
|
|
|
|
double rB = matrixRBg.getNumber(i, j);
|
|
|
|
|
double gB = matrixGBg.getNumber(i, j);
|
|
|
|
|
double bB = matrixBBg.getNumber(i, j);
|
|
|
|
|
double r = matrixR.getNumber(i, j);
|
|
|
|
|
double g = matrixG.getNumber(i, j);
|
|
|
|
|
double b = matrixB.getNumber(i, j);
|
|
|
|
|
double subR = Math.abs(r - rB);
|
|
|
|
|
double subG = Math.abs(g - gB);
|
|
|
|
|
double subB = Math.abs(b - bB);
|
|
|
|
|
double error = (subR + subB + subG) / 3;
|
|
|
|
|
if (error > errorBack) {
|
|
|
|
|
cover++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cover / size;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception("Temple matrix is different");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception("value is null");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Double> sub(Matrix matrix) throws Exception {//
|
|
|
|
|
List<Double> list = new ArrayList<>();
|
|
|
|
|
int x = matrix.getX() - 1;
|
|
|
|
|