增加选区缩小参数

pull/35/head
thenk008 5 years ago
parent cab03a61ae
commit cbfc4b56ea

@ -345,7 +345,7 @@ public class Convolution extends Frequency {
return myMatrix;
}
protected Matrix late(Matrix matrix, int size) throws Exception {//化处理
protected Matrix late(Matrix matrix, int size) throws Exception {//化处理
int xn = matrix.getX();
int yn = matrix.getY();
int x = xn / size;//求导后矩阵的行数

@ -818,6 +818,49 @@ public class Operation {//进行计算
return id;
}
public double isCover(ThreeChannelMatrix threeChannelMatrix) throws Exception {//固定背景覆盖率计算
ThreeChannelMatrix backGround = templeConfig.getBackGround();
double minCover = templeConfig.getMinCover();
double maxCover = templeConfig.getMaxCover();
double errorBack = templeConfig.getBackGroundError();
if (backGround != null && maxCover > minCover && errorBack >= 0 && errorBack <= 255) {
Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB();
Matrix matrixRBg = backGround.getMatrixR();
Matrix matrixGBg = backGround.getMatrixG();
Matrix matrixBBg = backGround.getMatrixB();
int x = matrixR.getX();
int y = matrixR.getY();
double size = x * y;
double cover = 0;
if (x == matrixRBg.getX() && y == matrixRBg.getY()) {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
double rB = matrixRBg.getNumber(i, j);
double gB = matrixGBg.getNumber(i, j);
double bB = matrixBBg.getNumber(i, j);
double r = matrixR.getNumber(i, j);
double g = matrixG.getNumber(i, j);
double b = matrixB.getNumber(i, j);
double subR = Math.abs(r - rB);
double subG = Math.abs(g - gB);
double subB = Math.abs(b - bB);
double error = (subR + subB + subG) / 3;
if (error > errorBack) {
cover++;
}
}
}
return cover / size;
} else {
throw new Exception("Temple matrix is different");
}
} else {
throw new Exception("value is null");
}
}
private List<Double> sub(Matrix matrix) throws Exception {//
List<Double> list = new ArrayList<>();
int x = matrix.getX() - 1;

@ -68,6 +68,42 @@ public class TempleConfig {
private int knnNub = 7;//KNN投票人数
private int times = 10;//聚类循环次数
private int shrink = 60;//收缩参数
private ThreeChannelMatrix backGround;//背景面板
private double minCover;//覆盖下限
private double maxCover;//覆盖上限
private double backGroundError;//背景误差偏移量0-255
public double getBackGroundError() {
return backGroundError;
}
public void setBackGroundError(double backGroundError) {
this.backGroundError = backGroundError;
}
public double getMinCover() {
return minCover;
}
public void setMinCover(double minCover) {
this.minCover = minCover;
}
public double getMaxCover() {
return maxCover;
}
public void setMaxCover(double maxCover) {
this.maxCover = maxCover;
}
public ThreeChannelMatrix getBackGround() {
return backGround;
}
public void setBackGround(ThreeChannelMatrix backGround) {
this.backGround = backGround;
}
public int getShrink() {
return shrink;

Loading…
Cancel
Save