|
|
@ -61,47 +61,51 @@ public class Operation {//进行计算
|
|
|
|
public void colorStudy(ThreeChannelMatrix threeChannelMatrix, int tag, List<Specifications> specificationsList) throws Exception {
|
|
|
|
public void colorStudy(ThreeChannelMatrix threeChannelMatrix, int tag, List<Specifications> specificationsList) throws Exception {
|
|
|
|
Watershed watershed = new Watershed(threeChannelMatrix.getMatrixRGB(), specificationsList, templeConfig);
|
|
|
|
Watershed watershed = new Watershed(threeChannelMatrix.getMatrixRGB(), specificationsList, templeConfig);
|
|
|
|
List<RegionBody> regionBodies = watershed.rainfall();
|
|
|
|
List<RegionBody> regionBodies = watershed.rainfall();
|
|
|
|
RegionBody regionBody = regionBodies.get(0);
|
|
|
|
if (regionBodies.size() == 1) {
|
|
|
|
int minX = regionBody.getMinX() + dif;
|
|
|
|
RegionBody regionBody = regionBodies.get(0);
|
|
|
|
int minY = regionBody.getMinY() + dif;
|
|
|
|
int minX = regionBody.getMinX() + dif;
|
|
|
|
int maxX = regionBody.getMaxX() - dif;
|
|
|
|
int minY = regionBody.getMinY() + dif;
|
|
|
|
int maxY = regionBody.getMaxY() - dif;
|
|
|
|
int maxX = regionBody.getMaxX() - dif;
|
|
|
|
int xSize = maxX - minX;
|
|
|
|
int maxY = regionBody.getMaxY() - dif;
|
|
|
|
int ySize = maxY - minY;
|
|
|
|
int xSize = maxX - minX;
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
|
|
|
|
int ySize = maxY - minY;
|
|
|
|
//convolution.filtering(threeChannelMatrix1);//光照过滤
|
|
|
|
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
|
|
|
|
int times = templeConfig.getFood().getTimes();
|
|
|
|
//convolution.filtering(threeChannelMatrix1);//光照过滤
|
|
|
|
for (int i = 0; i < times; i++) {
|
|
|
|
int times = templeConfig.getFood().getTimes();
|
|
|
|
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
|
|
|
|
for (int i = 0; i < times; i++) {
|
|
|
|
templeConfig.getFeatureNub());
|
|
|
|
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
|
|
|
|
if (templeConfig.isShowLog()) {
|
|
|
|
templeConfig.getFeatureNub());
|
|
|
|
System.out.println(tag + ":" + feature);
|
|
|
|
if (templeConfig.isShowLog()) {
|
|
|
|
}
|
|
|
|
System.out.println(tag + ":" + feature);
|
|
|
|
//System.out.println("=====================================");
|
|
|
|
}
|
|
|
|
int classifier = templeConfig.getClassifier();
|
|
|
|
//System.out.println("=====================================");
|
|
|
|
switch (classifier) {
|
|
|
|
int classifier = templeConfig.getClassifier();
|
|
|
|
case Classifier.DNN:
|
|
|
|
switch (classifier) {
|
|
|
|
Map<Integer, Double> map = new HashMap<>();
|
|
|
|
case Classifier.DNN:
|
|
|
|
map.put(tag, 1.0);
|
|
|
|
Map<Integer, Double> map = new HashMap<>();
|
|
|
|
if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub() * 3) {
|
|
|
|
map.put(tag, 1.0);
|
|
|
|
intoDnnNetwork(1, feature, templeConfig.getSensoryNerves(), true, map, null);
|
|
|
|
if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub() * 3) {
|
|
|
|
} else {
|
|
|
|
intoDnnNetwork(1, feature, templeConfig.getSensoryNerves(), true, map, null);
|
|
|
|
throw new Exception("nerves number is not equal featureNub");
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
throw new Exception("nerves number is not equal featureNub");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Classifier.LVQ:
|
|
|
|
break;
|
|
|
|
Matrix vector = MatrixOperation.listToRowVector(feature);
|
|
|
|
case Classifier.LVQ:
|
|
|
|
lvqStudy(tag, vector);
|
|
|
|
Matrix vector = MatrixOperation.listToRowVector(feature);
|
|
|
|
break;
|
|
|
|
lvqStudy(tag, vector);
|
|
|
|
case Classifier.VAvg:
|
|
|
|
break;
|
|
|
|
Matrix vec = MatrixOperation.listToRowVector(feature);
|
|
|
|
case Classifier.VAvg:
|
|
|
|
avgStudy(tag, vec);
|
|
|
|
Matrix vec = MatrixOperation.listToRowVector(feature);
|
|
|
|
break;
|
|
|
|
avgStudy(tag, vec);
|
|
|
|
case Classifier.KNN:
|
|
|
|
break;
|
|
|
|
Matrix veck = MatrixOperation.listToRowVector(feature);
|
|
|
|
case Classifier.KNN:
|
|
|
|
knnStudy(tag, veck);
|
|
|
|
Matrix veck = MatrixOperation.listToRowVector(feature);
|
|
|
|
break;
|
|
|
|
knnStudy(tag, veck);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new Exception("Parameter exception");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|