增加局部纹理聚类

pull/55/head
lidapeng 5 years ago
parent 203c05d83b
commit b817746eb6

@ -6,7 +6,7 @@
<groupId>com.wlld</groupId> <groupId>com.wlld</groupId>
<artifactId>easyAi</artifactId> <artifactId>easyAi</artifactId>
<version>1.1.2</version> <version>1.0.9</version>
<name>easyAi</name> <name>easyAi</name>
<!-- FIXME change it to the project's website --> <!-- FIXME change it to the project's website -->

@ -330,6 +330,7 @@ public class MatrixOperation {
mathMul(myMatrix, def); mathMul(myMatrix, def);
return myMatrix; return myMatrix;
} else { } else {
System.out.println(matrixs.getString());
throw new Exception("this matrixs do not have InverseMatrixs"); throw new Exception("this matrixs do not have InverseMatrixs");
} }
} }

@ -10,7 +10,7 @@ public class Kernel {
private static final String All_Number2 = "[-1,0,-1]#[0,4,0]#[-1,0,-1]#"; private static final String All_Number2 = "[-1,0,-1]#[0,4,0]#[-1,0,-1]#";
public static final int Region_Nub = 60;//一张图有多少份 public static final int Region_Nub = 60;//一张图有多少份
public static final double th = 0.88;//分水岭灰度阈值 public static final double th = 0.88;//分水岭灰度阈值
public static final double rgbN = 442.0;//RGB范数归一化最大值 public static final double rgbN = 442.0;//442.0;//RGB范数归一化最大值
public static Matrix Vertical; public static Matrix Vertical;
public static Matrix Horizontal; public static Matrix Horizontal;
public static Matrix All; public static Matrix All;

@ -169,9 +169,9 @@ public class Convolution extends Frequency {
Matrix matrixR = threeChannelMatrix.getMatrixR(); Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG(); Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB(); Matrix matrixB = threeChannelMatrix.getMatrixB();
matrixR = late(matrixR, poolSize); // matrixR = late(matrixR, poolSize);
matrixG = late(matrixG, poolSize); // matrixG = late(matrixG, poolSize);
matrixB = late(matrixB, poolSize); // matrixB = late(matrixB, poolSize);
RGBSort rgbSort = new RGBSort(); RGBSort rgbSort = new RGBSort();
int x = matrixR.getX(); int x = matrixR.getX();
int y = matrixR.getY(); int y = matrixR.getY();
@ -187,9 +187,9 @@ public class Convolution extends Frequency {
Collections.sort(rgbNorms, rgbSort); Collections.sort(rgbNorms, rgbSort);
List<Double> features = new ArrayList<>(); List<Double> features = new ArrayList<>();
for (int i = 0; i < sqNub; i++) { for (int i = 0; i < sqNub; i++) {
//double[] rgb = rgbNorms.get(i).getRgb(); double[] rgb = rgbNorms.get(i).getRgb();
RgbRegression rgbRegression = rgbNorms.get(i).getRgbRegression(); // RgbRegression rgbRegression = rgbNorms.get(i).getRgbRegression();
double[] rgb = new double[]{rgbRegression.getWr(), rgbRegression.getWg(), rgbRegression.getB()}; //double[] rgb = new double[]{rgbRegression.getWr(), rgbRegression.getWg(), rgbRegression.getB()};
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
features.add(rgb[j]); features.add(rgb[j]);
} }
@ -200,44 +200,45 @@ public class Convolution extends Frequency {
return features; return features;
} }
private void regression(XYBody xyBody) { public List<Double> getCenterTexture(ThreeChannelMatrix threeChannelMatrix, int size, int poolSize, TempleConfig templeConfig
//计算当前图形的线性回归 , int sqNub) throws Exception {
RegressionBody regressionBody = new RegressionBody(); RGBSort rgbSort = new RGBSort();
regressionBody.lineRegression(xyBody.getY(), xyBody.getX(), this); MeanClustering meanClustering = new MeanClustering(sqNub, templeConfig);
xyBody.setRegressionBody(regressionBody); Matrix matrixR = threeChannelMatrix.getMatrixR();
} Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB();
public XYBody imageTrance(Matrix matrix, int size) throws Exception {//矩阵和卷积核大小 int xn = matrixR.getX();
int xn = matrix.getX(); int yn = matrixR.getY();
int yn = matrix.getY(); for (int i = 0; i <= xn - size; i += size) {
int xSize = xn / size;//求导后矩阵的行数 for (int j = 0; j <= yn - size; j += size) {
int ySize = yn / size;//求导后矩阵的列数 Matrix sonR = late(matrixR.getSonOfMatrix(i, j, size, size), poolSize);
double[] Y = new double[xSize * ySize]; Matrix sonG = late(matrixG.getSonOfMatrix(i, j, size, size), poolSize);
double[] X = new double[xSize * ySize]; Matrix sonB = late(matrixB.getSonOfMatrix(i, j, size, size), poolSize);
double rgbN = Kernel.rgbN; int tSize = sonR.getX();
for (int i = 0; i < xn - size; i += size) { int kSize = sonR.getY();
for (int j = 0; j < yn - size; j += size) { double[] rgb = new double[tSize * kSize * 3];
Matrix matrix1 = matrix.getSonOfMatrix(i, j, size, size); for (int t = 0; t < tSize; t++) {
double[] nubs = new double[size * size];//平均值数组 for (int k = 0; k < kSize; k++) {
for (int t = 0; t < size; t++) { int index = t * kSize + k;
for (int k = 0; k < size; k++) { rgb[index] = sonR.getNumber(t, k);
double nub = matrix1.getNumber(t, k) / rgbN; rgb[tSize * kSize + index] = sonG.getNumber(t, k);
nubs[t * size + k] = nub; rgb[tSize * kSize * 2 + index] = sonB.getNumber(t, k);
} }
} }
double avg = average(nubs);//平均值 meanClustering.setColor(rgb);
//double dc = frequency.dcByAvg(nubs, avg);//当前离散系数
double va = varianceByAve(nubs, avg);//方差
//离散系数作为XAVG作为Y
int t = i / size * ySize + j / size;
Y[t] = avg;
X[t] = va;
} }
} }
XYBody xyBody = new XYBody(); meanClustering.start();//开始聚类
xyBody.setX(X); List<RGBNorm> rgbNorms = meanClustering.getMatrices();
xyBody.setY(Y); Collections.sort(rgbNorms, rgbSort);
return xyBody; List<Double> features = new ArrayList<>();
for (int i = 0; i < sqNub; i++) {
double[] rgb = rgbNorms.get(i).getRgb();
for (int j = 0; j < rgb.length; j++) {
features.add(rgb[j]);
}
}
return features;
} }
@ -260,11 +261,13 @@ public class Convolution extends Frequency {
Matrix matrixR = threeChannelMatrix.getMatrixR().getSonOfMatrix(x, y, xSize, ySize); Matrix matrixR = threeChannelMatrix.getMatrixR().getSonOfMatrix(x, y, xSize, ySize);
Matrix matrixG = threeChannelMatrix.getMatrixG().getSonOfMatrix(x, y, xSize, ySize); Matrix matrixG = threeChannelMatrix.getMatrixG().getSonOfMatrix(x, y, xSize, ySize);
Matrix matrixB = threeChannelMatrix.getMatrixB().getSonOfMatrix(x, y, xSize, ySize); Matrix matrixB = threeChannelMatrix.getMatrixB().getSonOfMatrix(x, y, xSize, ySize);
Matrix matrixH = threeChannelMatrix.getH().getSonOfMatrix(x, y, xSize, ySize);
Matrix matrixRGB = threeChannelMatrix.getMatrixRGB().getSonOfMatrix(x, y, xSize, ySize);
threeChannelMatrix1.setMatrixR(matrixR); threeChannelMatrix1.setMatrixR(matrixR);
threeChannelMatrix1.setMatrixG(matrixG); threeChannelMatrix1.setMatrixG(matrixG);
threeChannelMatrix1.setMatrixB(matrixB); threeChannelMatrix1.setMatrixB(matrixB);
threeChannelMatrix1.setH(threeChannelMatrix.getH()); threeChannelMatrix1.setH(matrixH);
threeChannelMatrix1.setMatrixRGB(threeChannelMatrix.getMatrixRGB()); threeChannelMatrix1.setMatrixRGB(matrixRGB);
return threeChannelMatrix1; return threeChannelMatrix1;
} }
@ -359,7 +362,7 @@ public class Convolution extends Frequency {
return myMatrix; return myMatrix;
} }
protected Matrix late(Matrix matrix, int size) throws Exception {//池化处理 public Matrix late(Matrix matrix, int size) throws Exception {//池化处理
int xn = matrix.getX(); int xn = matrix.getX();
int yn = matrix.getY(); int yn = matrix.getY();
int x = xn / size;//求导后矩阵的行数 int x = xn / size;//求导后矩阵的行数
@ -380,7 +383,7 @@ public class Convolution extends Frequency {
} }
} }
} }
maxNub = ArithUtil.div(sigma, n); maxNub = sigma / n;
//迟化的最大值是 MAXNUB //迟化的最大值是 MAXNUB
myMatrix.setNub(i / size, j / size, maxNub); myMatrix.setNub(i / size, j / size, maxNub);
} }

@ -96,7 +96,7 @@ public class MeanClustering {
for (int i = 0; i < speciesQuantity; i++) {//初始化均值向量 for (int i = 0; i < speciesQuantity; i++) {//初始化均值向量
int index = random.nextInt(matrixList.size()); int index = random.nextInt(matrixList.size());
double[] rgb = matrixList.get(index); double[] rgb = matrixList.get(index);
RGBNorm rgbNorm = new RGBNorm(rgb); RGBNorm rgbNorm = new RGBNorm(rgb, length);
//要进行深度克隆 //要进行深度克隆
matrices.add(rgbNorm); matrices.add(rgbNorm);
} }
@ -111,7 +111,7 @@ public class MeanClustering {
break; break;
} }
} }
startRegression();//开始进行回归 // startRegression();//开始进行回归
} else { } else {
throw new Exception("matrixList number less than 2"); throw new Exception("matrixList number less than 2");
} }

@ -7,7 +7,6 @@ import org.wlld.config.Classifier;
import org.wlld.config.StudyPattern; import org.wlld.config.StudyPattern;
import org.wlld.i.OutBack; import org.wlld.i.OutBack;
import org.wlld.imageRecognition.border.*; import org.wlld.imageRecognition.border.*;
import org.wlld.imageRecognition.modelEntity.TrayBody;
import org.wlld.imageRecognition.segmentation.RegionBody; import org.wlld.imageRecognition.segmentation.RegionBody;
import org.wlld.imageRecognition.segmentation.RgbRegression; import org.wlld.imageRecognition.segmentation.RgbRegression;
import org.wlld.imageRecognition.segmentation.Specifications; import org.wlld.imageRecognition.segmentation.Specifications;
@ -64,10 +63,10 @@ public class Operation {//进行计算
Matrix matrixR = threeChannelMatrix.getMatrixR(); Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG(); Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB(); Matrix matrixB = threeChannelMatrix.getMatrixB();
Matrix matrixRGB = threeChannelMatrix.getMatrixRGB(); //Matrix matrixRGB = threeChannelMatrix.getMatrixRGB();
Random random = new Random(); Random random = new Random();
int x = matrixRGB.getX(); int x = matrixR.getX();
int y = matrixRGB.getY(); int y = matrixR.getY();
int size = templeConfig.getFood().getRegressionNub(); int size = templeConfig.getFood().getRegressionNub();
RgbRegression rgbRegression = new RgbRegression(size); RgbRegression rgbRegression = new RgbRegression(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
@ -88,11 +87,9 @@ public class Operation {//进行计算
Matrix matrixR = threeChannelMatrix.getMatrixR(); Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG(); Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB(); Matrix matrixB = threeChannelMatrix.getMatrixB();
Matrix matrixRGB = threeChannelMatrix.getMatrixRGB();
threeChannelMatrix.setMatrixR(matrixR.getSonOfMatrix(x, y, xSize, ySize)); threeChannelMatrix.setMatrixR(matrixR.getSonOfMatrix(x, y, xSize, ySize));
threeChannelMatrix.setMatrixG(matrixG.getSonOfMatrix(x, y, xSize, ySize)); threeChannelMatrix.setMatrixG(matrixG.getSonOfMatrix(x, y, xSize, ySize));
threeChannelMatrix.setMatrixB(matrixB.getSonOfMatrix(x, y, xSize, ySize)); threeChannelMatrix.setMatrixB(matrixB.getSonOfMatrix(x, y, xSize, ySize));
threeChannelMatrix.setMatrixRGB(matrixRGB.getSonOfMatrix(x, y, xSize, ySize));
} }
public RegionBody colorStudy(ThreeChannelMatrix threeChannelMatrix, int tag, List<Specifications> specificationsList) throws Exception { public RegionBody colorStudy(ThreeChannelMatrix threeChannelMatrix, int tag, List<Specifications> specificationsList) throws Exception {
@ -107,15 +104,15 @@ public class Operation {//进行计算
int xSize = maxX - minX; int xSize = maxX - minX;
int ySize = maxY - minY; int ySize = maxY - minY;
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize); ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
//convolution.filtering(threeChannelMatrix1);//光照过滤
int times = templeConfig.getFood().getTimes(); int times = templeConfig.getFood().getTimes();
for (int i = 0; i < times; i++) { for (int i = 0; i < times; i++) {
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(), // List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
templeConfig.getFeatureNub(), templeConfig); // templeConfig.getFeatureNub(), templeConfig);
List<Double> feature = convolution.getCenterTexture(threeChannelMatrix1, templeConfig.getFood().getRegionSize(),
templeConfig.getPoolSize(), templeConfig, templeConfig.getFeatureNub());
if (templeConfig.isShowLog()) { if (templeConfig.isShowLog()) {
System.out.println(tag + ":" + feature); System.out.println(tag + ":" + feature);
} }
//System.out.println("=====================================");
int classifier = templeConfig.getClassifier(); int classifier = templeConfig.getClassifier();
switch (classifier) { switch (classifier) {
case Classifier.DNN: case Classifier.DNN:
@ -177,9 +174,10 @@ public class Operation {//进行计算
int xSize = maxX - minX; int xSize = maxX - minX;
int ySize = maxY - minY; int ySize = maxY - minY;
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize); ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
//convolution.filtering(threeChannelMatrix1);//光照过滤 // List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(), // templeConfig.getFeatureNub(), templeConfig);
templeConfig.getFeatureNub(), templeConfig); List<Double> feature = convolution.getCenterTexture(threeChannelMatrix1, templeConfig.getFood().getRegionSize(),
templeConfig.getPoolSize(), templeConfig, templeConfig.getFeatureNub());
if (templeConfig.isShowLog()) { if (templeConfig.isShowLog()) {
System.out.println(feature); System.out.println(feature);
} }

@ -7,13 +7,14 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RGBNorm { public class RGBNorm {
private double[] rgbAll = new double[3]; private double[] rgbAll;
private double norm; private double norm;
private int nub; private int nub;
private double[] rgb = new double[3]; private double[] rgb;
private double[] rgbUp; private double[] rgbUp;
private List<double[]> rgbs = new ArrayList<>(); private List<double[]> rgbs = new ArrayList<>();
private RgbRegression rgbRegression; private RgbRegression rgbRegression;
private int len;
public List<double[]> getRgbs() { public List<double[]> getRgbs() {
return rgbs; return rgbs;
@ -27,7 +28,10 @@ public class RGBNorm {
this.rgbRegression = rgbRegression; this.rgbRegression = rgbRegression;
} }
RGBNorm(double[] rgb) { RGBNorm(double[] rgb, int len) {
this.len = len;
rgbAll = new double[len];
this.rgb = new double[len];
this.rgbUp = rgb; this.rgbUp = rgb;
} }
@ -36,12 +40,11 @@ public class RGBNorm {
} }
public void clear() { public void clear() {
rgbAll = new double[3]; rgbAll = new double[len];
nub = 0; nub = 0;
for (int i = 0; i < rgb.length; i++) { for (int i = 0; i < rgb.length; i++) {
rgbUp[i] = rgb[i]; rgbUp[i] = rgb[i];
} }
rgbs.clear();
//System.out.println("clear==" + Arrays.toString(rgbUp)); //System.out.println("clear==" + Arrays.toString(rgbUp));
} }
@ -76,7 +79,6 @@ public class RGBNorm {
for (int i = 0; i < rgb.length; i++) { for (int i = 0; i < rgb.length; i++) {
rgbAll[i] = rgbAll[i] + rgb[i]; rgbAll[i] = rgbAll[i] + rgb[i];
} }
rgbs.add(rgb);
nub++; nub++;
} }

@ -85,7 +85,7 @@ public class Knn {//KNN分类器
compare(dists, types, dist, type); compare(dists, types, dist, type);
} }
} }
System.out.println(Arrays.toString(types)); //System.out.println(Arrays.toString(types));
Map<Integer, Integer> map = new HashMap<>(); Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nub; i++) { for (int i = 0; i < nub; i++) {
int type = types[i]; int type = types[i];

@ -277,13 +277,13 @@ public class Watershed {
regionBodies.add(regionBody); regionBodies.add(regionBody);
} }
} }
for (RegionBody regionBody : regionBodies) { // for (RegionBody regionBody : regionBodies) {
int minX = regionBody.getMinX(); // int minX = regionBody.getMinX();
int maxX = regionBody.getMaxX(); // int maxX = regionBody.getMaxX();
int minY = regionBody.getMinY(); // int minY = regionBody.getMinY();
int maxY = regionBody.getMaxY(); // int maxY = regionBody.getMaxY();
System.out.println("minX==" + minX + ",minY==" + minY + ",maxX==" + maxX + ",maxY==" + maxY); // System.out.println("minX==" + minX + ",minY==" + minY + ",maxX==" + maxX + ",maxY==" + maxY);
} // }
return regionBodies; return regionBodies;
} }
@ -399,8 +399,8 @@ public class Watershed {
} }
private void sigmaPixel() throws Exception {//生成降雨密度图 private void sigmaPixel() throws Exception {//生成降雨密度图
int x = matrix.getX(); // int x = matrix.getX();
int y = matrix.getY(); // int y = matrix.getY();
int size = xSize * ySize; int size = xSize * ySize;
for (int i = 0; i < xSize * regionNub; i += xSize) { for (int i = 0; i < xSize * regionNub; i += xSize) {
for (int j = 0; j < ySize * regionNub; j += ySize) { for (int j = 0; j < ySize * regionNub; j += ySize) {
@ -429,7 +429,7 @@ public class Watershed {
int minIdx = 0; int minIdx = 0;
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
double nub = array[i]; double nub = array[i];
if (nub > -1 && nub < mySelf - rainTh && nub < maxRain) { if (nub > -1 && nub < mySelf) {
minIdx = minIdx | (1 << i); minIdx = minIdx | (1 << i);
} }
} }

@ -19,6 +19,15 @@ public class Food {
private List<RgbRegression> trayBody = new ArrayList<>();//托盘实体参数 private List<RgbRegression> trayBody = new ArrayList<>();//托盘实体参数
private int regressionNub = 10000;//回归次数 private int regressionNub = 10000;//回归次数
private double trayTh = 0.1;//托盘回归阈值 private double trayTh = 0.1;//托盘回归阈值
private int regionSize = 10;//纹理区域大小
public int getRegionSize() {
return regionSize;
}
public void setRegionSize(int regionSize) {
this.regionSize = regionSize;
}
public double getTrayTh() { public double getTrayTh() {
return trayTh; return trayTh;

@ -16,35 +16,15 @@ import org.wlld.param.Food;
import org.wlld.tools.ArithUtil; import org.wlld.tools.ArithUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class FoodTest { public class FoodTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// ModelParameter parameter = JSON.parseObject(ModelData.DATA, ModelParameter.class);
// if (parameter.getKnnVector() != null) {
// System.out.println("空的");
// } else {
// System.out.println("不是空===");
// }
test(); test();
} }
public static void one(double[] test, double[] right, double[] wrong) {
int nub = 0;
for (int i = 0; i < test.length; i++) {
double test1 = test[i];
double right1 = right[i];
double wrong1 = wrong[i];
double sub1 = Math.abs(ArithUtil.sub(test1, right1));
double sub2 = Math.abs(ArithUtil.sub(test1, wrong1));
if (sub1 > sub2) {
nub++;
}
}
System.out.println(nub);
}
public static void test2(TempleConfig templeConfig) throws Exception { public static void test2(TempleConfig templeConfig) throws Exception {
if (templeConfig == null) { if (templeConfig == null) {
ModelParameter parameter = JSON.parseObject(ModelData.DATA, ModelParameter.class); ModelParameter parameter = JSON.parseObject(ModelData.DATA, ModelParameter.class);
@ -53,22 +33,24 @@ public class FoodTest {
Picture picture = new Picture(); Picture picture = new Picture();
List<Specifications> specificationsList = new ArrayList<>(); List<Specifications> specificationsList = new ArrayList<>();
Specifications specifications = new Specifications(); Specifications specifications = new Specifications();
specifications.setMinWidth(300); specifications.setMinWidth(100);
specifications.setMinHeight(300); specifications.setMinHeight(100);
specifications.setMaxWidth(950); specifications.setMaxWidth(950);
specifications.setMaxHeight(950); specifications.setMaxHeight(950);
specificationsList.add(specifications); specificationsList.add(specifications);
Operation operation = new Operation(templeConfig); Operation operation = new Operation(templeConfig);
for (int i = 1; i <= 28; i++) { long a = System.currentTimeMillis();
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Desktop/foodModel/test1/g" + i + ".jpg"); for (int i = 1; i <= 1; i++) {
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Desktop/test/d.jpg");
List<RegionBody> regionBody = operation.colorLook(threeChannelMatrix1, specificationsList); List<RegionBody> regionBody = operation.colorLook(threeChannelMatrix1, specificationsList);
long b = System.currentTimeMillis() - a;
System.out.println(b);
for (int j = 0; j < regionBody.size(); j++) { for (int j = 0; j < regionBody.size(); j++) {
RegionBody regionBody1 = regionBody.get(j); RegionBody regionBody1 = regionBody.get(j);
System.out.println("minX==" + regionBody1.getMinX() + ",minY==" + regionBody1.getMinY() System.out.println("minX==" + regionBody1.getMinX() + ",minY==" + regionBody1.getMinY()
+ ",maxX==" + regionBody1.getMaxX() + ",maxY==" + regionBody1.getMaxY()); + ",maxX==" + regionBody1.getMaxX() + ",maxY==" + regionBody1.getMaxY());
System.out.println(regionBody.get(j).getType()); System.out.println("type==" + regionBody.get(j).getType());
} }
System.out.println("===================================" + i);
} }
} }
@ -87,10 +69,10 @@ public class FoodTest {
//池化比例 //池化比例
templeConfig.setPoolSize(2);//缩小比例 templeConfig.setPoolSize(2);//缩小比例
//聚类 //聚类
templeConfig.setFeatureNub(3);//聚类特征数量 templeConfig.setFeatureNub(5);//聚类特征数量
//菜品识别实体类 //菜品识别实体类
food.setShrink(20);//缩紧像素 food.setShrink(20);//缩紧像素
food.setTimes(1);//聚类数据增强 food.setTimes(2);//聚类数据增强
food.setRowMark(0.1);//0.12 food.setRowMark(0.1);//0.12
food.setColumnMark(0.1);//0.25 food.setColumnMark(0.1);//0.25
food.setRegressionNub(20000); food.setRegressionNub(20000);
@ -109,21 +91,26 @@ public class FoodTest {
Operation operation = new Operation(templeConfig); Operation operation = new Operation(templeConfig);
List<Specifications> specificationsList = new ArrayList<>(); List<Specifications> specificationsList = new ArrayList<>();
Specifications specifications = new Specifications(); Specifications specifications = new Specifications();
specifications.setMinWidth(300); specifications.setMinWidth(100);
specifications.setMinHeight(300); specifications.setMinHeight(100);
specifications.setMaxWidth(1000); specifications.setMaxWidth(1000);
specifications.setMaxHeight(1000); specifications.setMaxHeight(1000);
specificationsList.add(specifications); specificationsList.add(specifications);
ThreeChannelMatrix threeChannelMatrix = picture.getThreeMatrix("/Users/lidapeng/Desktop/myDocument/d.jpg"); ThreeChannelMatrix threeChannelMatrix = picture.getThreeMatrix("/Users/lidapeng/Desktop/myDocument/d.jpg");
operation.setTray(threeChannelMatrix); operation.setTray(threeChannelMatrix);
for (int i = 1; i <= 1; i++) { for (int i = 1; i <= 1; i++) {
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Desktop/myDocument/m.jpg"); ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Desktop/test/a1.jpg");
ThreeChannelMatrix threeChannelMatrix2 = picture.getThreeMatrix("/Users/lidapeng/Desktop/test/b.jpg");
ThreeChannelMatrix threeChannelMatrix3 = picture.getThreeMatrix("/Users/lidapeng/Desktop/test/c.jpg");
operation.colorStudy(threeChannelMatrix1, 1, specificationsList); operation.colorStudy(threeChannelMatrix1, 1, specificationsList);
// System.out.println("=======================================" + i); operation.colorStudy(threeChannelMatrix2, 2, specificationsList);
operation.colorStudy(threeChannelMatrix3, 3, specificationsList);
} }
// minX==301,minY==430,maxX==854,maxY==920 // minX==301,minY==430,maxX==854,maxY==920
// minX==497,minY==1090,maxX==994,maxY==1520 // minX==497,minY==1090,maxX==994,maxY==1520
// test2(templeConfig); test2(templeConfig);
} }
public static void study() throws Exception { public static void study() throws Exception {

Loading…
Cancel
Save