Commit 8d62abba authored by Andrey Filippov's avatar Andrey Filippov

working on high disparity objects

parent 21cc4033
......@@ -153,6 +153,7 @@ public class AlignmentCorrection {
tilesX,
magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
debugLevel);
/*
double [][][] disparity_corr_coefficiants = null;
if (clt_parameters.inf_disp_apply) {
disparity_corr_coefficiants = infinityCorrection(
......@@ -176,11 +177,13 @@ public class AlignmentCorrection {
"");// String prefix)
}
}
if (clt_parameters.inf_mism_apply) {
double [][][] mismatch_corr_coefficiants = infinityMismatchCorrection(
clt_parameters.fcorr_quadratic,// final boolean use_quadratic,
clt_parameters.fcorr_inf_vert,// final boolean use_vertical,
!clt_parameters.inf_disp_apply, // final boolean use_disparity, // for infinity
*/
double [][][] mismatch_corr_coefficiants = null;
// if (clt_parameters.inf_disp_apply) {
mismatch_corr_coefficiants = infinityMismatchCorrection(
clt_parameters.fcorr_inf_quad, // final boolean use_quadratic,
clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
clt_parameters.ly_inf_en, // final boolean use_disparity, // for infinity
clt_parameters,
disp_strength,
samples_list,
......@@ -193,6 +196,7 @@ public class AlignmentCorrection {
mismatch_corr_coefficiants, // double [][][] corr,
"");// String prefix)
}
/*
if (disparity_corr_coefficiants == null) {
disparity_corr_coefficiants = mismatch_corr_coefficiants;
if (debugLevel > -1){
......@@ -211,8 +215,9 @@ public class AlignmentCorrection {
System.out.println("infinityCorrection(): combining coefficient increments from infinityCorrection and infinityMismatchCorrection");
}
}
}
return disparity_corr_coefficiants;
*/
// }
return mismatch_corr_coefficiants;
}
/**
......@@ -622,7 +627,7 @@ public class AlignmentCorrection {
Matrix AINV = A.inverse();
double scale = 0.5/magic_coeff;
double [][] dbg_xy = null;
if (debugLevel > -1) {
if (debugLevel > 0) {
dbg_xy = new double [9][num_tiles];
}
for (Sample s: samples_list){
......@@ -1167,10 +1172,12 @@ public class AlignmentCorrection {
double sdw = 0.0, sw = 0.0;
double [] sm = new double [NUM_SLICES - 2];
for (int sY = 0; sY < smpl_side; sY++){
for (int sY = -smpl_side/2; sY < smpl_side/2; sY++){
int y = tY + sY;
for (int sX = 0; sX < smpl_side; sX++){
if ((y >= 0) && (y <tilesY)) {
for (int sX = -smpl_side/2; sX < smpl_side/2; sX++){
int x = tX + sX;
if ((x >= 0) && (x <tilesX)) {
int nTile = y * tilesX + x;
double w = disp_strength_in[1][nTile];
if (w > 0.0){
......@@ -1185,6 +1192,8 @@ public class AlignmentCorrection {
}
}
}
}
}
if ((num_samples > min_samples) && (sw > 0.0)){
int nTile = tY * tilesX + tX;
disp_strength[0][nTile] = sdw/sw; // weighted average disparity
......@@ -1370,7 +1379,77 @@ public class AlignmentCorrection {
}
}
public double [][] getFineCorrFromImage(
public double [][] getDoubleFromImage(
ImagePlus imp_src,
int debugLevel)
{
// double min_max_ratio = 1.3;
ImageStack clt_mismatches_stack= imp_src.getStack();
final int tilesX = clt_mismatches_stack.getWidth(); // tp.getTilesX();
final int tilesY = clt_mismatches_stack.getHeight(); // tp.getTilesY();
final int nTiles =tilesX * tilesY;
final double [][] data = new double [clt_mismatches_stack.getSize()][nTiles];
for (int n = 0; n < data.length; n++) {
float [] fpixels = (float[]) clt_mismatches_stack.getPixels(n +1);
for (int i = 0; i < nTiles; i++){
data[n][i] = fpixels[i];
}
}
return data;
}
public double [][] getFineCorrFromDoubleArray(
double [][] data,
int tilesX,
int debugLevel)
{
// double min_max_ratio = 1.3;
final int tilesY = data[0].length/tilesX; // tp.getTilesY();
final int nTiles =tilesX * tilesY;
final int num_scans = data.length/NUM_ALL_SLICES;
final double [][] scans = new double [num_scans * NUM_ALL_SLICES][nTiles];
for (int ns = 0; ns < num_scans; ns++){
// double [][]min_max_strength = new double[2][nTiles];
for (int pair = 0; pair < 4; pair++){
float [][] fset = new float [3][];
// fset[0] = (float[]) clt_mismatches_stack.getPixels(12 * num_scans + ns +1);
// fset[1] = (float[]) clt_mismatches_stack.getPixels(13 * num_scans + ns +1); //
scans[ns * NUM_ALL_SLICES + 0] = data[12 * num_scans + ns];
scans[ns * NUM_ALL_SLICES + 1] = data[13 * num_scans + ns];
// for (int i = 0; i < nTiles; i++){
// scans[ns * NUM_ALL_SLICES + 0][i] = fset[0][i]; // disparity
// scans[ns * NUM_ALL_SLICES + 1][i] = fset[1][i]; // strength
// }
// fset[0] = (float[]) clt_mismatches_stack.getPixels((2 * pair + 0) * num_scans + ns +1);
// fset[1] = (float[]) clt_mismatches_stack.getPixels((2 * pair + 1) * num_scans + ns +1); //
// fset[2] = (float[]) clt_mismatches_stack.getPixels((8 + pair ) * num_scans + ns +1);
scans[ns * NUM_ALL_SLICES + pair * 3 + 2] = data[(2 * pair + 0) * num_scans + ns];
scans[ns * NUM_ALL_SLICES + pair * 3 + 3] = data[(2 * pair + 1) * num_scans + ns];
scans[ns * NUM_ALL_SLICES + pair * 3 + 4] = data[(8 + pair ) * num_scans + ns];
// for (int i = 0; i < nTiles; i++){
// scans[ns * NUM_ALL_SLICES + pair * 3 + 2][i] = fset[0][i]; // dx_i
// scans[ns * NUM_ALL_SLICES + pair * 3 + 3][i] = fset[1][i]; // dy_i
// scans[ns * NUM_ALL_SLICES + pair * 3 + 4][i] = fset[2][i]; // str_i
// }
}
}
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "str0", "dx1", "dy1", "str1", "dx2", "dy2", "str2", "dx3", "dy3", "str3"};
String [] titles = new String [num_scans * NUM_ALL_SLICES];
for (int ns = 0; ns < num_scans; ns++){
for (int i = 0; i < NUM_ALL_SLICES; i++){
titles[ns * NUM_ALL_SLICES + i] = prefixes[i]+"_"+ns;
}
}
(new showDoubleFloatArrays()).showArrays(scans, tilesX, tilesY, true, "scans" , titles);
}
return scans;
}
public double [][] getFineCorrFromImage_old(
ImagePlus imp_src,
int debugLevel)
{
......@@ -1397,28 +1476,13 @@ public class AlignmentCorrection {
fset[1] = (float[]) clt_mismatches_stack.getPixels((2 * pair + 1) * num_scans + ns +1); //
fset[2] = (float[]) clt_mismatches_stack.getPixels((8 + pair ) * num_scans + ns +1);
for (int i = 0; i < nTiles; i++){
// if (i == 55156) { // 52564){
// System.out.println("tile="+i+" scan="+ns+" pair = "+pair+ "fset[2]["+i+"]="+fset[2][i]);
// }
scans[ns * NUM_ALL_SLICES + pair * 3 + 2][i] = fset[0][i]; // dx_i
scans[ns * NUM_ALL_SLICES + pair * 3 + 3][i] = fset[1][i]; // dy_i
scans[ns * NUM_ALL_SLICES + pair * 3 + 4][i] = fset[2][i]; // str_i
// if ((pair == 0) || (fset[2][i] < min_max_strength[0][i])) min_max_strength[0][i] = fset[2][i];
// if ((pair == 0) || (fset[2][i] > min_max_strength[1][i])) min_max_strength[1][i] = fset[2][i];
// if (fset[2][i] < min_comp_strength) {
// scans[ns * NUM_SLICES + 1][i] = -1.0; // -1.0 - temporary to indicate
// };
}
}
// for (int i = 0; i < nTiles; i++){
// if (min_max_strength[1][i] > (min_max_ratio * min_max_strength[0][i]) ){
// scans[ns * NUM_SLICES + 1][i] = -1.0; // -1.0 - temporary to indicate
// }
// }
}
if (debugLevel > -1) {
// String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "str0", "dx1", "dy1", "str1", "dx2", "dy2", "str2", "dx3", "dy3", "str3"};
String [] titles = new String [num_scans * NUM_ALL_SLICES];
for (int ns = 0; ns < num_scans; ns++){
......@@ -1436,7 +1500,7 @@ public class AlignmentCorrection {
public double [][][] lazyEyeCorrection(
final double min_strength_in,
final double max_diff,
final double comp_strength_var,
// final double comp_strength_var,
final int max_iterations,
final double max_coeff_diff,
final double far_pull, // = 0.2; // 1; // 0.5;
......@@ -1475,6 +1539,10 @@ public class AlignmentCorrection {
scans[ns * NUM_SLICES + i] = scans_14[ns * NUM_ALL_SLICES + indices_14_10[i]];
}
}
// (new showDoubleFloatArrays()).showArrays(scans_14, tilesX, tilesY, true, "scans14");
// (new showDoubleFloatArrays()).showArrays(scans, tilesX, tilesY, true, "scans10");
for (int ns = 0; ns < num_scans; ns++){
for (int nTile = 0; nTile < num_tiles; nTile++){
double s1=0.0, s2=0.0;
......@@ -1510,7 +1578,7 @@ public class AlignmentCorrection {
* None of comp_strength_rms methods works to detect potential outliers for horizontal/vertical features
*/
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] titles = new String [num_scans];
for (int ns = 0; ns < num_scans; ns++){
titles[ns] = "scan_" + ns;
......@@ -1529,18 +1597,9 @@ public class AlignmentCorrection {
tilesX);// final int tilesX);
if (debugLevel > -1) {
System.out.println("lazyEyeCorrection() 1: removing tile with residual disparity absoulte value > "+lazyEyeCompDiff);
System.out.println("lazyEyeCorrection() 1: removing tiles with residual disparity absoulte value > "+lazyEyeCompDiff);
}
/*
for (int ns = 0; ns < num_scans; ns++){
for (int i = 0; i < num_tiles; i++){
double disp = filtered_scans[ns * NUM_SLICES + 0][i];
if (Math.abs(disp) > lazyEyeCompDiff) {
filtered_scans[ns * NUM_SLICES + 1][i] = 0.0;
}
}
}
*/
double [][] combo_mismatch = new double [NUM_SLICES][num_tiles];
double [] combo_comp_rms = new double [num_tiles];
for (int ns = 0; ns < num_scans; ns++){
......@@ -1598,7 +1657,7 @@ public class AlignmentCorrection {
}
}
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
}
......@@ -1612,7 +1671,7 @@ public class AlignmentCorrection {
true, // final boolean norm_center, // if there are more tiles that fit than minsamples, replace with a single equal weight
tilesX); // final int tilesX);
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "filtered_mismatch" , prefixes);
}
......@@ -1666,7 +1725,7 @@ public class AlignmentCorrection {
hist_min_samples, // final int min_samples,
hist_norm_center, // final boolean norm_center, // if there are more tiles that fit than minsamples, replace with
tilesX); // final int tilesX)
if (debugLevel > 0){
if (debugLevel > 1){
double [][] dbg_img = inf_scan.clone();
for (int n = 0; n < inf_scan.length; n++){
dbg_img[n] = inf_scan[n].clone();
......@@ -1689,7 +1748,7 @@ public class AlignmentCorrection {
}
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
String [] titles = new String [2 * NUM_SLICES];
for (int i = 0; i < NUM_SLICES; i++){
......@@ -1805,7 +1864,7 @@ public class AlignmentCorrection {
}
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
String [] titles = new String [num_scans * NUM_SLICES];
for (int ns = 0; ns < num_scans; ns++){
......@@ -1817,7 +1876,7 @@ public class AlignmentCorrection {
}
if (debugLevel > -1) {
if (debugLevel > 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
}
......@@ -1842,7 +1901,83 @@ public class AlignmentCorrection {
return mismatch_corr_coefficiants;
}
public double [][] combineCltMismatches(
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][][] clt_mismatches,
double [][][] disparity_maps,
int disparity_index,
int strength_index)
{
int n = clt_mismatches.length;
double [][] combo = new double [clt_parameters.disp_scan_count * AlignmentCorrection.NUM_ALL_SLICES][];
for (int pair = 0; pair < 4; pair++){
for (int i = 0; i < n; i++){
combo[(2 * pair + 0) * n + i] = clt_mismatches[i][3 * pair + 0];
combo[(2 * pair + 1) * n + i] = clt_mismatches[i][3 * pair + 1];
combo[(2 * 4 + pair) * n + i] = clt_mismatches[i][3 * pair + 2];
}
}
for (int i = 0; i < n; i++){
combo[12 * n + i] = disparity_maps[i][disparity_index];
combo[13 * n + i] = disparity_maps[i][strength_index];
}
return combo;
}
public void showCltMismatches(
String title,
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] combo_data,
int tilesX,
int tilesY)
{
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
String [] titles = new String [combo_data.length];
int num_scans = combo_data.length / AlignmentCorrection.NUM_ALL_SLICES;
for (int pair = 0; pair < 4; pair++){
for (int i = 0; i < num_scans; i++){
double disparity = clt_parameters.disp_scan_start + i * clt_parameters.disp_scan_step;
titles[(2 * pair + 0) * num_scans + i] = "dx_"+pair+"_"+disparity;
titles[(2 * pair + 1) * num_scans + i] = "dy_"+pair+"_"+disparity;
titles[(2 * 4 + pair) * num_scans + i] = "strength_"+pair+"_"+disparity;
}
}
for (int i = 0; i < num_scans; i++){
double disparity = clt_parameters.disp_scan_start + i * clt_parameters.disp_scan_step;
titles[ 12 * num_scans + i] = "disp_"+disparity;
titles[ 13 * num_scans + i] = "strength_"+disparity;
}
sdfa_instance.showArrays(combo_data, tilesX,tilesY, true, title, titles);
}
public void showCltMismatch(
String title,
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] clt_mismatch,
int tilesX,
int tilesY)
{
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
String [] titles = new String [12];
double [][] dbg_clt_mismatch= new double [12][];
for (int pair = 0; pair < 4; pair++){
titles[2 * pair + 0] = "dx_"+pair;
titles[2 * pair + 1] = "dy_"+pair;
titles[2 * 4 + pair] = "strength_"+pair;
dbg_clt_mismatch[(2 * pair + 0)] = clt_mismatch[3 * pair + 0].clone();
dbg_clt_mismatch[(2 * pair + 1)] = clt_mismatch[3 * pair + 1].clone();
dbg_clt_mismatch[(2 * 4 + pair)] = clt_mismatch[3 * pair + 2];
for (int i = 0; i < dbg_clt_mismatch[(2 * 4 + pair)].length; i++ ){
if (dbg_clt_mismatch[(2 * 4 + pair)][i] == 0.0){
dbg_clt_mismatch[(2 * pair + 0)][i] = Double.NaN;
dbg_clt_mismatch[(2 * pair + 1)][i] = Double.NaN;
}
}
}
sdfa_instance.showArrays(dbg_clt_mismatch, tilesX, tilesY, true, title, titles);
}
public void process_fine_corr(
......
......@@ -51,7 +51,7 @@ public class CLTPass3d{
public boolean [] border_tiles = null; // these are border tiles, zero out alpha
public boolean [] selected = null; // which tiles are selected for this layer
public double [][][][] texture_tiles;
public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity wor this tile, regardless of results
public double [][] max_tried_disparity = null; //[ty][tx] used for combined passes, shows maximal disparity for this tile, regardless of results
public boolean is_combo = false;
public boolean is_measured = false;
public String texture = null; // relative (to x3d) path
......@@ -190,6 +190,7 @@ public class CLTPass3d{
*/
public double [][] getDiffs (){
if (disparity_map == null) return null;
double [][] these_diffs = new double[ImageDtt.QUAD][];
for (int i = 0; i< ImageDtt.QUAD; i++) these_diffs[i] = disparity_map[ImageDtt.IMG_DIFF0_INDEX + i];
return these_diffs;
......@@ -208,6 +209,10 @@ public class CLTPass3d{
return selected;
}
public boolean [] getBorderTiles(){
return this.border_tiles;
}
public void setSelected (boolean [] selected) {
this.selected = selected;
}
......@@ -444,7 +449,7 @@ public class CLTPass3d{
* Replaces current combo disparity for tiles that are weak and do not have any neighbor within disparity range from this one
* @param selection optional boolean mask of tiles to use/update
* @param weakStrength maximal strength of the tile to be considered weak one
* @param maxDiff maximal difference from the most similar neighbor to be considered an outlayer
* @param maxDiff maximal difference from the most similar neighbor to be considered an outlier
* @param disparityFar minimal acceptable disparity for weak tiles
* @param disparityNear maximal acceptable disparity for weak tiles
* @return mask of weak (replaced) tiles
......@@ -455,8 +460,8 @@ public class CLTPass3d{
final boolean [] selection,
final double weakStrength, // strength to be considered weak, subject to this replacement
final double maxDiff,
final double maxDiffPos, // Replace weak outlayer tiles that have higher disparity than weighted average
final double maxDiffNeg, // Replace weak outlayer tiles that have lower disparity than weighted average
final double maxDiffPos, // Replace weak outlier tiles that have higher disparity than weighted average
final double maxDiffNeg, // Replace weak outlier tiles that have lower disparity than weighted average
final double disparityFar,
final double disparityNear,
final int debugLevel)
......@@ -474,7 +479,7 @@ public class CLTPass3d{
final double absMaxDisparity = 1.5 * disparityNear; // change?
final int dbg_nTile = (debugLevel > 0) ? 43493: -1; // x=77,y=134; // 42228; // x = 108, y = 130 46462; // 41545;
final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax);
// first pass = find outlayers
// first pass = find outliers
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
......@@ -507,7 +512,7 @@ public class CLTPass3d{
sw += w;
sd += w * disparity[nTile1];
hasNeighbors = true;
if (Math.abs(disparity[nTile]-disparity[nTile1]) <= maxDiff){ // any outlayer - will be false
if (Math.abs(disparity[nTile]-disparity[nTile1]) <= maxDiff){ // any outlier - will be false
weakOutlayers[nTile] = false;
// break;
}
......@@ -531,7 +536,7 @@ public class CLTPass3d{
}
ImageDtt.startAndJoin(threads);
// second pass - replace outlayers
// second pass - replace outliers
final double [] src_disparity = disparity.clone();
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
......@@ -580,6 +585,167 @@ public class CLTPass3d{
return weakOutlayers;
}
public boolean [] getUntestedBackgroundBorder (
final boolean [] known,
final double [] disparity,
final double grow_disp_step,
final int debugLevel)
{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
final int num_tiles = tilesX * tilesY;
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX);
final boolean [] untested_bgnd = new boolean [num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
if (known[nTile]){
int tX = nTile % tilesX;
int tY = nTile / tilesX;
double max_disp = max_tried_disparity[tY][tX] + grow_disp_step;
for (int dir = 0; dir < 8; dir++){
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ((nTile1 >=0) && known[nTile1] && (disparity[nTile1] > max_disp)) {
untested_bgnd[nTile] = true;
break;
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return untested_bgnd;
}
public boolean [] measuredTiles ()
{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
final int num_tiles = tilesX * tilesY;
final boolean [] measured = new boolean [num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
int tX = nTile % tilesX;
int tY = nTile / tilesX;
measured[nTile] = tile_op[tY][tX] != 0;
}
}
};
}
ImageDtt.startAndJoin(threads);
return measured;
}
public double [] getSecondMaxDiff (
final boolean averaged)
{
final double [][] diffs = getDiffs();
if (diffs == null) return null;
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
final int num_tiles = tilesX * tilesY;
final double [] second_max = new double [num_tiles];
final boolean [] measured = measuredTiles ();
final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
int imax1 = 0;
for (int ip = 1; ip < diffs.length; ip++){
if (diffs[ip][nTile] > diffs[imax1][nTile]) imax1 = ip;
}
int imax2 = (imax1 == 0)? 1 : 0;
for (int ip = 0; ip < diffs.length; ip++) if (ip != imax1) {
if (diffs[ip][nTile] > diffs[imax2][nTile]) imax2 = ip;
}
second_max[nTile] = diffs[imax2][nTile];
}
}
};
}
ImageDtt.startAndJoin(threads);
if (!averaged) return second_max;
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX);
final double [] second_max_averaged = new double [num_tiles];
final double [] dir_weights = {1.0/16, 1.0/8, 1.0/16, 1.0/8, 1.0/16, 1.0/8, 1.0/16, 1.0/8, 1.0/4};
ai.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (measured[nTile]) {
double sw = 0.0;
double swd = 0.0;
for (int dir = 0; dir < 9; dir++){ // including 8 - center
int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ((nTile1 >=0) && measured[nTile1]) {
sw += dir_weights[dir];
swd += dir_weights[dir] * second_max[nTile1] ;
}
}
second_max_averaged[nTile] = swd/sw;
}
}
};
}
ImageDtt.startAndJoin(threads);
return second_max_averaged;
}
// same, but 2 steps around
public boolean [] getUntestedBackgroundBorder2 (
final boolean [] known,
final double [] disparity,
final double grow_disp_step,
final int debugLevel)
{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
final int num_tiles = tilesX * tilesY;
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX);
final boolean [] untested_bgnd = new boolean [num_tiles];
final Thread[] threads = ImageDtt.newThreadArray(tileProcessor.threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
if (known[nTile]){
int tX = nTile % tilesX;
int tY = nTile / tilesX;
double max_disp = max_tried_disparity[tY][tX] + grow_disp_step;
for (int dir = 0; dir < 24; dir++){
int nTile1 = tnImage.getNeibIndex2(nTile, dir);
if ((nTile1 >=0) && known[nTile1] && (disparity[nTile1] > max_disp)) {
untested_bgnd[nTile] = true;
break;
}
}
}
}
}
};
}
ImageDtt.startAndJoin(threads);
return untested_bgnd;
}
public SuperTiles getSuperTiles()
{
return this.superTiles;
......
......@@ -1986,6 +1986,7 @@ public class EyesisCorrectionParameters {
public boolean gen_chn_stacks = false; // generate shifted channel rgb stacks
public boolean gen_chn_img = true; // generate shifted channel images
public boolean gen_4_img = true; // Generate shifted channel images and save with the model
public boolean show_nonoverlap = true; // show result RGBA before overlap combined (first channels, then RGBA combined?)
public boolean show_overlap = true; // show result RGBA (first channels, then RGBA combined?)
public boolean show_rgba_color = true; // show combined color image
......@@ -1995,6 +1996,7 @@ public class EyesisCorrectionParameters {
public double disp_scan_step = 1.0; // disparity scan step
public int disp_scan_count = 10; // disparity scan number of measurements
public boolean fine_dbg = false; // Debug infinity/lazy eye correction
public double fine_corr_x_0 = 0.0; // additionally shift image in port 0 in x direction
public double fine_corr_y_0 = 0.0; // additionally shift image in port 0 in y direction
public double fine_corr_x_1 = 0.0; // additionally shift image in port 1 in x direction
......@@ -2015,7 +2017,8 @@ public class EyesisCorrectionParameters {
//--
public boolean inf_disp_apply = true; // Apply disparity correction to zero at infinity
public boolean inf_mism_apply = true; // Apply lazy eye correction at infinity
public int inf_repeat = 5; // Re run disparity correction at infinity multiple times
// public boolean inf_mism_apply = true; // Apply lazy eye correction at infinity
public int inf_iters = 20; // Infinity extraction - maximum iterations
public double inf_final_diff = 0.0001; // Coefficients maximal increment to exit iterations
......@@ -2037,22 +2040,36 @@ public class EyesisCorrectionParameters {
public int ih_min_samples = 10; // Minimal number of remaining samples
public boolean ih_norm_center = true; // Replace samples with a single average with equal weight
// Lazy eye parameters
public int ly_smpl_side = 3; // Sample size (side of a square)
public int ly_smpl_num = 5; // Number after removing worst (should be >1)
public double ly_meas_disp = 1.5; // Maximal measured relative disparity
public double ly_smpl_rms = 0.1; // Maximal RMS of the remaining tiles in a sample
public double ly_disp_var = 0.2; // Maximal full disparity difference to 8 neighbors
public double ly_inf_frac = 0.5; // Relative weight of infinity calibration data
public boolean ly_on_scan = true; // Calculate and apply lazy eye correction after disparity scan
public boolean ly_inf_en = true; // Simultaneously correct disparity at infinity
// old fcorr parameters, reuse?
public int fcorr_sample_size = 32; // Use square this size side to detect outliers
public int fcorr_mintiles = 8; // Keep tiles only if there are more in each square
public double fcorr_reloutliers = 0.5; // Remove this fraction of tiles from each sample
public double fcorr_sigma = 20.0; // Gaussian blur channel mismatch data
// public int fcorr_sample_size = 32; // Use square this size side to detect outliers
// public int fcorr_mintiles = 8; // Keep tiles only if there are more in each square
// public double fcorr_reloutliers = 0.5; // Remove this fraction of tiles from each sample
// public double fcorr_sigma = 20.0; // Gaussian blur channel mismatch data
public double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood)
// 3d reconstruction
public boolean show_textures = true; // show generated textures
public boolean debug_filters = false;// show intermediate results of filtering
// not used anywhere so far
public double min_smth = 0.25; // 0.25 minimal noise-normalized pixel difference in a channel to suspect something
public double sure_smth = 2.0; // reliable noise-normalized pixel difference in a channel to have something
public double bgnd_range = 0.3; // disparity range to be considered background
public double other_range = 2.0; // disparity difference from center (provided) disparity to trust
public double ex_strength = 0.18; // minimal 4-corr strength to trust tile
public double ex_nstrength = 0.4; // minimal 4-corr strength divided by channel diff for new (border) tiles
public double bgnd_sure = 0.18; // minimal strength to be considered definitely background
public double bgnd_maybe = 0.1; // maximal strength to ignore as non-background
// public double bgnd_2diff = 0.005; // maximal strength to ignore as non-background
......@@ -2071,6 +2088,7 @@ public class EyesisCorrectionParameters {
public double ortho_min_hor = 0.07; // minimal strength of hor correlation to be used instead of full 4-pair correlation -
public double ortho_min_vert = 0.15; // minimal strength of vert correlation to be used instead of full 4-pair correlation
public double ortho_asym = 1.2; // vert/hor (or hor/vert) strength to be used instead of the full correlation
public double ortho_over4 = 0.8; // vert/hor (or hor/vert) strength exceeding scaled 4-pair strength
public double ortho_sustain = 0.05; // minimal strength of hor/vert to bridge over
public int ortho_run = 3; // minimal run of hor/vert tiles to be considered (at least from one side)
public double ortho_minmax = 0.09; // minimal maximal strength in an ortho run
......@@ -2144,9 +2162,9 @@ public class EyesisCorrectionParameters {
public boolean stShow = false; // Calculate and show supertiles histograms
public int stSize = 8; // Super tile size (square, in tiles)
public double stStepFar = 0.1; // Disaprity histogram step for far objects
public double stStepNear = 0.5; // Disaprity histogram step for near objects
public double stStepThreshold = 1.0; // Disaprity threshold to switch cfrom linear to logarithmic steps
public double stStepFar = 0.1; // Disparity histogram step for far objects
public double stStepNear = 0.5; // Disparity histogram step for near objects
public double stStepThreshold = 1.0; // Disparity threshold to switch from linear to logarithmic steps
public double stMinDisparity = 0.0; // Minimal disparity (center of a bin)
public double stMaxDisparity = 15.0; // Maximal disparity (center of a bin)
public double stFloor = 0.15; // Subtract from strength, discard negative
......@@ -2184,12 +2202,16 @@ public class EyesisCorrectionParameters {
// Multi-pass growing disparity
public int grow_sweep = 8; // Try these number of tiles around known ones
public double grow_disp_max = 100.0; // Maximal disparity to try
public double grow_disp_trust = 4.0; // Trust measured disparity within +/- this value
public double grow_disp_trust = 6.0; // Trust measured disparity within +/- this value
public double grow_disp_step = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips?
public double grow_min_diff = 0.5; // Grow more only if at least one channel has higher variance from others for the tile
public boolean grow_retry_far = false; // Retry tiles around known foreground that have low max_tried_disparity
public boolean grow_pedantic = false; // Scan full range between max_tried_disparity of the background and known foreground
public boolean grow_retry_inf = false; // Retry border tiles that were identified as infinity earlier
public boolean plPreferDisparity = false;// Always start with disparity-most axis (false - lowest eigenvalue)
public double plDispNorm = 3.0; // Normalize disparities to the average if above (now only for eigenvalue comparison)
public double plDispNorm = 5.0; // Normalize disparities to the average if above (now only for eigenvalue comparison)
public double plBlurBinVert = 1.2; // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
public double plBlurBinHor = 0.8; // Blur disparity histograms for horizontal clusters by this sigma (in bins)
......@@ -2441,6 +2463,7 @@ public class EyesisCorrectionParameters {
public boolean show_unique = false; // show 'unique_scan' (removed already measured tiles with the same disparity)
public boolean show_init_refine = false; // show debug images during initial refinement
public boolean show_expand = false; // show debug images during disparity expansion
public boolean show_retry_far = false; // show debug images related to retrying far tiles near foreground
public boolean show_shells = false; // show 'shells'
public boolean show_neighbors = false; // show 'neighbors'
......@@ -2519,6 +2542,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"gen_chn_stacks", this.gen_chn_stacks+"");
properties.setProperty(prefix+"gen_chn_img", this.gen_chn_img+"");
properties.setProperty(prefix+"gen_4_img", this.gen_4_img+"");
properties.setProperty(prefix+"show_nonoverlap", this.show_nonoverlap+"");
properties.setProperty(prefix+"show_overlap", this.show_overlap+"");
properties.setProperty(prefix+"show_rgba_color", this.show_rgba_color+"");
......@@ -2527,6 +2551,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"disp_scan_step", this.disp_scan_step +"");
properties.setProperty(prefix+"disp_scan_count", this.disp_scan_count+"");
properties.setProperty(prefix+"fine_dbg", this.fine_dbg+"");
properties.setProperty(prefix+"fine_corr_x_0", this.fine_corr_x_0 +"");
properties.setProperty(prefix+"fine_corr_y_0", this.fine_corr_y_0 +"");
properties.setProperty(prefix+"fine_corr_x_1", this.fine_corr_x_1 +"");
......@@ -2547,7 +2572,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"fcorr_inf_vert", this.fcorr_inf_vert+"");
properties.setProperty(prefix+"inf_disp_apply", this.inf_disp_apply+"");
properties.setProperty(prefix+"inf_mism_apply", this.inf_mism_apply+"");
properties.setProperty(prefix+"inf_repeat", this.inf_repeat+"");
// properties.setProperty(prefix+"inf_mism_apply", this.inf_mism_apply+"");
properties.setProperty(prefix+"inf_iters", this.inf_iters+"");
properties.setProperty(prefix+"inf_final_diff", this.inf_final_diff +"");
properties.setProperty(prefix+"inf_far_pull", this.inf_far_pull +"");
......@@ -2565,10 +2592,14 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"ih_min_samples", this.ih_min_samples+"");
properties.setProperty(prefix+"ih_norm_center", this.ih_norm_center+"");
properties.setProperty(prefix+"fcorr_sample_size",this.fcorr_sample_size+"");
properties.setProperty(prefix+"fcorr_mintiles", this.fcorr_mintiles+"");
properties.setProperty(prefix+"fcorr_reloutliers",this.fcorr_reloutliers +"");
properties.setProperty(prefix+"fcorr_sigma", this.fcorr_sigma +"");
properties.setProperty(prefix+"ly_smpl_side", this.ly_smpl_side+"");
properties.setProperty(prefix+"ly_smpl_num", this.ly_smpl_num+"");
properties.setProperty(prefix+"ly_meas_disp", this.ly_meas_disp +"");
properties.setProperty(prefix+"ly_smpl_rms", this.ly_smpl_rms +"");
properties.setProperty(prefix+"ly_disp_var", this.ly_disp_var +"");
properties.setProperty(prefix+"ly_inf_frac", this.ly_inf_frac +"");
properties.setProperty(prefix+"ly_on_scan", this.ly_on_scan+"");
properties.setProperty(prefix+"ly_inf_en", this.ly_inf_en+"");
properties.setProperty(prefix+"corr_magic_scale", this.corr_magic_scale +"");
......@@ -2579,6 +2610,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"sure_smth", this.sure_smth +"");
properties.setProperty(prefix+"bgnd_range", this.bgnd_range +"");
properties.setProperty(prefix+"other_range", this.other_range +"");
properties.setProperty(prefix+"ex_strength", this.ex_strength +"");
properties.setProperty(prefix+"ex_nstrength", this.ex_nstrength +"");
properties.setProperty(prefix+"bgnd_sure", this.bgnd_sure +"");
properties.setProperty(prefix+"bgnd_maybe", this.bgnd_maybe +"");
properties.setProperty(prefix+"min_clstr_seed", this.min_clstr_seed+"");
......@@ -2595,6 +2630,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"ortho_min_hor", this.ortho_min_hor +"");
properties.setProperty(prefix+"ortho_min_vert", this.ortho_min_vert +"");
properties.setProperty(prefix+"ortho_asym", this.ortho_asym +"");
properties.setProperty(prefix+"ortho_over4", this.ortho_over4 +"");
properties.setProperty(prefix+"ortho_sustain", this.ortho_sustain +"");
properties.setProperty(prefix+"ortho_run", this.ortho_run+"");
properties.setProperty(prefix+"ortho_minmax", this.ortho_minmax +"");
......@@ -2705,6 +2741,9 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"grow_disp_trust", this.grow_disp_trust +"");
properties.setProperty(prefix+"grow_disp_step", this.grow_disp_step +"");
properties.setProperty(prefix+"grow_min_diff", this.grow_min_diff +"");
properties.setProperty(prefix+"grow_retry_far", this.grow_retry_far+"");
properties.setProperty(prefix+"grow_pedantic", this.grow_pedantic+"");
properties.setProperty(prefix+"grow_retry_inf", this.grow_retry_inf+"");
properties.setProperty(prefix+"plPreferDisparity",this.plPreferDisparity+"");
properties.setProperty(prefix+"plDispNorm", this.plDispNorm +"");
......@@ -2932,6 +2971,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"show_unique", this.show_unique+"");
properties.setProperty(prefix+"show_init_refine", this.show_init_refine+"");
properties.setProperty(prefix+"show_expand", this.show_expand+"");
properties.setProperty(prefix+"show_retry_far", this.show_retry_far+"");
properties.setProperty(prefix+"show_shells", this.show_shells+"");
properties.setProperty(prefix+"show_neighbors", this.show_neighbors+"");
properties.setProperty(prefix+"show_flaps_dirs", this.show_flaps_dirs+"");
......@@ -3008,6 +3048,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"alpha1")!=null) this.alpha1=Double.parseDouble(properties.getProperty(prefix+"alpha1"));
if (properties.getProperty(prefix+"gen_chn_stacks")!=null) this.gen_chn_stacks=Boolean.parseBoolean(properties.getProperty(prefix+"gen_chn_stacks"));
if (properties.getProperty(prefix+"gen_chn_img")!=null) this.gen_chn_img=Boolean.parseBoolean(properties.getProperty(prefix+"gen_chn_img"));
if (properties.getProperty(prefix+"gen_4_img")!=null) this.gen_4_img=Boolean.parseBoolean(properties.getProperty(prefix+"gen_4_img"));
if (properties.getProperty(prefix+"show_nonoverlap")!=null)this.show_nonoverlap=Boolean.parseBoolean(properties.getProperty(prefix+"show_nonoverlap"));
if (properties.getProperty(prefix+"show_overlap")!=null) this.show_overlap=Boolean.parseBoolean(properties.getProperty(prefix+"show_overlap"));
if (properties.getProperty(prefix+"show_rgba_color")!=null)this.show_rgba_color=Boolean.parseBoolean(properties.getProperty(prefix+"show_rgba_color"));
......@@ -3016,6 +3057,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"disp_scan_step")!=null) this.disp_scan_step=Double.parseDouble(properties.getProperty(prefix+"disp_scan_step"));
if (properties.getProperty(prefix+"disp_scan_count")!=null)this.disp_scan_count=Integer.parseInt(properties.getProperty(prefix+"disp_scan_count"));
if (properties.getProperty(prefix+"fine_dbg")!=null) this.fine_dbg=Boolean.parseBoolean(properties.getProperty(prefix+"fine_dbg"));
if (properties.getProperty(prefix+"fine_corr_x_0")!=null) this.fine_corr_x_0=Double.parseDouble(properties.getProperty(prefix+"fine_corr_x_0"));
if (properties.getProperty(prefix+"fine_corr_y_0")!=null) this.fine_corr_y_0=Double.parseDouble(properties.getProperty(prefix+"fine_corr_y_0"));
if (properties.getProperty(prefix+"fine_corr_x_1")!=null) this.fine_corr_x_1=Double.parseDouble(properties.getProperty(prefix+"fine_corr_x_1"));
......@@ -3038,7 +3080,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"inf_disp_apply")!=null) this.inf_disp_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_disp_apply"));
if (properties.getProperty(prefix+"inf_mism_apply")!=null) this.inf_mism_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_mism_apply"));
if (properties.getProperty(prefix+"inf_repeat")!=null) this.inf_repeat=Integer.parseInt(properties.getProperty(prefix+"inf_repeat"));
// if (properties.getProperty(prefix+"inf_mism_apply")!=null) this.inf_mism_apply=Boolean.parseBoolean(properties.getProperty(prefix+"inf_mism_apply"));
if (properties.getProperty(prefix+"inf_iters")!=null) this.inf_iters=Integer.parseInt(properties.getProperty(prefix+"inf_iters"));
if (properties.getProperty(prefix+"inf_final_diff")!=null) this.inf_final_diff=Double.parseDouble(properties.getProperty(prefix+"inf_final_diff"));
if (properties.getProperty(prefix+"inf_far_pull")!=null) this.inf_far_pull=Double.parseDouble(properties.getProperty(prefix+"inf_far_pull"));
......@@ -3057,12 +3101,14 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"ih_min_samples")!=null) this.ih_min_samples=Integer.parseInt(properties.getProperty(prefix+"ih_min_samples"));
if (properties.getProperty(prefix+"ih_norm_center")!=null) this.ih_norm_center=Boolean.parseBoolean(properties.getProperty(prefix+"ih_norm_center"));
if (properties.getProperty(prefix+"fcorr_sample_size")!=null) this.fcorr_sample_size=Integer.parseInt(properties.getProperty(prefix+"fcorr_sample_size"));
if (properties.getProperty(prefix+"fcorr_mintiles")!=null) this.fcorr_mintiles=Integer.parseInt(properties.getProperty(prefix+"fcorr_mintiles"));
if (properties.getProperty(prefix+"fcorr_reloutliers")!=null) this.fcorr_reloutliers=Double.parseDouble(properties.getProperty(prefix+"fcorr_reloutliers"));
if (properties.getProperty(prefix+"fcorr_sigma")!=null) this.fcorr_sigma=Double.parseDouble(properties.getProperty(prefix+"fcorr_sigma"));
if (properties.getProperty(prefix+"ly_smpl_side")!=null) this.ly_smpl_side=Integer.parseInt(properties.getProperty(prefix+"ly_smpl_side"));
if (properties.getProperty(prefix+"ly_smpl_num")!=null) this.ly_smpl_num=Integer.parseInt(properties.getProperty(prefix+"ly_smpl_num"));
if (properties.getProperty(prefix+"ly_meas_disp")!=null) this.ly_meas_disp=Double.parseDouble(properties.getProperty(prefix+"ly_meas_disp"));
if (properties.getProperty(prefix+"ly_smpl_rms")!=null) this.ly_smpl_rms=Double.parseDouble(properties.getProperty(prefix+"ly_smpl_rms"));
if (properties.getProperty(prefix+"ly_disp_var")!=null) this.ly_disp_var=Double.parseDouble(properties.getProperty(prefix+"ly_disp_var"));
if (properties.getProperty(prefix+"ly_inf_frac")!=null) this.ly_inf_frac=Double.parseDouble(properties.getProperty(prefix+"ly_inf_frac"));
if (properties.getProperty(prefix+"ly_on_scan")!=null) this.ly_on_scan=Boolean.parseBoolean(properties.getProperty(prefix+"ly_on_scan"));
if (properties.getProperty(prefix+"ly_inf_en")!=null) this.ly_inf_en=Boolean.parseBoolean(properties.getProperty(prefix+"ly_inf_en"));
if (properties.getProperty(prefix+"corr_magic_scale")!=null) this.corr_magic_scale=Double.parseDouble(properties.getProperty(prefix+"corr_magic_scale"));
......@@ -3073,6 +3119,10 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"sure_smth")!=null) this.sure_smth=Double.parseDouble(properties.getProperty(prefix+"sure_smth"));
if (properties.getProperty(prefix+"bgnd_range")!=null) this.bgnd_range=Double.parseDouble(properties.getProperty(prefix+"bgnd_range"));
if (properties.getProperty(prefix+"other_range")!=null) this.other_range=Double.parseDouble(properties.getProperty(prefix+"other_range"));
if (properties.getProperty(prefix+"ex_strength")!=null) this.ex_strength=Double.parseDouble(properties.getProperty(prefix+"ex_strength"));
if (properties.getProperty(prefix+"ex_nstrength")!=null) this.ex_nstrength=Double.parseDouble(properties.getProperty(prefix+"ex_nstrength"));
if (properties.getProperty(prefix+"bgnd_sure")!=null) this.bgnd_sure=Double.parseDouble(properties.getProperty(prefix+"bgnd_sure"));
if (properties.getProperty(prefix+"bgnd_maybe")!=null) this.bgnd_maybe=Double.parseDouble(properties.getProperty(prefix+"bgnd_maybe"));
if (properties.getProperty(prefix+"min_clstr_seed")!=null) this.min_clstr_seed=Integer.parseInt(properties.getProperty(prefix+"min_clstr_seed"));
......@@ -3090,6 +3140,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"ortho_min_hor")!=null) this.ortho_min_hor=Double.parseDouble(properties.getProperty(prefix+"ortho_min_hor"));
if (properties.getProperty(prefix+"ortho_min_vert")!=null) this.ortho_min_vert=Double.parseDouble(properties.getProperty(prefix+"ortho_min_vert"));
if (properties.getProperty(prefix+"ortho_asym")!=null) this.ortho_asym=Double.parseDouble(properties.getProperty(prefix+"ortho_asym"));
if (properties.getProperty(prefix+"ortho_over4")!=null) this.ortho_over4=Double.parseDouble(properties.getProperty(prefix+"ortho_over4"));
if (properties.getProperty(prefix+"ortho_sustain")!=null) this.ortho_sustain=Double.parseDouble(properties.getProperty(prefix+"ortho_sustain"));
if (properties.getProperty(prefix+"ortho_run")!=null) this.ortho_run=Integer.parseInt(properties.getProperty(prefix+"ortho_run"));
if (properties.getProperty(prefix+"ortho_minmax")!=null) this.ortho_minmax=Double.parseDouble(properties.getProperty(prefix+"ortho_minmax"));
......@@ -3196,6 +3247,9 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"grow_disp_trust")!=null) this.grow_disp_trust=Double.parseDouble(properties.getProperty(prefix+"grow_disp_trust"));
if (properties.getProperty(prefix+"grow_disp_step")!=null) this.grow_disp_step=Double.parseDouble(properties.getProperty(prefix+"grow_disp_step"));
if (properties.getProperty(prefix+"grow_min_diff")!=null) this.grow_min_diff=Double.parseDouble(properties.getProperty(prefix+"grow_min_diff"));
if (properties.getProperty(prefix+"grow_retry_far")!=null) this.grow_retry_far=Boolean.parseBoolean(properties.getProperty(prefix+"grow_retry_far"));
if (properties.getProperty(prefix+"grow_pedantic")!=null) this.grow_pedantic=Boolean.parseBoolean(properties.getProperty(prefix+"grow_pedantic"));
if (properties.getProperty(prefix+"grow_retry_inf")!=null) this.grow_retry_inf=Boolean.parseBoolean(properties.getProperty(prefix+"grow_retry_inf"));
if (properties.getProperty(prefix+"plPreferDisparity")!=null) this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
if (properties.getProperty(prefix+"plDispNorm")!=null) this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm"));
......@@ -3426,6 +3480,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"show_unique")!=null) this.show_unique=Boolean.parseBoolean(properties.getProperty(prefix+"show_unique"));
if (properties.getProperty(prefix+"show_init_refine")!=null) this.show_init_refine=Boolean.parseBoolean(properties.getProperty(prefix+"show_init_refine"));
if (properties.getProperty(prefix+"show_expand")!=null) this.show_expand=Boolean.parseBoolean(properties.getProperty(prefix+"show_expand"));
if (properties.getProperty(prefix+"show_retry_far")!=null) this.show_retry_far=Boolean.parseBoolean(properties.getProperty(prefix+"show_retry_far"));
if (properties.getProperty(prefix+"show_shells")!=null) this.show_shells=Boolean.parseBoolean(properties.getProperty(prefix+"show_shells"));
if (properties.getProperty(prefix+"show_neighbors")!=null) this.show_neighbors=Boolean.parseBoolean(properties.getProperty(prefix+"show_neighbors"));
if (properties.getProperty(prefix+"show_flaps_dirs")!=null) this.show_flaps_dirs=Boolean.parseBoolean(properties.getProperty(prefix+"show_flaps_dirs"));
......@@ -3516,6 +3571,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Alpha channel 1.0 threshold (higher - opaque)", this.alpha1, 3);
gd.addCheckbox ("Generate shifted channel linear RGB stacks", this.gen_chn_stacks);
gd.addCheckbox ("Generate shifted channel color image stack", this.gen_chn_img);
gd.addCheckbox ("Generate shifted channel images and save with the model 'CLT process corr'",this.gen_4_img);
gd.addCheckbox ("Show result RGBA before overlap combined", this.show_nonoverlap);
gd.addCheckbox ("Show result RGBA", this.show_overlap);
gd.addCheckbox ("Show result color", this.show_rgba_color);
......@@ -3525,6 +3581,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Disparity scan number of disparity values to scan", this.disp_scan_count, 0);
gd.addMessage("--- camera fine correction: X/Y for images 0..3 ---");
gd.addCheckbox ("Debug infinity/lazy eye correction", this.fine_dbg);
gd.addNumericField("X 0", this.fine_corr_x_0, 3);
gd.addNumericField("Y 0", this.fine_corr_y_0, 3);
gd.addNumericField("X 1", this.fine_corr_x_1, 3);
......@@ -3546,7 +3603,10 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Apply disparity correction to zero at infinity", this.inf_disp_apply);
gd.addCheckbox ("Apply lazy eye correction at infinity", this.inf_mism_apply);
gd.addNumericField("Re run disparity correction at infinity multiple times", this.inf_repeat, 0);
// gd.addCheckbox ("Apply lazy eye correction at infinity", this.inf_mism_apply);
gd.addNumericField("Infinity extraction - maximum iterations", this.inf_iters, 0);
gd.addNumericField("Coefficients maximal increment to exit iterations", this.inf_final_diff, 6);
gd.addNumericField("Include farther tiles than tolerance, but scale their weights", this.inf_far_pull, 3);
......@@ -3565,10 +3625,20 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Minimal number of remaining samples", this.ih_min_samples, 0);
gd.addCheckbox ("Replace samples with a single average with equal weight", this.ih_norm_center);
gd.addNumericField("Use square this size side to detect outliers", this.fcorr_sample_size, 0);
gd.addNumericField("Keep tiles only if there are more in each square", this.fcorr_mintiles, 0);
gd.addNumericField("Remove this fraction of tiles from each sample", this.fcorr_reloutliers, 3);
gd.addNumericField("Gaussian blur channel mismatch data", this.fcorr_sigma, 3);
gd.addMessage ("--- Lazy eye parameters (disparity @ infinity should be adjusted first ---");
gd.addNumericField("Sample size (side of a square)", this.ly_smpl_side, 0);
gd.addNumericField("Number after removing worst (should be >1)", this.ly_smpl_num, 0);
gd.addNumericField("Maximal measured relative disparity", this.ly_meas_disp, 3);
gd.addNumericField("Maximal RMS of the remaining tiles in a sample", this.ly_smpl_rms, 3);
gd.addNumericField("Maximal full disparity difference to 8 neighbors", this.ly_disp_var, 3);
gd.addNumericField("Relative weight of infinity calibration data", this.ly_inf_frac, 3);
gd.addCheckbox ("Calculate and apply lazy eye correction after disparity scan (need to repeat)",this.ly_on_scan);
gd.addCheckbox ("Use infinity disparity (disable if there is not enough of infinity data)", this.ly_inf_en);
gd.addMessage ("---");
// gd.addNumericField("Use square this size side to detect outliers", this.fcorr_sample_size, 0);
// gd.addNumericField("Keep tiles only if there are more in each square", this.fcorr_mintiles, 0);
// gd.addNumericField("Remove this fraction of tiles from each sample", this.fcorr_reloutliers, 3);
// gd.addNumericField("Gaussian blur channel mismatch data", this.fcorr_sigma, 3);
gd.addNumericField("Calculated from correlation offset vs. actual one (not yet understood)", this.corr_magic_scale, 3);
......@@ -3580,6 +3650,10 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Reliable noise-normalized pixel difference in a channel to have something ", this.sure_smth, 3);
gd.addNumericField("Disparity range to be considered background", this.bgnd_range, 3);
gd.addNumericField("Disparity difference from the center (provided) disparity to trust", this.other_range, 3);
gd.addNumericField("Minimal 4-corr strength to trust tile", this.ex_strength, 3);
gd.addNumericField("Minimal 4-corr strength divided by channel diff for new (border) tiles", this.ex_nstrength, 3);
gd.addNumericField("Minimal strength to be considered definitely background", this.bgnd_sure, 3);
gd.addNumericField("Maximal strength to ignore as non-background", this.bgnd_maybe, 3);
......@@ -3598,6 +3672,7 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Minimal strength of hor correlation to be used instead of full 4-pair correlation", this.ortho_min_hor, 3);
gd.addNumericField("Minimal strength of vert correlation to be used instead of full 4-pair correlation", this.ortho_min_vert, 3);
gd.addNumericField("Vert/hor (or hor/vert) strength to be used instead of the full correlation", this.ortho_asym, 3);
gd.addNumericField("Vert/hor (or hor/vert) strength exceeding scaled 4-pair strength", this.ortho_over4, 3);
gd.addNumericField("Minimal strength of hor/vert to bridge over", this.ortho_sustain, 3);
gd.addNumericField("minimal run of hor/vert tiles to be considered (at least from one side)", this.ortho_run, 0);
......@@ -3671,9 +3746,9 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Show supertiles histograms", this.stShow);
gd.addNumericField("Super tile size (square, in tiles)", this.stSize, 0);
gd.addNumericField("Disaprity histogram step for far objects", this.stStepFar, 6);
gd.addNumericField("Disaprity histogram step for near objects", this.stStepNear, 6);
gd.addNumericField("Disaprity threshold to switch cfrom linear to logarithmic steps", this.stStepThreshold, 6);
gd.addNumericField("Disparity histogram step for far objects", this.stStepFar, 6);
gd.addNumericField("Disparity histogram step for near objects", this.stStepNear, 6);
gd.addNumericField("Disparity threshold to switch from linear to logarithmic steps", this.stStepThreshold, 6);
gd.addNumericField("Minimal disparity (center of a bin)", this.stMinDisparity, 6);
gd.addNumericField("Maximal disparity (center of a bin)", this.stMaxDisparity, 6);
gd.addNumericField("Subtract from strength, discard negative", this.stFloor, 6);
......@@ -3711,6 +3786,10 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Trust measured disparity within +/- this value", this.grow_disp_trust, 6);
gd.addNumericField("Increase disparity (from maximal tried) if nothing found in that tile", this.grow_disp_step, 6);
gd.addNumericField("Grow more only if at least one channel has higher variance from others for the tile", this.grow_min_diff, 6);
gd.addCheckbox ("Retry tiles around known foreground that have low max_tried_disparity", this.grow_retry_far);
gd.addCheckbox ("Scan full range between max_tried_disparity of the background and known foreground", this.grow_pedantic);
gd.addCheckbox ("Retry border tiles that were identified as infinity earlier", this.grow_retry_inf);
gd.addMessage ("--- Planes detection ---");
gd.addCheckbox ("Always start with disparity-most axis (false - lowest eigenvalue)", this.plPreferDisparity);
gd.addNumericField("Normalize disparities to the average if above", this.plDispNorm, 6);
......@@ -3949,6 +4028,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Show 'unique_scan' (removed already measured tiles with the same disparity)", this.show_unique);
gd.addCheckbox ("Show debug images during initial refinement", this.show_init_refine);
gd.addCheckbox ("Show debug images during disparity expansion", this.show_expand);
gd.addCheckbox ("Show debug images related to retrying far tiles near foreground", this.show_retry_far);
gd.addCheckbox ("Show 'shells'", this.show_shells);
gd.addCheckbox ("show 'neighbors'", this.show_neighbors);
gd.addCheckbox ("Show 'flaps-dirs'", this.show_flaps_dirs);
......@@ -4031,6 +4111,7 @@ public class EyesisCorrectionParameters {
this.alpha1= gd.getNextNumber();
this.gen_chn_stacks= gd.getNextBoolean();
this.gen_chn_img= gd.getNextBoolean();
this.gen_4_img= gd.getNextBoolean();
this.show_nonoverlap= gd.getNextBoolean();
this.show_overlap= gd.getNextBoolean();
this.show_rgba_color= gd.getNextBoolean();
......@@ -4039,6 +4120,7 @@ public class EyesisCorrectionParameters {
this.disp_scan_step= gd.getNextNumber();
this.disp_scan_count= (int) gd.getNextNumber();
this.fine_dbg= gd.getNextBoolean();
this.fine_corr_x_0= gd.getNextNumber();
this.fine_corr_y_0= gd.getNextNumber();
this.fine_corr_x_1= gd.getNextNumber();
......@@ -4059,7 +4141,8 @@ public class EyesisCorrectionParameters {
this.fcorr_inf_vert= gd.getNextBoolean();
this.inf_disp_apply= gd.getNextBoolean();
this.inf_mism_apply= gd.getNextBoolean();
this.inf_repeat= (int) gd.getNextNumber();
// this.inf_mism_apply= gd.getNextBoolean();
this.inf_iters= (int) gd.getNextNumber();
this.inf_final_diff= gd.getNextNumber();
this.inf_far_pull= gd.getNextNumber();
......@@ -4078,10 +4161,19 @@ public class EyesisCorrectionParameters {
this.ih_min_samples= (int) gd.getNextNumber();
this.ih_norm_center= gd.getNextBoolean();
this.fcorr_sample_size= (int)gd.getNextNumber();
this.fcorr_mintiles= (int) gd.getNextNumber();
this.fcorr_reloutliers= gd.getNextNumber();
this.fcorr_sigma= gd.getNextNumber();
this.ly_smpl_side= (int) gd.getNextNumber();
this.ly_smpl_num= (int) gd.getNextNumber();
this.ly_meas_disp= gd.getNextNumber();
this.ly_smpl_rms= gd.getNextNumber();
this.ly_disp_var= gd.getNextNumber();
this.ly_inf_frac= gd.getNextNumber();
this.ly_on_scan= gd.getNextBoolean();
this.ly_inf_en= gd.getNextBoolean();
// this.fcorr_sample_size= (int)gd.getNextNumber();
// this.fcorr_mintiles= (int) gd.getNextNumber();
// this.fcorr_reloutliers= gd.getNextNumber();
// this.fcorr_sigma= gd.getNextNumber();
this.corr_magic_scale= gd.getNextNumber();
......@@ -4091,6 +4183,10 @@ public class EyesisCorrectionParameters {
this.sure_smth= gd.getNextNumber();
this.bgnd_range= gd.getNextNumber();
this.other_range= gd.getNextNumber();
this.ex_strength= gd.getNextNumber();
this.ex_nstrength= gd.getNextNumber();
this.bgnd_sure= gd.getNextNumber();
this.bgnd_maybe= gd.getNextNumber();
this.min_clstr_seed= (int) gd.getNextNumber();
......@@ -4107,6 +4203,7 @@ public class EyesisCorrectionParameters {
this.ortho_min_hor= gd.getNextNumber();
this.ortho_min_vert= gd.getNextNumber();
this.ortho_asym= gd.getNextNumber();
this.ortho_over4= gd.getNextNumber();
this.ortho_sustain= gd.getNextNumber();
this.ortho_run= (int) gd.getNextNumber();
......@@ -4215,6 +4312,9 @@ public class EyesisCorrectionParameters {
this.grow_disp_trust= gd.getNextNumber();
this.grow_disp_step= gd.getNextNumber();
this.grow_min_diff= gd.getNextNumber();
this.grow_retry_far= gd.getNextBoolean();
this.grow_pedantic= gd.getNextBoolean();
this.grow_retry_inf= gd.getNextBoolean();
this.plPreferDisparity= gd.getNextBoolean();
this.plDispNorm= gd.getNextNumber();
......@@ -4446,6 +4546,7 @@ public class EyesisCorrectionParameters {
this.show_unique= gd.getNextBoolean();
this.show_init_refine= gd.getNextBoolean();
this.show_expand= gd.getNextBoolean();
this.show_retry_far= gd.getNextBoolean();
this.show_shells= gd.getNextBoolean();
this.show_neighbors= gd.getNextBoolean();
this.show_flaps_dirs= gd.getNextBoolean();
......
......@@ -4548,7 +4548,9 @@ private Panel panel1,
}
///========================================
int num_infinity_corr = infinity_corr? CLT_PARAMETERS.inf_repeat : 1;
if ( num_infinity_corr < 1) num_infinity_corr = 1;
for (int i_infinity_corr = 0; i_infinity_corr < num_infinity_corr; i_infinity_corr++) {
QUAD_CLT.processCLTQuadCorrs(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
......@@ -4563,7 +4565,7 @@ private Panel panel1,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
}
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
......@@ -4609,20 +4611,15 @@ private Panel panel1,
System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
}
}
/*
QUAD_CLT.process_fine_corr(
dry_run, // boolean dry_run
CLT_PARAMETERS,
DEBUG_LEVEL);
*/
QUAD_CLT.processLazyEye(
dry_run, // boolean dry_run
CLT_PARAMETERS,
DEBUG_LEVEL);
return;
} else if (label.equals("CLT ext infinity corr")) {
// boolean dry_run = label.equals("CLT test fine corr");
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
......
......@@ -3224,7 +3224,7 @@ public class QuadCLT {
texture_tiles[i][j] = null;
}
}
if (clt_parameters.corr_keep){
if (!infinity_corr && clt_parameters.corr_keep){
clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
......@@ -3328,7 +3328,7 @@ public class QuadCLT {
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
}
if (clt_parameters.show_overlap || clt_parameters.show_rgba_color){
if (!infinity_corr && (clt_parameters.show_overlap || clt_parameters.show_rgba_color)){
int alpha_index = 3;
texture_overlap = image_dtt.combineRGBATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
......@@ -3383,7 +3383,7 @@ public class QuadCLT {
// visualize correlation results
if (clt_corr_combo!=null){
if (disparity_map != null){
if (clt_parameters.show_map){
if (!infinity_corr && clt_parameters.show_map){
sdfa_instance.showArrays(
disparity_map,
tilesX,
......@@ -3394,33 +3394,9 @@ public class QuadCLT {
}
}
if (clt_mismatch != null){
if (debugLevel > -1){
String [] disparity_titles = {"dx0", "dy0","strength0","dx1", "dy1","strength1","dx2", "dy2","strength2","dx3", "dy3","strength3"};
sdfa_instance.showArrays(
clt_mismatch,
tilesX,
tilesY,
true,
name+"-MISMATCH_XYW-D"+clt_parameters.disparity,
disparity_titles);
}
if (apply_corr && (disparity_map != null)){
System.out.println("=== applying geometry correction coefficients ===");
double [][][] new_corr = fine_geometry_correction(
clt_parameters,
disparity_map,
clt_mismatch,
tilesX,
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
debugLevel); // int debugLevel)
apply_fine_corr(
new_corr,
debugLevel + 1);
}
}
if (infinity_corr && (disparity_map != null)){
System.out.println("=== applying geometry correction coefficients to correct disparity at infinity ===");
System.out.println("=== Set inf_repeat =0 to disable automatic correction and just generate a data image to correct in offline mode ===");
double [][] inf_ds = {
disparity_map[ImageDtt.DISPARITY_INDEX_CM],
disparity_map[ ImageDtt.DISPARITY_STRENGTH_INDEX]};
......@@ -3441,7 +3417,9 @@ public class QuadCLT {
inf_ds = inf_ds1;
titles = titles1;
}
if (clt_parameters.inf_repeat <1) {
System.out.println("=== Generating image to be saved and then used for correction with 'CLT ext infinity corr'===");
// This image can be saved and re-read with "CLT ext infinity corr" command
if (sdfa_instance != null){
sdfa_instance.showArrays(
inf_ds,
......@@ -3451,39 +3429,68 @@ public class QuadCLT {
name + "-inf_corr",
titles );
}
} else { // calculate/apply coefficients
if (debugLevel + (clt_parameters.fine_dbg ? 1:0) > 0){
// still show image, even as it is not needed
if (sdfa_instance != null){
sdfa_instance.showArrays(
inf_ds,
tilesX,
tilesY,
true,
name + "-inf_corr",
titles );
}
}
if (debugLevel > 100) {
double [][][] new_corr = infinityCorrection(
AlignmentCorrection ac = new AlignmentCorrection(this);
// includes both infinity correction and mismatch correction for the same infinity tiles
double [][][] new_corr = ac.infinityCorrection(
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff,
20, // 0, // final int max_iterations,
0.0001, // final double max_coeff_diff,
clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
inf_ds, // double [][] disp_strength,
tilesX, // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel + 1); // int debugLevel)
debugLevel + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
if (debugLevel > -1){
System.out.println("Ready to apply infinity correction");
System.out.println("process_infinity_corr(): ready to apply infinity correction");
show_fine_corr(
new_corr, // double [][][] corr,
"");// String prefix)
}
if (clt_parameters.inf_disp_apply){
apply_fine_corr(
new_corr,
debugLevel + 2);
}
apply_fine_corr(
new_corr,
debugLevel + 1);
}
}
if (clt_parameters.corr_show){
if (!infinity_corr && clt_parameters.corr_show){
double [][] corr_rslt = new double [clt_corr_combo.length][];
String [] titles = new String[clt_corr_combo.length]; // {"combo","sum"};
for (int i = 0; i< titles.length; i++) titles[i] = ImageDtt.TCORR_TITLES[i];
......@@ -3505,7 +3512,7 @@ public class QuadCLT {
titles );
}
if (clt_corr_partial!=null){
if (!infinity_corr && (clt_corr_partial!=null)){
if (debugLevel > -1){ // -1
String [] allColorNames = {"red","blue","green","combo"};
String [] titles = new String[clt_corr_partial.length];
......@@ -3531,7 +3538,7 @@ public class QuadCLT {
}
}
if (clt_parameters.gen_chn_img || clt_parameters.gen_chn_stacks) {
if (!infinity_corr && (clt_parameters.gen_chn_img || clt_parameters.gen_4_img || clt_parameters.gen_chn_stacks)) {
ImagePlus [] imps_RGB = new ImagePlus[clt_data.length];
for (int iQuad = 0; iQuad < clt_data.length; iQuad++){
......@@ -3630,6 +3637,20 @@ public class QuadCLT {
//imp_stack.show();
eyesisCorrections.saveAndShow(imp_stack, this.correctionsParameters);
}
if (clt_parameters.gen_4_img) {
// Save as individual JPEG images in the model directory
String x3d_path= correctionsParameters.selectX3dDirectory(
true, // smart,
true); //newAllowed, // save
for (int sub_img = 0; sub_img < 4; sub_img++){
eyesisCorrections.saveAndShow(
imps_RGB[sub_img],
x3d_path,
correctionsParameters.png && !clt_parameters.black_back,
clt_parameters.show_textures,
correctionsParameters.JPEG_quality); // jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
}
}
}
return results;
}
......@@ -3843,8 +3864,8 @@ public class QuadCLT {
}
public double [][][] fine_geometry_correction(
/*
public double [][][] fine_geometry_correction_old(
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] disparity_map,
double [][] clt_mismatch,
......@@ -3893,7 +3914,7 @@ public class QuadCLT {
* or 3-element - (D,E,F) if linear is possible and quadratic is not possible or disabled
* returns null if not enough data even for the linear approximation
*/
/*
double [][] coeffs = pa.quadraticApproximation(
mdata,
!clt_parameters.fcorr_quadratic, // boolean forceLinear, // use linear approximation
......@@ -3993,7 +4014,7 @@ public class QuadCLT {
// new one, pre-calculated from the disparity scan
public double [][][] fine_geometry_correction(
public double [][][] fine_geometry_correction_old(
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] clt_mismatch,
int tilesX,
......@@ -4042,13 +4063,14 @@ public class QuadCLT {
PolynomialApproximation pa = new PolynomialApproximation();
double thresholdLin = 1.0E-20; // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
double thresholdQuad = 1.0E-30; // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
*/
/*
* returns array of vectors or null
* each vector (one per each z component) is either 6-element- (A,B,C,D,E,F) if quadratic is possible and enabled
* or 3-element - (D,E,F) if linear is possible and quadratic is not possible or disabled
* returns null if not enough data even for the linear approximation
*/
/*
double [][] coeffs = pa.quadraticApproximation(
mdata,
......@@ -4145,7 +4167,7 @@ public class QuadCLT {
}
return coeff_full;
}
*/
/**
* Calculate quadratic polynomials for each subcamera X/Y correction to match disparity = 0 at infinity
* Next parameters are made separate to be able to modify them between different runs keeping clt_parameters
......@@ -4901,26 +4923,86 @@ public class QuadCLT {
}
}
if (debugLevel > -1) {
showCltMismatches(
"clt_mismatches", // String title,
if (clt_mismatches != null) { // now always
AlignmentCorrection ac = new AlignmentCorrection(this);
double [][] scans = ac.combineCltMismatches(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_mismatches, // double [][][] clt_mismatches)
disparity_maps,// double [][][] disparities,
ImageDtt.DISPARITY_INDEX_CM,
ImageDtt.DISPARITY_STRENGTH_INDEX,
clt_mismatches, // double [][][] clt_mismatches,
disparity_maps, // double [][][] disparity_maps,
ImageDtt.DISPARITY_INDEX_CM, // int disparity_index,
ImageDtt.DISPARITY_STRENGTH_INDEX); // int strength_index)
if (clt_parameters.fine_dbg) {
ac.showCltMismatches(
"clt_mismatches", // String title,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scans, // double [][] combo_data,
tp.getTilesX(),
tp.getTilesY());
showCltMismatch(
if (debugLevel > 1) {
ac.showCltMismatch(
"clt_mismatch", // String title,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_mismatch, // double [][][] clt_mismatch)
tp.getTilesX(),
tp.getTilesY());
}
}
// TODO: Add automatic run of the lazy eye here
if (true) {
System.out.println("=== Calcualting eye correction ===");
// final int nTiles =tilesX * tilesY;
double [][] disp_strength = ac.getFineCorrFromDoubleArray(
scans, // double [][] data,
tilesX, // int tilesX,
debugLevel); // int debugLevel)
double [][][] new_corr = ac.lazyEyeCorrection(
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff,
// 1.3, // final double comp_strength_var,
clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
clt_parameters.ly_meas_disp, // 1.5, // final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
clt_parameters.ly_smpl_side, // 3, // final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
clt_parameters.ly_smpl_num, // 5, // final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.ly_smpl_rms, // 0.1, // final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.ly_disp_var, // 0.2, // final double lazyEyeDispVariation, // 0.2, maximal full disparity difference between tgh tile and 8 neighborxs
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
clt_parameters.ly_inf_frac, // 0.5, // final double inf_fraction, // fraction of the weight for the infinity tiles
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
disp_strength, // scans, // double [][] disp_strength,
tilesX, // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
if (clt_parameters.ly_on_scan) {
if (debugLevel > -1){
System.out.println("=== Applying lazy eye correction === ");
}
apply_fine_corr(
new_corr,
debugLevel + 2);
} else {
if (debugLevel > -1){
System.out.println("=== SKIPPING application of the lazy eye correction because \"ly_on_scan\" is not set=== ");
}
}
}
}
int [] disp_indices = {
ImageDtt.DISPARITY_INDEX_INT,
ImageDtt.DISPARITY_INDEX_CM,
......@@ -4930,7 +5012,7 @@ public class QuadCLT {
String [] disparity_titles = new String [disp_indices.length];
for (int i = 0; i < disparity_titles.length; i++ ) disparity_titles[i] = ImageDtt.DISPARITY_TITLES[i];
// 2,4,6,7};
// 2,4,6,7};
String [] disparities_titles = new String [disparity_titles.length * clt_parameters.disp_scan_count];
double [][] disparities_maps = new double [disparity_titles.length * clt_parameters.disp_scan_count][];
int indx = 0;
......@@ -4943,6 +5025,7 @@ public class QuadCLT {
}
}
if (!clt_parameters.ly_on_scan) { // do not show if scan ran for the lazy eye correction
ImageStack array_stack = sdfa_instance.makeStack(
disparities_maps,
tilesX,
......@@ -4955,7 +5038,7 @@ public class QuadCLT {
//imp_stack.getProcessor().resetMinAndMax();
//imp_stack.show();
eyesisCorrections.saveAndShow(imp_stack, this.correctionsParameters);
// process scan results
// process scan results
double [][] scan_trends = process_disparity_scan(
disparities_maps,
clt_parameters.disp_scan_step,
......@@ -4972,49 +5055,62 @@ public class QuadCLT {
imp_stack_trends.getProcessor().resetMinAndMax();
imp_stack_trends.updateAndDraw();
eyesisCorrections.saveAndShow(imp_stack_trends, this.correctionsParameters);
}
return results;
}
public void showCltMismatches(
String title,
/* public double [][] combineCltMismatches(
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][][] clt_mismatches,
double [][][] disparity_maps,
int disparity_index,
int strength_index,
int strength_index)
{
int n = clt_mismatches.length;
double [][] combo = new double [clt_parameters.disp_scan_count * AlignmentCorrection.NUM_ALL_SLICES][];
for (int pair = 0; pair < 4; pair++){
for (int i = 0; i < n; i++){
combo[(2 * pair + 0) * n + i] = clt_mismatches[i][3 * pair + 0];
combo[(2 * pair + 1) * n + i] = clt_mismatches[i][3 * pair + 1];
combo[(2 * 4 + pair) * n + i] = clt_mismatches[i][3 * pair + 2];
}
}
for (int i = 0; i < n; i++){
combo[12 * n + i] = disparity_maps[i][disparity_index];
combo[13 * n + i] = disparity_maps[i][strength_index];
}
return combo;
}
public void showCltMismatches(
String title,
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] combo_data,
int tilesX,
int tilesY)
{
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
int n = clt_mismatches.length;
String [] titles = new String [n * 14];
double [][] dbg_clt_mismatch= new double [clt_parameters.disp_scan_count * 14][];
String [] titles = new String [combo_data.length];
int num_scans = combo_data.length / AlignmentCorrection.NUM_ALL_SLICES;
for (int pair = 0; pair < 4; pair++){
for (int i = 0; i < n; i++){
for (int i = 0; i < num_scans; i++){
double disparity = clt_parameters.disp_scan_start + i * clt_parameters.disp_scan_step;
titles[(2 * pair + 0) * n + i] = "dx_"+pair+"_"+disparity;
titles[(2 * pair + 1) * n + i] = "dy_"+pair+"_"+disparity;
titles[(2 * 4 + pair) * n + i] = "strength_"+pair+"_"+disparity;
dbg_clt_mismatch[(2 * pair + 0) * n + i] = clt_mismatches[i][3 * pair + 0];
dbg_clt_mismatch[(2 * pair + 1) * n + i] = clt_mismatches[i][3 * pair + 1];
dbg_clt_mismatch[(2 * 4 + pair) * n + i] = clt_mismatches[i][3 * pair + 2];
titles[(2 * pair + 0) * num_scans + i] = "dx_"+pair+"_"+disparity;
titles[(2 * pair + 1) * num_scans + i] = "dy_"+pair+"_"+disparity;
titles[(2 * 4 + pair) * num_scans + i] = "strength_"+pair+"_"+disparity;
}
}
for (int i = 0; i < n; i++){
for (int i = 0; i < num_scans; i++){
double disparity = clt_parameters.disp_scan_start + i * clt_parameters.disp_scan_step;
titles[ 12 * num_scans + i] = "disp_"+disparity;
titles[ 13 * num_scans + i] = "strength_"+disparity;
}
sdfa_instance.showArrays(combo_data, tilesX,tilesY, true, title, titles);
}
titles[ 12 * n + i] = "disp_"+disparity;
titles[ 13 * n + i] = "strength_"+disparity;
dbg_clt_mismatch[12 * n + i] = disparity_maps[i][disparity_index];
dbg_clt_mismatch[13 * n + i] = disparity_maps[i][strength_index];
}
sdfa_instance.showArrays(dbg_clt_mismatch, tilesX,tilesY, true, title, titles);
}
public void showCltMismatch(
String title,
......@@ -5207,7 +5303,7 @@ public class QuadCLT {
}
return combo_mismatch;
}
*/
public void process_infinity_corr(
EyesisCorrectionParameters.CLTParameters clt_parameters,
int debugLevel
......@@ -5279,6 +5375,7 @@ public class QuadCLT {
public void processLazyEye(
boolean dry_run,
EyesisCorrectionParameters.CLTParameters clt_parameters,
int debugLevel
) {
......@@ -5289,28 +5386,39 @@ public class QuadCLT {
}
ImageStack disp_strength_stack= imp_src.getStack();
final int tilesX = disp_strength_stack.getWidth(); // tp.getTilesX();
final int tilesY = disp_strength_stack.getHeight(); // tp.getTilesY();
final int nTiles =tilesX * tilesY;
// final int tilesY = disp_strength_stack.getHeight(); // tp.getTilesY();
// final int nTiles =tilesX * tilesY;
AlignmentCorrection ac = new AlignmentCorrection(this);
double [][] scans = ac.getFineCorrFromImage(
double [][] scans = ac.getDoubleFromImage(
imp_src,
// 0.2, // double min_comp_strength, // 0.2
debugLevel);
// getFineCorrFromImage(
// imp_src,
// debugLevel);
double [][] disp_strength = ac.getFineCorrFromDoubleArray(
scans, // double [][] data,
tilesX, // int tilesX,
debugLevel); // int debugLevel)
double [][][] new_corr = ac.lazyEyeCorrection(
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff,
1.3, // final double comp_strength_var,
// 1.3, // final double comp_strength_var,
clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
1.5, // final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
clt_parameters.inf_smpl_side, // final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
0.1, // final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
0.2, // final double lazyEyeDispVariation, // 0.2, maximal full disparity difference between tgh tile and 8 neighborxs
clt_parameters.ly_meas_disp, // 1.5, // final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
clt_parameters.ly_smpl_side, // 3, // final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
clt_parameters.ly_smpl_num, // 5, // final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.ly_smpl_rms, // 0.1, // final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
clt_parameters.ly_disp_var, // 0.2, // final double lazyEyeDispVariation, // 0.2, maximal full disparity difference between tgh tile and 8 neighborxs
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
......@@ -5323,14 +5431,14 @@ public class QuadCLT {
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
0.5, // final double inf_fraction, // fraction of the weight for the infinity tiles
clt_parameters.ly_inf_frac, // 0.5, // final double inf_fraction, // fraction of the weight for the infinity tiles
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scans, // double [][] disp_strength,
disp_strength, // scans, // double [][] disp_strength,
tilesX, // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel + 1); // int debugLevel)
debugLevel + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
if (debugLevel > -100){
if (!dry_run){
apply_fine_corr(
new_corr,
debugLevel + 2);
......@@ -5340,7 +5448,7 @@ public class QuadCLT {
/*
public void process_fine_corr(
boolean dry_run,
EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -5502,7 +5610,7 @@ public class QuadCLT {
}
*/
public double [][] process_disparity_scan(
......@@ -5897,9 +6005,12 @@ public class QuadCLT {
final boolean updateStatus,
final int debugLevel)
{
final boolean show_init_refine = clt_parameters.show_init_refine;
final boolean show_expand = clt_parameters.show_expand;
final int max_expand = 100; // 30;
final boolean show_init_refine = clt_parameters.show_init_refine;
final boolean show_expand = clt_parameters.show_expand && (max_expand <= 10);
final boolean show_retry_far = clt_parameters.show_retry_far && (max_expand <= 10);
//max_expand
String name = (String) imp_quad[0].getProperty("name");
double [][][] image_data = new double [imp_quad.length][][];
for (int i = 0; i < image_data.length; i++){
......@@ -5981,7 +6092,8 @@ public class QuadCLT {
// disparity range - differences from
clt_parameters.bgnd_range, // double disparity_far,
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
clt_parameters.bgnd_sure, // double this_sure, // minimal strength to be considered definitely background
clt_parameters.ex_strength, // double this_sure, // minimal strength to be considered definitely good
clt_parameters.ex_nstrength, // double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
clt_parameters.bgnd_maybe, // double this_maybe, // maximal strength to ignore as non-background
clt_parameters.sure_smth, // sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
ImageDtt.DISPARITY_INDEX_CM, // index of disparity value in disparity_map == 2 (0,2 or 4)
......@@ -5989,7 +6101,8 @@ public class QuadCLT {
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel); //2);
if (debugLevel > 1)
/// if (debugLevel > 1)
if (debugLevel > -1)
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"before_makeUnique-"+refine_pass);
......@@ -6054,8 +6167,9 @@ public class QuadCLT {
int num_extended = -1;
int [] numLeftRemoved;
// process once more to try combining of processed
boolean last_pass = false;
// for (int num_expand = 0; (num_expand < 4) && (num_extended != 0); num_expand++) {
for (int num_expand = 0; (num_expand < 10) && (num_extended != 0); num_expand++) {
for (int num_expand = 0; num_expand < max_expand; num_expand++) {
// for (int num_expand = 0; (num_expand < 1) && (num_extended != 0); num_expand++) {
refine_pass = tp.clt_3d_passes.size(); // 1
tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
......@@ -6066,7 +6180,8 @@ public class QuadCLT {
// disparity range - differences from
clt_parameters.bgnd_range, // double disparity_far,
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
clt_parameters.bgnd_sure, // double this_sure, // minimal strength to be considered definitely background
clt_parameters.ex_strength, // double this_sure, // minimal strength to be considered definitely good
clt_parameters.ex_nstrength, // double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
clt_parameters.bgnd_maybe, // double this_maybe, // maximal strength to ignore as non-background
clt_parameters.sure_smth, // sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
ImageDtt.DISPARITY_INDEX_CM, // index of disparity value in disparity_map == 2 (0,2 or 4)
......@@ -6075,9 +6190,13 @@ public class QuadCLT {
updateStatus,
debugLevel);
if (show_expand) tp.showScan(
if (show_expand || (clt_parameters.show_expand && last_pass)) {
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_refine-"+refine_pass);
}
tp.calcMaxTried(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
bg_pass, // final int firstPass,
......@@ -6099,8 +6218,7 @@ public class QuadCLT {
false, // final boolean usePoly) // use polynomial method to find max), valid if useCombo == false
true, // final boolean copyDebug)
debugLevel);
if (show_expand) tp.showScan(
if (show_expand || (clt_parameters.show_expand && last_pass)) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_refine-combine-"+(tp.clt_3d_passes.size() - 1));
......@@ -6113,14 +6231,21 @@ public class QuadCLT {
0.5 * clt_parameters.grow_disp_trust, // = 4.0; // Trust measured disparity within +/- this value
clt_parameters.grow_disp_step, // = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips?
clt_parameters.grow_min_diff, // = 0.5; // Grow more only if at least one channel has higher variance from others for the tile
clt_parameters.grow_retry_far, // final boolean grow_retry_far, // Retry tiles around known foreground that have low max_tried_disparity
clt_parameters.grow_pedantic, // final boolean grow_pedantic, // Scan full range between max_tried_disparity of the background and known foreground
clt_parameters.grow_retry_inf, // final boolean grow_retry_inf, // Retry border tiles that were identified as infinity earlier
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
geometryCorrection, // GeometryCorrection geometryCorrection,
show_expand, // true, // final boolean show_debug,
(show_retry_far|| (clt_parameters.show_retry_far && last_pass)), // true, // final boolean show_debug,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
//TODO: break if nothing wanted? - no, there are some left to be refined
if (debugLevel > -1){
System.out.println("=== setupExtendDisparity() pass:"+num_expand+" added "+num_extended+" new tiles to scan");
}
refine_pass = tp.clt_3d_passes.size(); // 1
......@@ -6140,6 +6265,7 @@ public class QuadCLT {
if (debugLevel > -1){
System.out.println("last makeUnique("+refine_pass+") -> left: "+numLeftRemoved[0]+", removed:" + numLeftRemoved[1]);
}
num_extended = numLeftRemoved[0];
//TODO: break if nothing wanted? - here yes, will make sens
......@@ -6152,13 +6278,13 @@ public class QuadCLT {
updateStatus,
debugLevel);
if (show_expand) tp.showScan(
if (show_expand || (clt_parameters.show_expand && last_pass)) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_measure-"+refine_pass); //String title)
if (debugLevel > -1){
System.out.println("extending: CLTMeasure("+refine_pass+")");
System.out.println("extending: CLTMeasure("+refine_pass+"), num_extended = "+num_extended);
}
//num_expand == 9
CLTPass3d combo_pass = tp.compositeScan(
......@@ -6181,9 +6307,14 @@ public class QuadCLT {
tp.clt_3d_passes.add(combo_pass);
// refine_pass = tp.clt_3d_passes.size();
// }
if (show_expand) tp.showScan(
if (show_expand || (clt_parameters.show_expand && last_pass)) tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_combo_pass-"+(refine_pass)); //String title)
if (last_pass) {
break;
} else if (numLeftRemoved[0] == 0){
last_pass = true;
}
}
......@@ -6194,58 +6325,8 @@ public class QuadCLT {
tp.clt_3d_passes.get(tp.clt_3d_passes.size()-1), // CLTPass3d scan,
"after_last_combo_pass-"+(tp.clt_3d_passes.size()-1)); //String title)
// TEMPORARY EXIT
// if (tp.clt_3d_passes.size() > 0) return null; // just to fool compiler
refine_pass = tp.clt_3d_passes.size(); // refinePassSetup() will add one
/*
// Refine after extension
tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
// final double [][][] image_data, // first index - number of image in a quad
clt_parameters,
clt_parameters.stUseRefine, // use supertiles
bg_pass,
// disparity range - differences from
// clt_parameters.bgnd_range, // double disparity_far,
-0.5, // 0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
clt_parameters.bgnd_sure, // double this_sure, // minimal strength to be considered definitely background
clt_parameters.bgnd_maybe, // double this_maybe, // maximal strength to ignore as non-background
clt_parameters.sure_smth, // sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
ImageDtt.DISPARITY_INDEX_CM, // index of disparity value in disparity_map == 2 (0,2 or 4)
geometryCorrection,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel); // 2); // debugLevel);
numLeftRemoved = tp.makeUnique(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
0, // final int firstPass,
refine_pass, // - 1, // final int lastPassPlus1,
tp.clt_3d_passes.get(refine_pass), // final CLTPass3d new_scan,
clt_parameters.unique_tolerance, // final double unique_tolerance,
clt_parameters.show_unique); // final boolean show_unique)
if (debugLevel > -1){
System.out.println("makeUnique("+refine_pass+") -> left: "+numLeftRemoved[0]+", removed:" + numLeftRemoved[1]);
}
tp.showScan(
tp.clt_3d_passes.get(refine_pass-1), // CLTPass3d scan,
"prev_after_last_refine-"+(refine_pass-1)); //String title)
tp.showScan(
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"after_last_refine-"+refine_pass); //String title)
// TEMPORARY EXIT
if (tp.clt_3d_passes.size() > 0) return null; // just to fool compiler
*/
// testing 2-nd pass
// int next_pass = tp.clt_3d_passes.size() + 1; // Now secondPassSetup starts with generating a combo image?
int next_pass = tp.clt_3d_passes.size(); //
tp.secondPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
// final double [][][] image_data, // first index - number of image in a quad
......@@ -6256,7 +6337,8 @@ public class QuadCLT {
clt_parameters.bgnd_range, // double disparity_far,
// -0.5, // 0.0, // clt_parameters.bgnd_range, // final double disp_far, // limit results to the disparity range
clt_parameters.grow_disp_max, // other_range, //double disparity_near, //
clt_parameters.bgnd_sure, // double this_sure, // minimal strength to be considered definitely background
clt_parameters.ex_strength, // double this_sure, // minimal strength to be considered definitely good
clt_parameters.ex_nstrength, // double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
clt_parameters.bgnd_maybe, // double this_maybe, // maximal strength to ignore as non-background
clt_parameters.sure_smth, // sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
ImageDtt.DISPARITY_INDEX_CM, // index of disparity value in disparity_map == 2 (0,2 or 4)
......@@ -6277,7 +6359,7 @@ public class QuadCLT {
return null; // just to fool compiler
}
// ***************** Garbage below ***************?
tp.showScan(
tp.clt_3d_passes.get(next_pass-1), // CLTPass3d scan,
"after_pass2-"+(next_pass-1)); //String title)
......
......@@ -559,7 +559,7 @@ public class SuperTiles{
int numMax = 0;
int lo = 0;
int hi = 1;
if ((globalDebugLevel > -1 ) && (nsTile == 359)) {
if ((globalDebugLevel > -1 ) && (nsTile == 795)) {
System.out.println(nsTile);
}
while (hi < numBins) {
......@@ -567,7 +567,7 @@ public class SuperTiles{
while ((hi < numBins) && (dh[hi] >= dh[hi - 1])) hi++; // flat or higher - continue
if (hi == numBins){ // last
if (dh[hi - 1] == dh[lo]) break; // no maximums till the very end
if (dh[hi - 1] > dh[hi-2]) {// and is higher than previus
if (dh[hi - 1] > dh[hi-2]) {// and is higher than previous
mmm[numMax * 2][0] = hi - 1;
} else { // flat top, but higher than [lo]
int i = hi - 3;
......@@ -616,7 +616,7 @@ public class SuperTiles{
double a = 0.5*(dh[hi] -2*dh[hi-1] + dh[hi-2]);
double b = 0.5*(dh[hi] - dh[hi-2]);
double dx = - b/(2*a);
// protect agains very low a,b
// protect against very low a,b
if (dx > 1.0){
dx = 1.0;
mmm[numMax * 2 - 1][1] = dh[hi];
......@@ -811,6 +811,9 @@ public class SuperTiles{
}
}
for (int nsTile = 0; nsTile < sTiles; nsTile++){
if (nsTile == 795){
System.out.println("showMaxMinMax(), nsTile="+nsTile);
}
int stileY = nsTile / sTilesX;
int stileX = nsTile % sTilesX;
int x0 = stileX * (numBins + 1);
......@@ -834,7 +837,8 @@ public class SuperTiles{
isMin[bin] = false;
}
for (int i = 0; i <maxMinMax[nsTile].length; i++){
int imm = (int) Math.round(maxMinMax[nsTile][i][0]);
// int imm = (int) Math.round(maxMinMax[nsTile][i][0]);
int imm = disparityToBin(maxMinMax[nsTile][i][0]);
if (imm <0 ) imm = 0;
else if (imm >= numBins) imm = numBins - 1;
if ((i & 1) == 0) isMax[imm] = true;
......@@ -1530,10 +1534,14 @@ public class SuperTiles{
final boolean [][][] selected, // tiles OK to be assigned [supertile][measurement layer] [tile index] or null (or null or per-measurement layer)
final boolean [][][] prohibited, // already assigned tiles [supertile][measurement layer] [tile index] or null
final int stMeasSel, // = 1; // Select measurements for supertiles : +1 - combo, +2 - quad +4 - hor +8 - vert
// TODO: Scale max_diff, smallDiff for large disparities
final double max_diff, // maximal disparity difference (to assign to a cluster (of Double.NaN)
final int plMinPoints, // = 5; // Minimal number of points for plane detection
final double smallDiff, // = 0.4; // Consider merging initial planes if disparity difference below
final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
final boolean norm_max_diff, // scale max_diff for large (> dispNorm) average disparities
final boolean norm_small_diff, // scale max_diff for large (> dispNorm) average disparities
final double dispNorm,
final int debugLevel,
final int dbg_X,
final int dbg_Y)
......@@ -1631,7 +1639,13 @@ public class SuperTiles{
double best_d2 = Double.NaN;
for (int np = 0; np < num_p; np++) {
double d2 = max_only[np][0] - disp_strength[ml][0][indx];
// add disp_norm correction here?
// add disp_norm correction here? Yes!
if (norm_max_diff) {
double d_avg = 0.5 * (max_only[np][0] + disp_strength[ml][0][indx]);
if (d_avg > dispNorm){
d2 *= dispNorm / d_avg;
}
}
d2 *= d2;
if (!(d2 >= best_d2)){
best_d2 = d2;
......@@ -1692,7 +1706,7 @@ public class SuperTiles{
double [][] rel_trans = getTransRel(trans_mat);
if (dl > 0) {
if (dl > 1) {
System.out.println("trans_mat = ");
for (int i = 0; i < trans_mat.length; i++){
System.out.print(i+": ");
......@@ -1725,7 +1739,15 @@ public class SuperTiles{
// find candidates for merge
windx = -1;
for (int i = 0; i < (num_p - 1); i++) {
if (((max_only[i+1][0] - max_only[i][0]) < smallDiff) && // close enough to consider merging
double diff_disp = max_only[i+1][0] - max_only[i][0];
if (norm_small_diff) {
double d_avg = 0.5 * (max_only[i+1][0] + max_only[i][0]);
if (d_avg > dispNorm){
diff_disp *= dispNorm / d_avg;
}
}
if ((diff_disp < smallDiff) && // close enough to consider merging
(rel_trans[i][i+1] > highMix)) {
if ((windx < 0) || (rel_trans[i][i+1] > rel_trans[windx][windx+1])) windx = i;
}
......@@ -1840,11 +1862,13 @@ public class SuperTiles{
final double bin_blur_hor, // Blur disparity histograms for horizontal clusters by this sigma (in bins)
final double bin_blur_vert, // Blur disparity histograms for constant disparity clusters by this sigma (in bins)
// TODO: scale down max_diff_hor, max_diff_vert for large disparities?
final double max_diff_hor, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for horizontal planes
final double max_diff_vert, // maximal disparity difference (to assign to a cluster (of Double.NaN) at first run for vertical plane
final int max_tries, // on last run - assign all rfemaining pixels to some cluster (disregard max_diff)
final int max_tries, // on last run - assign all remaining pixels to some cluster (disregard max_diff)
final double smallDiff, // = 0.4; // Consider merging initial planes if disparity difference below
// TODO: scale down smallDiff for large disparities?
final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
final int debugLevel,
......@@ -1981,6 +2005,9 @@ public class SuperTiles{
plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection
smallDiff, // final double smallDiff, // = 0.4; // Consider merging initial planes if disparity difference below
highMix, // final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
true, // final boolean norm_max_diff, // scale max_diff for large (> dispNorm) average disparities
true, // final boolean norm_small_diff, // scale max_diff for large (> dispNorm) average disparities
plDispNorm, // final double dispNorm, // TODO: make a separate variable?
debugLevel, // 1, // debugLevel,
dbg_X,
dbg_Y);
......@@ -1998,6 +2025,9 @@ public class SuperTiles{
plMinPoints, // final int plMinPoints, // = 5; // Minimal number of points for plane detection
smallDiff, // final double smallDiff, // = 0.4; // Consider merging initial planes if disparity difference below
highMix, // final double highMix, //stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
true, // final boolean norm_max_diff, // scale max_diff for large (> dispNorm) average disparities
true, // final boolean norm_small_diff, // scale max_diff for large (> dispNorm) average disparities
plDispNorm, // final double dispNorm, // TODO: make a separate variable?
debugLevel, // 2, // debugLevel,
dbg_X,
dbg_Y);
......@@ -2009,9 +2039,9 @@ public class SuperTiles{
public void run() {
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > -1) && (nsTile == debug_stile)) ? 3 : 0;
int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
if (dl > 0){
// int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
int dl = ((debugLevel > 0) && (nsTile == debug_stile)) ? 3: debugLevel;
if (dl > 2){
System.out.println("initialDiscriminateTiles() selecting: nsTile="+nsTile);
}
double [][][][] ds = {vert_disp_strength[nsTile],hor_disp_strength[nsTile]};
......@@ -2042,7 +2072,7 @@ public class SuperTiles{
selStrengthList.add(new SelStrength(pType, np, sw));
}
}
if (dl > 0){
if (dl > 1){
System.out.println("initialDiscriminateTiles() got list of clusters for "+nsTile);
for (int i = 0; i < selStrengthList.size(); i++){
System.out.println(i+": type = "+selStrengthList.get(i).type+
......@@ -2058,7 +2088,7 @@ public class SuperTiles{
return (lhs.strength > rhs.strength) ? -1 : (lhs.strength < rhs.strength ) ? 1 : 0;
}
});
if (dl > 0){
if (dl > 1){
System.out.println("initialDiscriminateTiles() sorted list of clusters for "+nsTile);
for (int i = 0; i < selStrengthList.size(); i++){
System.out.println(i+": type = "+selStrengthList.get(i).type+
......@@ -2075,7 +2105,7 @@ public class SuperTiles{
}
}
int num_old_planes = (planes_selections[nsTile] == null) ? 0: planes_selections[nsTile].length;
if (dl > 0){
if (dl > 1){
System.out.println("initialDiscriminateTiles() num_old_planes= "+num_old_planes);
}
boolean [][][] new_planes_selections = new boolean [num_old_planes + num_planes][][];
......@@ -2096,7 +2126,7 @@ public class SuperTiles{
}
}
planes_selections[nsTile] = new_planes_selections;
if (dl > 0){
if (dl > 1){
System.out.println("initialDiscriminateTiles() new_planes_selections.length= "+new_planes_selections.length);
}
}
......@@ -2362,7 +2392,7 @@ public class SuperTiles{
for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
// int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
if (dl > 1){
if (dl > 2){
System.out.println("createPlanesFromSelections(): nsTile="+nsTile);
}
if (plane_selections[nsTile] != null) {
......@@ -2470,6 +2500,30 @@ public class SuperTiles{
sdfa_instance.showArrays(dbg_img, 2 * superTileSize, 2* superTileSize, true, "create_planes_disp-"+nsTile+"-"+debugLevel,dbg_titles);
dbg_img = showSupertileSeparation(true, disp_strength[nsTile], plane_selections[nsTile], result_planes[nsTile]);
sdfa_instance.showArrays(dbg_img, 2 * superTileSize, 2* superTileSize, true, "create_planes_world-"+nsTile+"-"+debugLevel,dbg_titles);
System.out.println("createPlanesFromSelections(): disp_strength["+nsTile+"][0][0]:");
for (int iy = 0; iy < 2 * superTileSize; iy++){
for (int ix = 0; ix < 2 * superTileSize; ix++){
System.out.print(disp_strength[nsTile][0][0][2 * superTileSize * iy + ix]);
if (ix < (2 * superTileSize-1)){
System.out.print(", ");
} else {
System.out.println();
}
}
}
System.out.println("createPlanesFromSelections(): disp_strength["+nsTile+"][0][1]:");
for (int iy = 0; iy < 2 * superTileSize; iy++){
for (int ix = 0; ix < 2 * superTileSize; ix++){
System.out.print(disp_strength[nsTile][0][1][2 * superTileSize * iy + ix]);
if (ix < (2 * superTileSize - 1)){
System.out.print(", ");
} else {
System.out.println();
}
}
}
System.out.println();
}
}
}
......@@ -2544,7 +2598,7 @@ public class SuperTiles{
smallDiff, // final double smallDiff, // = 0.4; // Consider merging initial planes if disparity difference below
highMix, //final double highMix, // stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
world_hor, // final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
debugLevel, // final int debugLevel,
debugLevel+1, // final int debugLevel,
dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y)
......@@ -2586,7 +2640,7 @@ public class SuperTiles{
smplNum, // final int smplNum, // = 3; // Number after removing worst
smplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
debugLevel, // + 2, // 1, // final int debugLevel,
debugLevel + 2, // + 2, // 1, // final int debugLevel,
dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y)
this.planes = new_planes; // save as "measured" (as opposed to "smoothed" by neighbors) planes
......
......@@ -104,6 +104,53 @@ public class TileNeibs{
default: return indx;
}
}
/**
* Get 2d element index after step N, NE, ... NW. Returns -1 if leaving array
* And 2 steps for dir = 8(N), 9(NNE),..23(NNW)
* @param indx start index
* @param dir step direction (CW from up)
* @return new index or -1 if leaving
*/
int getNeibIndex2(int indx, int dir)
{
int y = indx / sizeX;
int x = indx % sizeX;
if (dir < 0) return indx;
if (dir > 24) {
System.out.println("getNeibIndex(): indx="+indx+", dir="+dir);
}
// switch (dir % dirs){
switch (dir){
case 0: return (y == 0) ? -1 : (indx - sizeX);
case 1: return ((y == 0) || ( x == (sizeX - 1))) ? -1 : (indx - sizeX + 1);
case 2: return ( ( x == (sizeX - 1))) ? -1 : (indx + 1);
case 3: return ((y == (sizeY - 1)) || ( x == (sizeX - 1))) ? -1 : (indx + sizeX + 1);
case 4: return ((y == (sizeY - 1)) ) ? -1 : (indx + sizeX);
case 5: return ((y == (sizeY - 1)) || ( x == 0)) ? -1 : (indx + sizeX - 1);
case 6: return ( ( x == 0)) ? -1 : (indx - 1);
case 7: return ((y == 0) || ( x == 0)) ? -1 : (indx - sizeX - 1);
case 8: return ( y < 2) ? -1 : (indx - 2 * sizeX);
case 9: return ((y < 2) || ( x > (sizeX - 2))) ? -1 : (indx - 2 * sizeX + 1);
case 10: return ((y < 2) || ( x > (sizeX - 3))) ? -1 : (indx - 2 * sizeX + 2);
case 11: return ((y < 1) || ( x > (sizeX - 3))) ? -1 : (indx - 1 * sizeX + 2);
case 12: return ( ( x > (sizeX - 3))) ? -1 : (indx + 2);
case 13: return ((y > (sizeY - 2)) || ( x > (sizeX - 3))) ? -1 : (indx + 1 * sizeX + 2);
case 14: return ((y > (sizeY - 3)) || ( x > (sizeX - 3))) ? -1 : (indx + 2 * sizeX + 2);
case 15: return ((y > (sizeY - 3)) || ( x > (sizeX - 2))) ? -1 : (indx + 2 * sizeX + 1);
case 16: return ((y > (sizeY - 3)) ) ? -1 : (indx + 2 * sizeX);
case 17: return ((y > (sizeY - 3)) || ( x < 1)) ? -1 : (indx + 2 * sizeX - 1);
case 18: return ((y > (sizeY - 3)) || ( x < 2)) ? -1 : (indx + 2 * sizeX - 2);
case 19: return ((y > (sizeY - 2)) || ( x < 2)) ? -1 : (indx + 1 * sizeX - 2);
case 20: return ( ( x < 2)) ? -1 : (indx - 2);
case 21: return ((y < 1) || ( x < 2)) ? -1 : (indx - 1 * sizeX - 2);
case 22: return ((y < 2) || ( x < 2)) ? -1 : (indx - 2 * sizeX - 2);
case 23: return ((y < 2) || ( x < 1)) ? -1 : (indx - 2 * sizeX - 1);
default: return indx;
}
}
/**
* Return tile segment for 50% overlap. -1 - center, 0 N, 1 - NE,... 7 - NW
......
......@@ -1383,10 +1383,10 @@ public class TilePlanes {
swx /= sw;
swy /= sw;
double kz = ((dispNorm > 0.0) && (swz > dispNorm)) ? (dispNorm / swz) : 1.0;
// double kz = ((dispNorm > 0.0) && (swz > dispNorm)) ? (dispNorm / swz) : 1.0;
if (debugLevel > 0){
System.out.println("getPlaneFromMeas(): num_tiles="+num_tiles+", sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy+", kz="+kz);
System.out.println("getPlaneFromMeas(): num_tiles="+num_tiles+", sw = "+sw +", swz = "+swz +", swx = "+swx +", swy = "+swy); // +", kz="+kz);
}
// TODO: scale disparity to make same scale for 3 axes?
......@@ -1397,7 +1397,8 @@ public class TilePlanes {
if (tile_sel[nl][indx]) {
double w = disp_str[nl][1][indx] / sw;
if (w > 0.0){
double d = kz * (disp_str[nl][0][indx] - swz);
// double d = kz * (disp_str[nl][0][indx] - swz); // Not here!
double d = disp_str[nl][0][indx] - swz;
double wd = w*d;
double x = ((indx % stSize2) - stSize + 0.5) * tileSize + 0.5 - swx;
double y = ((indx / stSize2) - stSize + 0.5) * tileSize + 0.5 - swy;
......@@ -3795,6 +3796,7 @@ public class TilePlanes {
double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
int debugLevel)
{
if (debugLevel > 2) debugLevel ++; // no show all eigen stuff (debugLevel > 3)
// first make a plane from all tiles
ArrayList<PlaneData> st_planes = new ArrayList<PlaneData>();
......
......@@ -106,14 +106,14 @@ public class TileProcessor {
* Even when this method compares calculated values, it still only copies raw ones, all derivatives should
* be re-calculated for the new combined pass
*
* Calculates max_tried_disparity that shows maximal tried dieparity for each tile, regardless of the reulsts/strength
* Calculates max_tried_disparity that shows maximal tried disparity for each tile, regardless of the resulsts/strength
* @param passes list of passes to merge
* @param firstPass first index in the list to use
* @param lastPass last index in the list to use
* @param debugLevel debug level
* @return combined pass, contains same data as after the measuremnt of the actual one
* @return combined pass, contains same data as after the measurement of the actual one
*/
public CLTPass3d combinePasses(
public CLTPass3d combinePasses_old(
final ArrayList <CLTPass3d> passes,
final int firstPass,
final int lastPassPlus1,
......@@ -278,7 +278,7 @@ public class TileProcessor {
* @param minStrengthVert vertical (for horizontal features) correlation strength to consider data to be reliable
* @param use_last use last scan data if nothing strong enough (false - use the strongest)
* @param usePoly use polynomial method to find max for full correlation, false - use center of mass
* @param copyDebug copy data tyhat is only needed for debug purposes
* @param copyDebug copy data that is only needed for debug purposes
* @return new composite scan pass (not added to the list
*/
public CLTPass3d compositeScan(
......@@ -591,9 +591,14 @@ public class TileProcessor {
final CLTPass3d bg_scan, // background scan data
final int grow_sweep, // 8; // Try these number of tiles around known ones
final double grow_disp_max, // = 50.0; // Maximal disparity to try
final double tried_margin, // = 4.0; // consider alrdeady tried if within this margin from already tried
final double tried_margin, // = 4.0; // consider already tried if within this margin from already tried
final double grow_disp_step, // = 6.0; // Increase disparity (from maximal tried) if nothing found in that tile // TODO: handle enclosed dips?
// not used
final double grow_min_diff, // = 0.5; // Grow more only if at least one channel has higher variance from others for the tile
final boolean grow_retry_far, // Retry tiles around known foreground that have low max_tried_disparity
final boolean grow_pedantic, // Scan full range between max_tried_disparity of the background and known foreground
final boolean grow_retry_inf, // Retry border tiles that were identified as infinity earlier
EyesisCorrectionParameters.CLTParameters clt_parameters,
GeometryCorrection geometryCorrection,
final boolean show_debug,
......@@ -603,6 +608,8 @@ public class TileProcessor {
{
final int dbg_tile = 54627; // ty=159, tx = 249
final int tlen = tilesY * tilesX;
final boolean retryTwoSteps = true; // false; // true;
double [][] dbg_img = null;
String [] dbg_titles = null;
showDoubleFloatArrays sdfa_instance = null;
......@@ -627,16 +634,48 @@ public class TileProcessor {
int ty = nt / tilesX;
int tx = nt % tilesX;
disparity[nt] = 0.0;
/// if (last_scan.selected[nt]) disparity[nt] = last_scan.disparity[ty][tx];
if (these_no_border[nt]) disparity[nt] = last_scan.disparity[ty][tx];
}
boolean [] untested_bgnd = null;
if (grow_retry_far){
if (retryTwoSteps) {
untested_bgnd = scan.getUntestedBackgroundBorder2 (
known_tiles, // final boolean [] known,
disparity, // final double [] disparity,
grow_disp_step, // final double grow_disp_step,
debugLevel); // final int debugLevel)
} else {
untested_bgnd = scan.getUntestedBackgroundBorder (
known_tiles, // final boolean [] known,
disparity, // final double [] disparity,
grow_disp_step, // final double grow_disp_step,
debugLevel); // final int debugLevel)
}
if (!grow_retry_inf){
for (int i = 0; i < untested_bgnd.length; i++) if (bg_scan.selected[i]) untested_bgnd[i] = false;
}
// turn these tiles as if they are not known (really known or belong to bgnd)
for (int i = 0; i < known_tiles.length; i++) known_tiles[i] &= !untested_bgnd[i];
if (debugLevel > -1){
int num_untested_far = 0;
for (int i = 0; i < untested_bgnd.length; i++) if (untested_bgnd[i]) num_untested_far++;
System.out.println("setupExtendDisparity(): Discovered "+num_untested_far+" tiles that may have disparity between bg and (yet untested) fg");
}
}
// now known_tiles have untested background removed. most likely will be added when growing known
boolean [] grown = known_tiles.clone();
growTiles(
2*grow_sweep, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown, // boolean [] tiles,
null); // boolean [] prohibit)
boolean [] border = grown.clone();
for (int i = 0; i < border.length; i++) border[i] &= !known_tiles[i];
// double [] dbg_before = scan.getDisparity().clone();
......@@ -646,6 +685,8 @@ public class TileProcessor {
scan.getStrength()); // double [] strength)
// double [] dbg_after = scan.getDisparity().clone();
int [] neighbors = dp.getNeighbors( // creates neighbors mask from bitmask
grown, // these_tiles, // grown, // these_tiles, // boolean [] selected,
tilesX);
......@@ -660,6 +701,10 @@ public class TileProcessor {
sdfa_instance.showArrays(dbg_neib,tilesX*clt_parameters.transform_size, tilesY*clt_parameters.transform_size,"XXneighbors");
}
*/
double [] dbg_pre_disp = null;
if (show_debug) {
dbg_pre_disp = scan.getDisparity().clone();
}
dp.smoothDisparity(
clt_parameters.tiDispPull, // final double dispPull, // clt_parameters.tiDispPull or 0.0
2, // 2, // 3, // final int mask, // 1 - work on internal elements, 2 - on border elements, 3 - both (internal first);
......@@ -677,7 +722,28 @@ public class TileProcessor {
threadsMax, // maximal number of threads to launch
debugLevel);
// increase disparity if it
// replace untested_bgnd[] tiles with max_tried_disparity + grow_disp_step if it is below disparity[...]
if (grow_retry_far && grow_pedantic) {
int num_pedantic = 0;
// disparity = scan.getDisparity();
for (int nTile = 0; nTile < untested_bgnd.length; nTile++) if (untested_bgnd[nTile]) {
int tX = nTile% tilesX;
int tY = nTile% tilesY;
double disp = scan.max_tried_disparity[tY][tX] + grow_disp_step;
if (disp < disparity[nTile]){
disparity[nTile] = disp;
num_pedantic++;
}
if (debugLevel > -1){
System.out.println("setupExtendDisparity(): replaced "+num_pedantic+" tiles to discover possible planes between fg and bg");
}
}
}
// increase disparity if new suggested value was already tried
boolean [] tried_before = new boolean [tlen];
int num_tried_before = 0;
int num_extended = 0;
......@@ -744,12 +810,16 @@ public class TileProcessor {
int op = ImageDtt.setImgMask(0, 0xf);
op = ImageDtt.setPairMask(op,0xf);
op = ImageDtt.setForcedDisparity(op,true);
// Wrong calculation of num_extended?
int num_op_tiles = 0;
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
if (scan.selected[indx]) {
scan.disparity[ty][tx] = disparity[indx];
scan.tile_op[ty][tx] = op;
num_op_tiles ++;
} else {
scan.disparity[ty][tx] = 0.0;
scan.tile_op[ty][tx] = 0;
......@@ -758,48 +828,61 @@ public class TileProcessor {
if (show_debug){
String [] dbg_titles0 = {"tried","disparity","bgnd","these","known_in", "known","last_sel_border", "no_border","tried_before"};
dbg_titles = dbg_titles0;
dbg_img = new double[dbg_titles.length][];
dbg_img[0] = new double[tilesY * tilesX];
// dbg_img[1] = scan.getDisparity();
dbg_img[1] = new double[tilesY * tilesX];
dbg_img[2] = new double[tilesY * tilesX];
dbg_img[3] = new double[tilesY * tilesX];
dbg_img[4] = new double[tilesY * tilesX];
dbg_img[5] = new double[tilesY * tilesX];
String [] dbg_titles0 = {
"tried", // 0
"pre_disp", // 1
"disparity", // 2
"strength", // 3
"bgnd", // 4
"these", // 5
"known_in", // 6
"known", // 7
"last_sel_border",// 8
"no_border", // 9
"tried_before", // 10
"retest", // 11
"diff2max", // 12
"diff2maxAvg", // 13
"normStrength"}; //14
dbg_img[6] = new double[tilesY * tilesX];
dbg_img[7] = new double[tilesY * tilesX];
dbg_img[8] = new double[tilesY * tilesX];
dbg_titles = dbg_titles0;
dbg_img = new double[dbg_titles.length][tilesY * tilesX];
//dbg_pre_disp
double [] strength = scan.getStrength();
double boolean_val = 50.0;
double [] diff2max = scan.getSecondMaxDiff(false);
double [] diff2maxAvg = scan.getSecondMaxDiff(true);
dbg_img[1] = dbg_pre_disp;
for (int i = 0; i <tlen; i++){
int ty = i / tilesX;
int tx = i % tilesX;
dbg_img[0][i] = scan.max_tried_disparity[ty][tx];
dbg_img[1][i] = scan.disparity[ty][tx];
// dbg_img[1][i] = last_scan.disparity[ty][tx];
dbg_img[2][i] = ((bg_scan.selected != null) && (bg_scan.selected[i]))? 1.0:0.0 ;
dbg_img[3][i] = ((last_scan.selected != null) && (last_scan.selected[i]))? 1.0:0.0 ;
dbg_img[4][i] = dbg_img[2][i] + dbg_img[3][i];
dbg_img[5][i] = (scan.selected[i]?1:0)+ (scan.border_tiles[i]?2:0);
dbg_img[2][i] = scan.disparity[ty][tx];
dbg_img[3][i] = strength[i];
dbg_img[4][i] = ((bg_scan.selected != null) && (bg_scan.selected[i]))? boolean_val:0.0 ;
dbg_img[5][i] = ((last_scan.selected != null) && (last_scan.selected[i]))? boolean_val:0.0 ;
dbg_img[6][i] = 0.05 * (dbg_img[4][i] + dbg_img[5][i]);
dbg_img[7][i] = (scan.selected[i]?4:0)+ (scan.border_tiles[i]?8:0);
dbg_img[6][i] = (dbg_last_selected[i]?1:0)+ (dbg_last_border[i]?2:0);
dbg_img[7][i] = dbg_no_border[i]?1:0;
dbg_img[8][i] = tried_before[i]?1:0;
dbg_img[8][i] = (dbg_last_selected[i]?4:0)+ (dbg_last_border[i]?8:0);
dbg_img[9][i] = dbg_no_border[i]?boolean_val:0;
dbg_img[10][i] = tried_before[i]?boolean_val:0;
if (untested_bgnd != null){
dbg_img[11][i] = untested_bgnd[i]? scan.disparity[ty][tx]: Double.NaN;
}
if (diff2maxAvg[i] > 0.0){
dbg_img[14][i] = strength[i]/ diff2maxAvg[i];
}
sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "extend_disparity",dbg_titles);
}
/*
boolean [] dbg_last_selected = last_scan.selected.clone();
boolean [] dbg_last_border = last_scan.border_tiles.clone();
boolean [] dbg_no_border = these_no_border.clone();
dbg_img[12] = diff2max;
dbg_img[13] = diff2maxAvg;
*/
return num_extended;
sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "extend_disparity-"+clt_3d_passes.size(),dbg_titles);
}
return num_op_tiles; // num_extended;
}
public void showScan(
......@@ -821,7 +904,16 @@ public class TileProcessor {
"strength_vert", // 9
"selection", // 10
"border_tiles", // 11
"max_tried"}; // 12
"max_tried", // 12
"diff0", // 13
"diff1", // 14
"diff2", // 15
"diff3", // 16
"diff2max", // 17
"diff2maxAvg", // 18
"normStrength"}; // 19
int tlen = tilesX*tilesY;
// double [][] dbg_img = new double[titles.length][tlen];
double [][] dbg_img = new double[titles.length][];
......@@ -839,7 +931,9 @@ public class TileProcessor {
if (scan.border_tiles != null) dbg_img[11][nt] = scan.border_tiles[nt]? 1.0:0.0;
if (scan.max_tried_disparity != null) dbg_img[12][nt] = scan.max_tried_disparity[ty][tx];
}
double [] strength4 = null;
if (scan.disparity_map != null){
strength4 = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[3] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM];
dbg_img[4] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR];
dbg_img[5] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT];
......@@ -849,6 +943,25 @@ public class TileProcessor {
}
dbg_img[1] = scan.calc_disparity_combo;
dbg_img[6] = scan.strength;
double [][] these_diffs = scan.getDiffs();
double [] diff2max = scan.getSecondMaxDiff(false);
double [] diff2maxAvg = scan.getSecondMaxDiff(true);
if (these_diffs != null) {
dbg_img[13] = these_diffs[0];
dbg_img[14] = these_diffs[1];
dbg_img[15] = these_diffs[2];
dbg_img[16] = these_diffs[3];
dbg_img[17] = diff2max;
dbg_img[18] = diff2maxAvg;
dbg_img[19] = new double[tlen];
if ((diff2maxAvg != null) && (strength4 != null)) {
for (int i = 0; i < tlen; i++){
if (diff2maxAvg[i] > 0.0){
dbg_img[19][i] = strength4[i]/ diff2maxAvg[i];
}
}
}
}
title += "-";
if (scan.isMeasured()) title += "M";
......@@ -2180,15 +2293,15 @@ public class TileProcessor {
public boolean [] FilterScan(
final CLTPass3d scan,
final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
// final boolean [] border_tiles, // last measured boirder tiles
final CLTPass3d last_meas, // last measured scan (with border_tiles and getSecondMaxDiff
final int [] horVertMod, // +1 - modified by hor correlation, +2 - modified by vert correlation (or null)
final double disparity_far, //
final double disparity_near, //
final double this_sure, // minimal strength to be considered definitely background
final double ex_strength, // minimal 4-corr strength to trust tile
final double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
final double this_maybe, // maximal strength to ignore as non-background
final double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
// final EyesisCorrectionParameters.CLTParameters clt_parameters,
// final int threadsMax, // maximal number of threads to launch
final boolean show_filter_scan,
final int min_clstr_seed, // clt_parameters.min_clstr_seed
final double min_clstr_weight, // double min_weight // minimal total weight of the cluster
......@@ -2200,14 +2313,7 @@ public class TileProcessor {
final int debugLevel
)
{
/*
clt_parameters.min_clstr_weight, // double min_weight // minimal total weight of the cluster
clt_parameters.min_clstr_max, // double min_max_weight // minimal value of the maximal strengh in the cluster
clt_parameters.min_clstr_lone, // int min_area, // minimal number of pixels
clt_parameters.fill_gaps, // int depth, // same as grow - odd - 4 directions, even - 8
*/
final double super_trust = 1.6; // If strength exceeds ex_strength * super_trust, do not apply ex_nstrength
final int dbg_tile = 49468; // x = 220, y = 152 (pavement line)
final boolean show_scan = show_filter_scan || (debugLevel > 1);
......@@ -2227,6 +2333,11 @@ public class TileProcessor {
boolean [] near_tiles = new boolean [tlen];
boolean [] far_tiles = new boolean [tlen];
boolean [] block_propagate = new boolean [tlen];
double [] second_max_diff = null;
final boolean [] border_tiles = (last_meas != null) ? last_meas.getBorderTiles() : null;
if ((ex_nstrength > 0.0) && (border_tiles != null)){
second_max_diff = last_meas.getSecondMaxDiff(true); // false - single tile, true - 3x3 weighted average
}
for (int i = 0; i <tlen; i++) if (!Double.isNaN(this_disparity[i])){
if ((debugLevel > 0) && (i==dbg_tile)){
......@@ -2246,10 +2357,23 @@ public class TileProcessor {
near_tiles[i] = true;
}
} else { // in range
if ((this_strength[i] > this_sure) || ((horVertMod != null) && (horVertMod[i] != 0))){
// Higher difference, higher the correlation strength is needed
// assuming this_strength is combine of the strength4 and hor/vert, apply to any
if ((this_strength[i] > ex_strength) || (horVertMod != null) && (horVertMod[i] != 0)){
these_tiles[i] = true;
if (this_strength[i] < ex_strength* super_trust) {
if (second_max_diff != null) { // only apply to the border tiles, so by next pass they () weak can be used?
if (border_tiles[i] && (this_strength[i] < second_max_diff[i] * ex_nstrength)) {
these_tiles[i] = false;
}
}
}
}
// this one is not (yet) compared to normalized difference between the channels
// if ((horVertMod != null) && (horVertMod[i] != 0)){
// these_tiles[i] = true;
// }
}
// see if the second worst variation exceeds sure_smth (like a window), really close object
int imax1 = 0;
for (int ip = 1; ip < these_diffs.length; ip++){
......@@ -2261,6 +2385,10 @@ public class TileProcessor {
}
block_propagate[i] = (these_diffs[imax2][i] > sure_smth);
}
//ex_nstrength
boolean[] prohibit = null; // TBD
boolean[] dbg_before_small = null;
boolean[] dbg_before_lone = null;
......@@ -2470,7 +2598,7 @@ public class TileProcessor {
return replaced;
}
public boolean [] combineHorVertDisparity(
public boolean [] combineHorVertDisparity_old(
final CLTPass3d scan,
final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
final double disparity_far, //
......@@ -2533,6 +2661,8 @@ public class TileProcessor {
//getOriginalStrength()
boolean use_ortho = true; // false;
if (use_ortho) {
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
int indx = i * tilesX + j;
......@@ -2542,12 +2672,14 @@ public class TileProcessor {
// with that value
if ((hor_strength_conv[indx] >= clt_parameters.ortho_min_hor) &&
(hor_strength_conv[indx] / vert_strength_conv[indx]>= clt_parameters.ortho_asym) &&
((strength[indx] ==0.0) || (hor_strength_conv[indx] / strength[indx] >= clt_parameters.ortho_over4)) &&
(this_hor_disparity[indx] > disp)) {
disp = this_hor_disparity[indx];
used_hor[indx] = true;
}
if ((vert_strength_conv[indx] >= clt_parameters.ortho_min_vert) &&
(vert_strength_conv[indx] / hor_strength_conv[indx]>= clt_parameters.ortho_asym) &&
((strength[indx] ==0.0) || (vert_strength_conv[indx] / strength[indx] >= clt_parameters.ortho_over4)) &&
(this_vert_disparity[indx] > disp)) {
disp = this_vert_disparity[indx];
used_vert[indx] = true;
......@@ -2555,7 +2687,7 @@ public class TileProcessor {
}
}
}
}
boolean [] dbg_used_hor = used_hor.clone();
boolean [] dbg_used_vert = used_vert.clone();
......@@ -2641,7 +2773,7 @@ public class TileProcessor {
boolean[] dbg_before_gaps = null;
if (clt_parameters.min_clstr_seed > 1){
// TODO: check - now no limit on the strength of the offending selections, only on these onses
// TODO: check - now no limit on the strength of the offending selections, only on these ones
removeSmallClusters(
false, //true, // boolean diag_en, // enable diagonal directions, false only up, dowm, right,left
......@@ -2741,6 +2873,18 @@ public class TileProcessor {
return these_tiles;
}
public CLTPass3d getLastMeasured(
int indx){
if (indx < 0) {
indx = clt_3d_passes.size() -1;
}
for (int i = indx; i >= 0; i--){
if (clt_3d_passes.get(i).isMeasured()){
return clt_3d_passes.get(i);
}
}
return null;
}
public CLTPass3d refinePassSetup( // prepare tile tasks for the second pass based on the previous one(s)
......@@ -2751,7 +2895,8 @@ public class TileProcessor {
int bg_scan_index,
double disparity_far, //
double disparity_near, //
double this_sure, // minimal strength to be considered definitely background
double ex_strength, // minimal 4-corr strength to trust tile
double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
double this_maybe, // maximal strength to ignore as non-background
double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
int disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4)
......@@ -2762,12 +2907,13 @@ public class TileProcessor {
{
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1);
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); //
CLTPass3d scan_lm = getLastMeasured(-1);
// boolean [] border_tiles = (scan_lm != null) ? scan_lm.getBorderTiles() : null;
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
//TODO: for next passes - combine all selected for previous passes (all passes with smaller disparity)
int [] replaced = null; // +1 - hor, +2 - vert
int [] replaced0 = null; // +1 - hor, +2 - vert
// if (clt_parameters.or_hor || clt_parameters.or_vert) {
// TODO: add filtering before/after
double [][] dbg_img = null;
String [] dbg_titles = null;
......@@ -2869,13 +3015,23 @@ public class TileProcessor {
sdfa_instance.showArrays(dbg_img, tilesX, tilesY, true, "ortho_combine",dbg_titles);
}
if (debugLevel > 10){
showScan( scan_prev, "preFilter_last");
showScan( scan_lm, "preFilter_meas");
}
boolean [] these_tiles = FilterScan(
scan_prev, // final CLTPass3d scan,
scan_bg.selected, // get from selected in clt_3d_passes.get(0);
// border_tiles, // final boolean [] border_tiles, // last measured boirder tiles
scan_lm, // final CLTPass3d last_meas, // last measured scan (with border_tiles and getSecondMaxDiff
replaced, // final int [] horVertMod, // +1 - modified by hor correlation, +2 - modified by vert correlation (or null)
disparity_far, // final double disparity_far, //
disparity_near, // final double disparity_near, //
this_sure, // final double this_sure, // minimal strength to be considered definitely background
ex_strength, // final double ex_strength, // minimal 4-corr strength to trust tile
ex_nstrength, // final double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
this_maybe, // final double this_maybe, // maximal strength to ignore as non-background
sure_smth, // final double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
clt_parameters.show_filter_scan,
......@@ -2884,7 +3040,7 @@ public class TileProcessor {
clt_parameters.min_clstr_max, // double min_max_weight // minimal value of the maximal strengh in the cluster
clt_parameters.min_clstr_lone, // int min_area, // minimal number of pixels
clt_parameters.fill_gaps, // int depth, // same as grow - odd - 4 directions, even - 8
0, // final int poison_gaps, // Do not fill gaps that have even single "poisoned" tile
2, // 0, // final int poison_gaps, // Do not fill gaps that have even single "poisoned" tile
false, // final boolean zero_gap_strength, // set strength to zero when covering gaps
debugLevel);
......@@ -4525,7 +4681,9 @@ public class TileProcessor {
// disparity range - differences from
double disparity_far, //
double disparity_near, //
double this_sure, // minimal strength to be considered definitely background
// double this_sure, // minimal strength to be considered definitely background
double ex_strength, // minimal 4-corr strength to trust tile
double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
double this_maybe, // maximal strength to ignore as non-background
double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
int disparity_index, // index of disparity value in disparity_map == 2 (0,2 or 4)
......@@ -4536,7 +4694,9 @@ public class TileProcessor {
{
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); //
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
// CLTPass3d scan_next =new CLTPass3d(this);
CLTPass3d scan_lm = getLastMeasured(-1);
boolean [] border_tiles = (scan_lm != null) ? scan_lm.getBorderTiles() : null;
showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
//TODO: for next passes - combine all selected for previous passes (all passes with smaller disparity)
......@@ -4553,7 +4713,7 @@ public class TileProcessor {
clt_parameters.or_vert, // true; // Apply ortho correction to vertical correlation (horizontal features)
clt_parameters.or_sigma, // 2.0; // Blur sigma: verically for horizontal correlation, horizontally - for vertically
clt_parameters.or_sharp, // 0.5; // 3-point sharpening (-k, +2k+1, -k)
clt_parameters.or_scale, // 2.0; // Scale ortho correletion strength relative to 4-directional one
clt_parameters.or_scale, // 2.0; // Scale ortho correlation strength relative to 4-directional one
clt_parameters.or_offset, // 0.1; // Subtract from scaled correlation strength, limit by 0
clt_parameters.or_asym , // 1.5; // Minimal ratio of orthogonal strengths required for dis[parity replacement
clt_parameters.or_threshold, // 1.5; // Minimal scaled offsetg ortho strength to normal strength needed for replacement
......@@ -4589,10 +4749,15 @@ public class TileProcessor {
these_tiles = FilterScan(
scan_prev, // final CLTPass3d scan,
scan_bg.selected, // get from selected in clt_3d_passes.get(0);
// border_tiles, // final boolean [] border_tiles, // last measured boirder tiles
scan_lm, // final CLTPass3d last_meas, // last measured scan (with border_tiles and getSecondMaxDiff
replaced, // final int [] horVertMod, // +1 - modified by hor correlation, +2 - modified by vert correlation (or null)
disparity_far, // final double disparity_far, //
disparity_near, // final double disparity_near, //
this_sure, // final double this_sure, // minimal strength to be considered definitely background
// this_sure, // final double this_sure, // minimal strength to be considered definitely background
ex_strength, // final double ex_strength, // minimal 4-corr strength to trust tile
ex_nstrength, // final double ex_nstrength, // minimal 4-corr strength divided by channel diff for new (border) tiles
this_maybe, // final double this_maybe, // maximal strength to ignore as non-background
sure_smth, // final double sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
true, // clt_parameters.show_filter_scan,
......@@ -4607,12 +4772,12 @@ public class TileProcessor {
// final boolean updateStatus,
2); //debugLevel);
} else {
these_tiles= combineHorVertDisparity(
these_tiles= combineHorVertDisparity_old(
scan_prev, // final CLTPass3d scan,
scan_bg.selected, // clt_3d_passes.get(0).selected, // final boolean [] bg_tiles, // get from selected in clt_3d_passes.get(0);
disparity_far, //
disparity_near, //
this_sure, // minimal strength to be considered definitely background
ex_strength, // this_sure, // minimal strength to be considered definitely background
this_maybe, // maximal strength to ignore as non-background
sure_smth, // if 2-nd worst image difference (noise-normalized) exceeds this - do not propagate bgnd
clt_parameters,
......
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