增加切割图像边缘减除

pull/46/head
lidapeng 5 years ago
parent b40206cb5f
commit c10adfa885

@ -70,6 +70,15 @@ public class TempleConfig {
private ThreeChannelMatrix backGround;//背景面板
private double backGroundError;//背景误差偏移量0-255
private Cutting cutting = new Cutting();
private double edge = 0;//边缘剪掉多少份
public double getEdge() {
return edge;
}
public void setEdge(double edge) {
this.edge = edge;
}
public Cutting getCutting() {
return cutting;

@ -18,8 +18,8 @@ public class Watershed {
private Matrix regionMap;//分区图
private int xSize;//单元高度
private int ySize;//单元宽度
private double th = Kernel.th;//灰度阈值
private int regionNub = Kernel.Region_Nub;//一张图分多少份
private double th;//灰度阈值
private int regionNub;//一张图分多少份
private Map<Integer, RegionBody> regionBodyMap = new HashMap<>();
private double rainTh = 0;
private int xMax;
@ -27,6 +27,7 @@ public class Watershed {
private double maxRain;
private double width;
private double height;
private double edgeSize = 0;//边缘提取多少份
private List<Specifications> specifications;
public Watershed(Matrix matrix, List<Specifications> specifications, TempleConfig templeConfig) throws Exception {
@ -37,6 +38,9 @@ public class Watershed {
maxRain = cutting.getMaxRain();
this.matrix = matrix;
this.specifications = specifications;
if (templeConfig.getEdge() > 0) {
edgeSize = templeConfig.getEdge();
}
width = matrix.getY();
height = matrix.getX();
xSize = matrix.getX() / regionNub;
@ -216,11 +220,15 @@ public class Watershed {
for (Specifications specification : specifications) {
int width = maxY - minY;
int height = maxX - minX;
// double h = this.height / 8;
// double w = this.width / 8;
// boolean isCenter = minX > h && minY > w && minX < (h * 4.5) && minY < (w * 4.5);
boolean isCenter = true;
if (edgeSize > 0) {
double h = this.height / edgeSize;
double w = this.width / edgeSize;
isCenter = maxX > h && maxY > w && maxX < (h * (edgeSize - 1)) && maxY < (w * (edgeSize - 1));
}
if (width >= specification.getMinWidth() && height >= specification.getMinHeight()
&& width <= specification.getMaxWidth() && height <= specification.getMaxHeight()) {
&& width <= specification.getMaxWidth() && height <= specification.getMaxHeight()
&& isCenter) {
isRight = true;
break;
}

@ -112,22 +112,12 @@ public class FoodTest {
for (int i = 1; i <= 1; i++) {
ThreeChannelMatrix threeChannelMatrix1 = picture.getThreeMatrix("/Users/lidapeng/Documents/paramterTest/a" + i + ".jpg");
ThreeChannelMatrix threeChannelMatrix2 = picture.getThreeMatrix("/Users/lidapeng/Documents/paramterTest/b" + i + ".jpg");
operation.colorStudy(threeChannelMatrix1, 83, specificationsList);
operation.colorStudy(threeChannelMatrix1, 1, specificationsList);
System.out.println("=======================================");
operation.colorStudy(threeChannelMatrix2, 86, specificationsList);
operation.colorStudy(threeChannelMatrix2, 2, specificationsList);
System.out.println("=======================================" + i);
}
ModelParameter modelParameter = templeConfig.getModel();
if (modelParameter.getKnnVector() != null) {
System.out.println("not null 1");
}
String tr = JSON.toJSONString(modelParameter);
System.out.println(tr);
ModelParameter modelParameter1 = JSON.parseObject(tr, ModelParameter.class);
if (modelParameter1.getKnnVector() != null) {
System.out.println("not null 2");
}
//test2(templeConfig);
test2(templeConfig);
}
public static void study() throws Exception {

@ -71,19 +71,20 @@ public class LangTest {
//创建模板读取累
TemplateReader templateReader = new TemplateReader();
WordTemple wordTemple = new WordTemple();//初始化语言模版
wordTemple.setTreeNub(9);
// wordTemple.setSplitWord(true);
//wordTemple.setTreeNub(9);
//wordTemple.setTrustPunishment(0.5);
wordTemple.setSplitWord(true);
//读取语言模版,第一个参数是模版地址,第二个参数是编码方式 (教程里的第三个参数已经省略)
//同时也是学习过程
templateReader.read("/Users/lidapeng/Desktop/myDocument/model.txt", "UTF-8", wordTemple);
Talk talk = new Talk(wordTemple);
//输入语句进行识别若有标点符号会形成LIST中的每个元素
//返回的集合中每个值代表了输入语句,每个标点符号前语句的分类
// List<List<String>> lists = talk.getSplitWord("空调坏了,帮我修一修");
// for (List<String> list : lists) {
// System.out.println(list);
// }
List<Integer> list = talk.talk("空调坏了,帮我修一修");
System.out.println(list);
List<List<String>> lists = talk.getSplitWord("空调坏了,帮我修一修");
for (List<String> list : lists) {
System.out.println(list);
}
// List<Integer> list = talk.talk("空调坏了,帮我修一修");
// System.out.println(list);
}
}

Loading…
Cancel
Save