覆盖模式 使用rgb

pull/44/head
lidapeng 5 years ago
parent 50da4ed045
commit f1620ba4f1

@ -62,26 +62,17 @@ public class Convolution extends Frequency {
return threeChannelMatrixList;
}
public List<List<Double>> kAvg(ThreeChannelMatrix threeMatrix, int poolSize, int sqNub
public List<List<Double>> kAvg(ThreeChannelMatrix threeMatrix, int sqNub
, int regionSize) throws Exception {
RGBSort rgbSort = new RGBSort();
List<List<Double>> features = new ArrayList<>();
Matrix matrixR = threeMatrix.getMatrixR();
Matrix matrixG = threeMatrix.getMatrixG();
Matrix matrixB = threeMatrix.getMatrixB();
matrixR = late(matrixR, poolSize);
matrixG = late(matrixG, poolSize);
matrixB = late(matrixB, poolSize);
threeMatrix.setMatrixR(matrixR);
threeMatrix.setMatrixG(matrixG);
threeMatrix.setMatrixB(matrixB);
List<ThreeChannelMatrix> threeChannelMatrixList = regionThreeChannelMatrix(threeMatrix, regionSize);
for (ThreeChannelMatrix threeChannelMatrix : threeChannelMatrixList) {
List<Double> feature = new ArrayList<>();
MeanClustering meanClustering = new MeanClustering(sqNub);
matrixR = threeChannelMatrix.getMatrixR();
matrixG = threeChannelMatrix.getMatrixG();
matrixB = threeChannelMatrix.getMatrixB();
Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB();
int x = matrixR.getX();
int y = matrixR.getY();
for (int i = 0; i < x; i++) {
@ -93,14 +84,12 @@ public class Convolution extends Frequency {
meanClustering.start();
List<RGBNorm> rgbNorms = meanClustering.getMatrices();
Collections.sort(rgbNorms, rgbSort);
double[] dm = new double[sqNub];
for (RGBNorm rgbNorm : rgbNorms) {
feature.add(rgbNorm.getNorm());
}
for (int t = 0; t < dm.length; t++) {
dm[t] = rgbNorms.get(t).getNorm();
double[] rgb = rgbNorm.getRgb();
for (int i = 0; i < rgb.length; i++) {
feature.add(rgb[i]);
}
}
//System.out.println(Arrays.toString(dm));
features.add(feature);
}
return features;

@ -226,8 +226,7 @@ public class Operation {//进行计算
return id;
}
public void coverStudy(Map<Integer, ThreeChannelMatrix> matrixMap, int poolSize, int sqNub, int regionSize,
int times) throws Exception {
public void coverStudy(Map<Integer, ThreeChannelMatrix> matrixMap, int sqNub, int regionSize) throws Exception {
if (templeConfig.getStudyPattern() == StudyPattern.Cover_Pattern) {
int size = 0;
List<CoverBody> coverBodies = new ArrayList<>();
@ -235,32 +234,31 @@ public class Operation {//进行计算
CoverBody coverBody = new CoverBody();
Map<Integer, Double> tag = new HashMap<>();
tag.put(entry.getKey(), 1.0);
List<List<Double>> lists = convolution.kAvg(entry.getValue(), poolSize, sqNub, regionSize);
List<List<Double>> lists = convolution.kAvg(entry.getValue(), sqNub, regionSize);
size = lists.size();
coverBody.setFeature(lists);
coverBody.setTag(tag);
coverBodies.add(coverBody);
}
//特征塞入容器完毕
for (int j = 0; j < times; j++) {
for (int i = 0; i < size; i++) {
for (CoverBody coverBody : coverBodies) {
List<Double> list = coverBody.getFeature().get(i);
if (templeConfig.isShowLog()) {
System.out.println("feature:" + list);
}
intoDnnNetwork(1, list, templeConfig.getSensoryNerves(), true, coverBody.getTag(), null);
for (int i = 0; i < size; i++) {
for (CoverBody coverBody : coverBodies) {
List<Double> list = coverBody.getFeature().get(i);
if (templeConfig.isShowLog()) {
System.out.println("feature:" + list);
}
intoDnnNetwork(1, list, templeConfig.getSensoryNerves(), true, coverBody.getTag(), null);
}
}
}
}
public Map<Integer, Double> coverPoint(ThreeChannelMatrix matrix, int poolSize, int sqNub, int regionSize) throws Exception {
public Map<Integer, Double> coverPoint(ThreeChannelMatrix matrix, int sqNub, int regionSize) throws Exception {
if (templeConfig.getStudyPattern() == StudyPattern.Cover_Pattern) {
Map<Integer, Double> coverMap = new HashMap<>();
Map<Integer, Integer> typeNub = new HashMap<>();
List<List<Double>> lists = convolution.kAvg(matrix, poolSize, sqNub, regionSize);
List<List<Double>> lists = convolution.kAvg(matrix, sqNub, regionSize);
//特征塞入容器完毕
int size = lists.size();
int all = 0;

@ -24,7 +24,7 @@ import java.util.Map;
public class CoverTest {
public static void main(String[] args) throws Exception {
//cover();
cover();
}
public static void insertModel(String model) throws Exception {//注入模型
@ -63,7 +63,7 @@ public class CoverTest {
String na = "D:\\share\\cai/" + name + i + ".jpg";
//System.out.println("name======================" + na);
ThreeChannelMatrix threeChannelMatrix = picture.getThreeMatrix(na);
Map<Integer, Double> map1 = operation.coverPoint(threeChannelMatrix, poolSize, sqlNub, regionSize);
Map<Integer, Double> map1 = operation.coverPoint(threeChannelMatrix, sqlNub, regionSize);
int id = 0;
double point = 0;
for (Map.Entry<Integer, Double> entry : map1.entrySet()) {
@ -117,7 +117,7 @@ public class CoverTest {
matrixMap.put(2, threeChannelMatrix2);//土地
matrixMap.put(3, threeChannelMatrix3);//桔梗覆盖
matrixMap.put(4, threeChannelMatrix4);//土地
operation.coverStudy(matrixMap, 2, 3, 18, 2);
operation.coverStudy(matrixMap, 2, 18);
}
ModelParameter modelParameter = templeConfig.getModel();
String model = JSON.toJSONString(modelParameter);

Loading…
Cancel
Save