Commit c0c2cd6a authored by Andrey Filippov's avatar Andrey Filippov

updating macro mode (preliminary correlation)

parent a2bb43cd
......@@ -2850,12 +2850,21 @@ public class EyesisCorrectionParameters {
public double mc_disp8_trust = 2.0; //Trust measured disparity within +/- this value
public double mc_strength = 0.2; // Minimal composite correlation to process (0.2..0.3)
public double mc_unique_tol = 0.05; // Do not re-measure macro correlation if target disparity differs from some previous by this
public double mc_trust_fin = 0.3; // When consolidating macro results, exclude high residual disparity
public double mc_trust_sigma = 0.2; // Gaussian sigma to reduce weight of large residual disparity
public double mc_ortho_weight = 0.5; // Weight from ortho neighbor supertiles
public double mc_diag_weight = 0.25; // Weight from diagonal neighbor supertiles
public double mc_gap = 0.4; // Do not remove measurements farther from the kept ones
public double mc_weight_var = 1.0; // weight of variance data (old, detects thin wires?)
public double mc_weight_Y = 1.0; // weight of average intensity
public double mc_weight_RBmG = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
// 0x1e, // 0x1f, // final int variants_mask,
public int gr_min_new = 20; // Discard variant if it requests too few tiles
public boolean gr_var_new_sngl = false;// Expand only unambiguous tiles over previously undefined
......@@ -3546,6 +3555,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"mc_diag_weight", this.mc_diag_weight +"");
properties.setProperty(prefix+"mc_gap", this.mc_gap +"");
properties.setProperty(prefix+"mc_weight_var", this.mc_weight_var +"");
properties.setProperty(prefix+"mc_weight_Y", this.mc_weight_Y +"");
properties.setProperty(prefix+"mc_weight_RBmG", this.mc_weight_RBmG +"");
properties.setProperty(prefix+"gr_min_new", this.gr_min_new+"");
properties.setProperty(prefix+"gr_var_new_sngl", this.gr_var_new_sngl+"");
properties.setProperty(prefix+"gr_var_new_fg", this.gr_var_new_fg+"");
......@@ -4212,6 +4225,10 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"mc_diag_weight")!=null) this.mc_diag_weight=Double.parseDouble(properties.getProperty(prefix+"mc_diag_weight"));
if (properties.getProperty(prefix+"mc_gap")!=null) this.mc_gap=Double.parseDouble(properties.getProperty(prefix+"mc_gap"));
if (properties.getProperty(prefix+"mc_weight_var")!=null) this.mc_weight_var=Double.parseDouble(properties.getProperty(prefix+"mc_weight_var"));
if (properties.getProperty(prefix+"mc_weight_Y")!=null) this.mc_weight_Y=Double.parseDouble(properties.getProperty(prefix+"mc_weight_Y"));
if (properties.getProperty(prefix+"mc_weight_RBmG")!=null) this.mc_weight_RBmG=Double.parseDouble(properties.getProperty(prefix+"mc_weight_RBmG"));
if (properties.getProperty(prefix+"gr_min_new")!=null) this.gr_min_new=Integer.parseInt(properties.getProperty(prefix+"gr_min_new"));
if (properties.getProperty(prefix+"gr_var_new_sngl")!=null) this.gr_var_new_sngl=Boolean.parseBoolean(properties.getProperty(prefix+"gr_var_new_sngl"));
if (properties.getProperty(prefix+"gr_var_new_fg")!=null) this.gr_var_new_fg=Boolean.parseBoolean(properties.getProperty(prefix+"gr_var_new_fg"));
......@@ -4973,6 +4990,15 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Weight from diagonal neighbor supertiles", this.mc_diag_weight, 6);
gd.addNumericField("Do not remove measurements farther from the kept ones", this.mc_gap, 6);
gd.addNumericField("weight of variance data ", this.mc_weight_var, 4, 6,"",
"This is what was used before - can detect tin wires, probably");
gd.addNumericField("Weight of average intensity", this.mc_weight_Y, 4, 6,"",
"Combination of R,G,B fro the tile");
gd.addNumericField("Weight of average color difference", this.mc_weight_RBmG, 4, 6,"",
"0.5*(R+B)-G");
gd.addTab ("Grow2", "More disparity range growing parameters");
gd.addMessage ("--- more growing parameters ---");
gd.addNumericField("Discard variant if it requests too few tiles", this.gr_min_new, 0);
......@@ -5671,11 +5697,15 @@ public class EyesisCorrectionParameters {
this.mc_strength= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_unique_tol= gd.getNextNumber();
this.mc_trust_fin= gd.getNextNumber();
this.mc_trust_sigma= gd.getNextNumber();
this.mc_ortho_weight= gd.getNextNumber();
this.mc_diag_weight= gd.getNextNumber();
this.mc_gap= gd.getNextNumber();
this.mc_weight_var= gd.getNextNumber();
this.mc_weight_Y= gd.getNextNumber();
this.mc_weight_RBmG= gd.getNextNumber();
this.gr_min_new= (int) gd.getNextNumber();
this.gr_var_new_sngl= gd.getNextBoolean();
......
This diff is collapsed.
......@@ -32,9 +32,21 @@ import java.util.concurrent.atomic.AtomicInteger;
public class MacroCorrelation {
TileProcessor tp; // pixel tile processor
TileProcessor mtp; // macro tile processor
double weight_var = 1.0; // weight of variance data (old, detects thin wires?)
double weight_Y = 1.0; // weight of average intensity
double weight_RBmG = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
public MacroCorrelation(
TileProcessor tp,
double trusted_correlation){
double trusted_correlation,
double weight_var, // = 1.0; // weight of variance data (old, detects thin wires?)
double weight_Y, // = 1.0; // weight of average intensity
double weight_RBmG // = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
){
this.weight_var = weight_var; // weight of variance data (old, detects thin wires?)
this.weight_Y = weight_Y; // weight of average intensity
this.weight_RBmG = weight_RBmG; // = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
this.tp = tp;
final int pTilesX = tp.getTilesX();
final int pTilesY = tp.getTilesY();
......@@ -61,40 +73,102 @@ public class MacroCorrelation {
final double macro_disparity_step,
final int debugLevel){
double [][][] input_data = CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
src_scan, // final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
null); // final double [][][] other_channels, // other channels to correlate, such as average RGB (first index - subcamera, 2-nd - channel, 3-rd - pixel)
double [][][] input_data = CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
src_scan); // final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
if (debugLevel > 0) {
final int pTilesX = tp.getTilesX();
final int pTilesY = tp.getTilesY();
final int tileSize = tp.getTileSize(); //
final int mTilesX = (pTilesX + tileSize - 1) / tileSize; // clt_aberrations_quad_corr truncates
final int mTilesY = (pTilesY + tileSize - 1) / tileSize;
String [] titles = {
"chn0-0","chn0-1","chn0-2",
"chn1-0","chn1-1","chn1-2",
"chn2-0","chn2-1","chn2-2",
"chn3-0","chn3-1","chn3-2"};
double [][] dbg_img = new double [input_data.length*input_data[0].length][];
for (int i=0; i < 12;i++) {
dbg_img[i] = input_data[i /3][i%3];
}
(new showDoubleFloatArrays()).showArrays(dbg_img, mTilesX*tileSize, mTilesY*tileSize, true, "input_data",titles);
}
mtp.resetCLTPasses();
for (double mdisp = macro_disparity_low; mdisp < (macro_disparity_high - macro_disparity_step); mdisp +=macro_disparity_step){
final CLTPass3d macro_scan = new CLTPass3d(mtp);
CLTMacroSetMeasure( // perform single pass according to prepared tiles operations and disparity
macro_scan, // final CLTPass3d macro_scan, // new, will be filled out
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
geometryCorrection, // GeometryCorrection geometryCorrection,
mdisp, // final double macro_disparity,
false, // final boolean show_corr_partial,
false, // final boolean show_corr_combo,
debugLevel); // final int debugLevel)
CLTMacroMeasure( // perform single pass according to prepared tiles operations and disparity
macro_scan, // final CLTPass3d macro_scan, //
input_data, // final double [][][] input_data,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
geometryCorrection, // GeometryCorrection geometryCorrection,
""+mdisp, // final String suffix,
false, // final boolean show_corr_partial,
false, // final boolean show_corr_combo,
debugLevel); // final int debugLevel)
mtp.clt_3d_passes.add(macro_scan);
if (input_data != null) {
final CLTPass3d macro_scan = new CLTPass3d(mtp);
CLTMacroSetMeasure( // perform single pass according to prepared tiles operations and disparity
macro_scan, // final CLTPass3d macro_scan, // new, will be filled out
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
geometryCorrection, // GeometryCorrection geometryCorrection,
mdisp, // final double macro_disparity,
false, // final boolean show_corr_partial,
false, // final boolean show_corr_combo,
debugLevel); // final int debugLevel)
CLTMacroMeasure( // perform single pass according to prepared tiles operations and disparity
macro_scan, // final CLTPass3d macro_scan, //
input_data, // final double [][][] input_data,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
geometryCorrection, // GeometryCorrection geometryCorrection,
""+mdisp, // final String suffix,
false, // final boolean show_corr_partial,
false, // final boolean show_corr_combo,
debugLevel); // final int debugLevel)
mtp.clt_3d_passes.add(macro_scan);
}
}
return mtp;
}
public double [][][] CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
public double [][][] CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
final CLTPass3d src_scan // results of the normal correlations (now expecting infinity)
)
{
// final int dbg_x = 295;
// final int dbg_y = 160;
final int pTilesX = tp.getTilesX();
final int pTilesY = tp.getTilesY();
final int tileSize = tp.getTileSize(); //
final int mTilesX = (pTilesX + tileSize - 1) / tileSize; // clt_aberrations_quad_corr truncates
final int mTilesY = (pTilesY + tileSize - 1) / tileSize;
final int mTiles = mTilesX * mTilesY;
final int num_chn = 3;
double corr_red = 0.5; // Red to green correlation weight
double corr_blue = 0.2; // Blue to green correlation weight
double [] col_weights = new double[3];
col_weights[2] = 1.0/(1.0 + corr_red + corr_blue); // green color
col_weights[0] = corr_red * col_weights[2];
col_weights[1] = corr_blue * col_weights[2];
final double [][][] input_data = new double [ImageDtt.QUAD][num_chn][mTiles*tileSize*tileSize];
final int INDX_R0 = ImageDtt.IMG_TONE_RGB;
final int INDX_B0 = ImageDtt.IMG_TONE_RGB + ImageDtt.QUAD;
final int INDX_G0 = ImageDtt.IMG_TONE_RGB + 2 * ImageDtt.QUAD;
for (int sub_cam =0; sub_cam < input_data.length; sub_cam++){
for (int pty = 0; pty < pTilesY; pty++){
for (int ptx = 0; ptx < pTilesX; ptx++){
int pTile = ptx + pty * pTilesX;
int mTile = ptx + pty * (mTilesX * tileSize);
input_data[sub_cam][0][mTile]= weight_var * src_scan.disparity_map[ImageDtt.IMG_DIFF0_INDEX + sub_cam][pTile];
double r = src_scan.disparity_map[INDX_R0 + sub_cam][pTile];
double b = src_scan.disparity_map[INDX_B0 + sub_cam][pTile];
double g = src_scan.disparity_map[INDX_G0 + sub_cam][pTile];
input_data[sub_cam][1][mTile]= weight_Y * (r * col_weights[0] + b * col_weights[1] + g * col_weights[2]);
input_data[sub_cam][2][mTile]= weight_RBmG * (0.5*(r + b) - g);
}
}
}
return input_data;
}
public double [][][] CLTMacroSetData_old( // perform single pass according to prepared tiles operations and disparity
final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
final double [][][] other_channels // other channels to correlate, such as average RGB (first index - subcamera, 2-nd - channel, 3-rd - pixel)
)
......@@ -141,6 +215,7 @@ public class MacroCorrelation {
public CLTPass3d CLTMacroSetMeasure( // perform single pass according to prepared tiles operations and disparity
final CLTPass3d macro_scan, // new, will be filled out
EyesisCorrectionParameters.CLTParameters clt_parameters,
......
......@@ -5883,15 +5883,26 @@ public class QuadCLT {
"after_bg-"+tp.clt_3d_passes.size());
}
// Test macro correlation and exit.
// final double weight_var = 1.0; // 1.0; // weight of variance data (old, detects thin wires?)
// final double weight_Y = 1.0; // weight of average intensity
// final double weight_RBmG = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
// TODO: Make double pass - with only weight_var (thin wires) and weight_Y, weight_RBmG - larger objects
// just use two instances of MacroCorrelation, run one after another (move code to MacroCorrelation class)
// and then join
MacroCorrelation mc = new MacroCorrelation(
tp,
clt_parameters.mc_disp8_trust);
clt_parameters.mc_disp8_trust,
clt_parameters.mc_weight_var, // final double weight_var, // weight of variance data (old, detects thin wires?)
clt_parameters.mc_weight_Y, // final double weight_Y, // weight of average intensity
clt_parameters.mc_weight_RBmG // final double weight_RBmG, // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
);
double [][][] input_data = mc.CLTMacroSetData( // perform single pass according to prepared tiles operations and disparity
bgnd_data, // final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
null); // final double [][][] other_channels, // other channels to correlate, such as average RGB (first index - subcamera, 2-nd - channel, 3-rd - pixel)
bgnd_data); // final CLTPass3d src_scan, // results of the normal correlations (now expecting infinity)
// null); // final double [][][] other_channels, // other channels to correlate, such as average RGB (first index - subcamera, 2-nd - channel, 3-rd - pixel)
TileProcessor mtp = mc.CLTMacroScan( // perform single pass according to prepared tiles operations and disparity
......
......@@ -51,7 +51,13 @@ public class TileProcessor {
"diff2max", // 17
"diff2maxAvg", // 18
"normStrength", // 19
"overexp"}; // 20
"overexp", // 20
"r0","r1","r2","r3",
"b0","b1","b2","b3",
"g0","g1","g2","g3",
"y0","y1","y2","y3",
"d0","d1","d2","d3"
};
public ArrayList <CLTPass3d> clt_3d_passes = null;
public double [][] rig_disparity_strength = null; // Disparity and strength created by a two-camera rig, with disparity scale and distortions of the main camera
......@@ -2241,10 +2247,22 @@ public class TileProcessor {
public double [][] getShowScan(
CLTPass3d scan)
{
int NUM_SLICES=getScanTitles().length;
int this_IMG_TONE_RGB = 21;
double corr_red = 0.5; // Red to green correlation weight
double corr_blue = 0.2; // Blue to green correlation weight
double scale_diff = 5.0; // scale 0.5*(r+b)-G to match Y
double [] col_weights = new double[3];
col_weights[2] = 1.0/(1.0 + corr_red + corr_blue); // green color
col_weights[0] = corr_red * col_weights[2];
col_weights[1] = corr_blue * col_weights[2];
int this_IMG_TONE_RGB_R = this_IMG_TONE_RGB + 0;
int this_IMG_TONE_RGB_B = this_IMG_TONE_RGB + 4;
int this_IMG_TONE_RGB_G = this_IMG_TONE_RGB + 8;
int this_IMG_TONE_RGB_Y = this_IMG_TONE_RGB+12;
int this_IMG_TONE_RGB_DIFF = this_IMG_TONE_RGB+16;
int tlen = tilesX*tilesY;
double [][] dbg_img = new double[NUM_SLICES][];
......@@ -2272,6 +2290,9 @@ public class TileProcessor {
dbg_img[ 8] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH];
dbg_img[ 9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
dbg_img[20] = scan.disparity_map[ImageDtt.OVEREXPOSED];
for (int i = 0; i < 12; i++) {
dbg_img[this_IMG_TONE_RGB+i] = scan.disparity_map[ImageDtt.IMG_TONE_RGB + i];
}
}
dbg_img[1] = scan.calc_disparity_combo;
dbg_img[6] = scan.strength;
......@@ -2293,13 +2314,26 @@ public class TileProcessor {
}
}
}
if (dbg_img[this_IMG_TONE_RGB] != null) {
for (int np = 0; np < 4; np++) {
dbg_img[this_IMG_TONE_RGB_Y+np] = new double [tlen];
dbg_img[this_IMG_TONE_RGB_DIFF+np] = new double [tlen];
for (int i = 0; i < tlen; i++){
dbg_img[this_IMG_TONE_RGB_Y+np][i] =
col_weights[0]*dbg_img[this_IMG_TONE_RGB_R + np][i] +
col_weights[1]*dbg_img[this_IMG_TONE_RGB_B + np][i] +
col_weights[2]*dbg_img[this_IMG_TONE_RGB_G + np][i];
dbg_img[this_IMG_TONE_RGB_DIFF+np][i] =
scale_diff* 0.5 * dbg_img[this_IMG_TONE_RGB_R + np][i] +
scale_diff* 0.5 * dbg_img[this_IMG_TONE_RGB_B + np][i] -
scale_diff* 1.0 * dbg_img[this_IMG_TONE_RGB_G + np][i];
}
}
}
}
return dbg_img;
}
public boolean [] getBackgroundMask( // which tiles do belong to the background
double bgnd_range, // disparity range to be considered background
double bgnd_sure, // minimal strength to be considered definitely background
......
......@@ -1545,7 +1545,7 @@ if (debugLevel > -100) return true; // temporarily !
rig_disparity_strength[0], // double [] disparity,
rig_disparity_strength[1], // double [] strength)
cond_sel); // boolean [] selected)
// CLT ASSIGN needs best texture for each tile. Initially will just copy from teh previous master
// CLT ASSIGN needs best texture for each tile. Initially will just copy from the previous master
// composite scan, later - fill disparity gaps and re-measure
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment