覆盖模式 使用rgb

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

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

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

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

Loading…
Cancel
Save