Commit f5a43005 authored by Andrey Filippov's avatar Andrey Filippov

correcting wrongly reported exposure

parent 8d207d39
...@@ -315,16 +315,16 @@ public class AlignmentCorrection { ...@@ -315,16 +315,16 @@ public class AlignmentCorrection {
magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5 magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
debugLevel); debugLevel);
double [][][] mismatch_corr_coefficiants = null; double [][][] mismatch_corr_coefficients = null;
ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>()); ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>());
mismatch_corr_coefficiants = infinityMismatchCorrection( mismatch_corr_coefficients = infinityMismatchCorrection(
clt_parameters.disp_scan_start, // final double disp_scan_start, clt_parameters.disp_scan_start, // final double disp_scan_start,
clt_parameters.disp_scan_step, // final double disp_scan_step, clt_parameters.disp_scan_step, // final double disp_scan_step,
use_poly, // clt_parameters.ly_poly, // final boolean use_poly, use_poly, // final boolean use_poly,
clt_parameters.fcorr_inf_quad, // final boolean use_quadratic, clt_parameters.fcorr_inf_quad, // final boolean use_quadratic,
clt_parameters.fcorr_inf_vert, // final boolean use_vertical, clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
clt_parameters.ly_inf_en, // final boolean use_disparity, // for infinity clt_parameters.ly_inf_en, // final boolean use_disparity, // for infinity
clt_parameters, clt_parameters,
disp_strength, disp_strength,
samples_list, samples_list,
...@@ -335,10 +335,10 @@ public class AlignmentCorrection { ...@@ -335,10 +335,10 @@ public class AlignmentCorrection {
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("infinityCorrection(): coefficient increments from infinityMismatchCorrection"); System.out.println("infinityCorrection(): coefficient increments from infinityMismatchCorrection");
show_fine_corr( show_fine_corr(
mismatch_corr_coefficiants, // double [][][] corr, mismatch_corr_coefficients, // double [][][] corr,
"");// String prefix) "");// String prefix)
} }
return mismatch_corr_coefficiants; return mismatch_corr_coefficients;
} }
/** /**
...@@ -789,7 +789,7 @@ public class AlignmentCorrection { ...@@ -789,7 +789,7 @@ public class AlignmentCorrection {
Matrix AINV = A.inverse(); Matrix AINV = A.inverse();
double scale = 0.5/magic_coeff; double scale = 0.5/magic_coeff;
double [][] dbg_xy = null; double [][] dbg_xy = null;
if (debugLevel > 0) { if (clt_parameters.show_extrinsic && (debugLevel > -2)) { // TODO: Add clt_parameters
dbg_xy = new double [9][num_tiles]; dbg_xy = new double [9][num_tiles];
} }
for (Sample s: samples_list){ for (Sample s: samples_list){
...@@ -1586,11 +1586,45 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1586,11 +1586,45 @@ B = |+dy0 -dy1 -2*dy3 |
return scans; return scans;
} }
public double [][][] lazyEyeCorrectionStep(
final boolean use_poly, // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor
final double fcorr_radius,
final double min_strength_in,
final double max_diff,
// final double comp_strength_var,
final int max_iterations,
final double max_coeff_diff,
final double far_pull, // = 0.2; // 1; // 0.5;
final double strength_pow,
final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final double lazyEyeDispVariation, // maximal full disparity difference between tgh tile and 8 neighborxs
final int smplSide, // = 2; // Sample size (side of a square)
final int smplNum, // = 3; // Number after removing worst (should be >1)
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
final double hist_disp_min,
final double hist_disp_step,
final int hist_num_bins,
final double hist_sigma,
final double hist_max_diff,
final int hist_min_samples,
final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
final double inf_fraction, // fraction of the weight for the infinity tiles
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] scans_14,
int tilesX,
double magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
int debugLevel)
{
return null;
}
public double [][][] lazyEyeCorrection( public double [][][] lazyEyeCorrection(
// final double disp_scan_start,
// final double disp_scan_step,
final boolean use_poly, // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor final boolean use_poly, // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor
final double fcorr_radius, final double fcorr_radius,
final double min_strength_in, final double min_strength_in,
...@@ -1604,7 +1638,9 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1604,7 +1638,9 @@ B = |+dy0 -dy1 -2*dy3 |
final int lazyEyeSmplSide, // = 2; // Sample size (side of a square) final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1) final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
final double lazyEyeDispVariation, // maximal full disparity difference between tgh tile and 8 neighborxs final double lazyEyeDispVariation, // maximal full disparity difference between the tile and 8 neighborxs
final double lazyEyeDispRelVariation,
final double ly_norm_disp, // = 5.0; // Reduce weight of higher disparity tiles
final int smplSide, // = 2; // Sample size (side of a square) final int smplSide, // = 2; // Sample size (side of a square)
final int smplNum, // = 3; // Number after removing worst (should be >1) final int smplNum, // = 3; // Number after removing worst (should be >1)
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
...@@ -1620,9 +1656,14 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1620,9 +1656,14 @@ B = |+dy0 -dy1 -2*dy3 |
final double inf_fraction, // fraction of the weight for the infinity tiles final double inf_fraction, // fraction of the weight for the infinity tiles
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] scans_14, double [][] scans_14,
double [][] target_disparity, // null or programmed disparity (1 per each 14 entries of scans_14)
int tilesX, int tilesX,
double magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5 double magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
int debugLevel){ int debugLevel){
// final double lazyEyeDispRelVariation = 0.02;
final int dbg_nTile = -59038;
final int num_scans = scans_14.length/NUM_ALL_SLICES; final int num_scans = scans_14.length/NUM_ALL_SLICES;
final int num_tiles = scans_14[0].length; final int num_tiles = scans_14[0].length;
final int tilesY = num_tiles/tilesX; final int tilesY = num_tiles/tilesX;
...@@ -1671,7 +1712,15 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1671,7 +1712,15 @@ B = |+dy0 -dy1 -2*dy3 |
lazyEyeSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample lazyEyeSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
tilesX);// final int tilesX); tilesX);// final int tilesX);
if (debugLevel > -1) { if (debugLevel > -2) { // -2) { // 100) {
(new showDoubleFloatArrays()).showArrays(filtered_scans, tilesX, tilesY, true, "filtered_scans");
if (debugLevel > -1) { // -2) { // 100) {
(new showDoubleFloatArrays()).showArrays(scans, tilesX, tilesY, true, "scans");
(new showDoubleFloatArrays()).showArrays(target_disparity, tilesX, tilesY, true, "target_disparity");
}
}
if (debugLevel > -2) {
System.out.println("lazyEyeCorrection() 1: removing tiles with residual disparity absoulte value > "+lazyEyeCompDiff); System.out.println("lazyEyeCorrection() 1: removing tiles with residual disparity absoulte value > "+lazyEyeCompDiff);
} }
...@@ -1679,6 +1728,9 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1679,6 +1728,9 @@ B = |+dy0 -dy1 -2*dy3 |
double [] combo_comp_rms = new double [num_tiles]; double [] combo_comp_rms = new double [num_tiles];
for (int ns = 0; ns < num_scans; ns++){ for (int ns = 0; ns < num_scans; ns++){
for (int nTile = 0; nTile < num_tiles; nTile++) { for (int nTile = 0; nTile < num_tiles; nTile++) {
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrection().1: nTile="+nTile);
}
double w = filtered_scans[ns * NUM_SLICES + 1][nTile]; double w = filtered_scans[ns * NUM_SLICES + 1][nTile];
if (w > 0.0){ if (w > 0.0){
double disp = filtered_scans[ns * NUM_SLICES + 0][nTile]; double disp = filtered_scans[ns * NUM_SLICES + 0][nTile];
...@@ -1686,9 +1738,15 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1686,9 +1738,15 @@ B = |+dy0 -dy1 -2*dy3 |
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){ for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] += filtered_scans[ns * NUM_SLICES + i][nTile] * w; combo_mismatch[i][nTile] += filtered_scans[ns * NUM_SLICES + i][nTile] * w;
} }
combo_mismatch[0][nTile] += ( if (target_disparity != null){
filtered_scans[ns * NUM_SLICES + 0][nTile]/clt_parameters.corr_magic_scale + combo_mismatch[0][nTile] += (
clt_parameters.disp_scan_start + clt_parameters.disp_scan_step * ns)* w; filtered_scans[ns * NUM_SLICES + 0][nTile]/clt_parameters.corr_magic_scale +
target_disparity[ns][nTile])* w;
} else {
combo_mismatch[0][nTile] += (
filtered_scans[ns * NUM_SLICES + 0][nTile]/clt_parameters.corr_magic_scale +
(clt_parameters.disp_scan_start + clt_parameters.disp_scan_step * ns ) )* w;
}
combo_mismatch[1][nTile] += w; combo_mismatch[1][nTile] += w;
combo_comp_rms[nTile] += w * comp_strength_rms[ns][nTile]; combo_comp_rms[nTile] += w * comp_strength_rms[ns][nTile];
} }
...@@ -1697,6 +1755,10 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1697,6 +1755,10 @@ B = |+dy0 -dy1 -2*dy3 |
} }
for (int nTile = 0; nTile < num_tiles; nTile++) { for (int nTile = 0; nTile < num_tiles; nTile++) {
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrection().2: nTile="+nTile);
}
double w = combo_mismatch[1][nTile]; double w = combo_mismatch[1][nTile];
if (w > 0.0){ if (w > 0.0){
for (int i = 0; i < NUM_SLICES; i++) if (i != 1){ for (int i = 0; i < NUM_SLICES; i++) if (i != 1){
...@@ -1711,19 +1773,35 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1711,19 +1773,35 @@ B = |+dy0 -dy1 -2*dy3 |
} }
} }
if (debugLevel > 0) { // 100) { // reduce influence of high disparity
// double norm_ly_disparity = 100.0; // disabling
for (int nTile = 0; nTile < num_tiles; nTile++) {
if (combo_mismatch[0][nTile] > ly_norm_disp) {
combo_mismatch[1][nTile] *= ly_norm_disp/combo_mismatch[0][nTile];
}
}
if (debugLevel > 0) { // -2) { // 100) {
(new showDoubleFloatArrays()).showArrays(combo_comp_rms, tilesX, tilesY, "combo_comp_rms"); (new showDoubleFloatArrays()).showArrays(combo_comp_rms, tilesX, tilesY, "combo_comp_rms");
} }
final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX); final TileNeibs tnImage = new TileNeibs(tilesX, tilesY); // num_tiles/tilesX);
for (int nTile = 0; nTile < num_tiles; nTile++) if (combo_mismatch[1][nTile] > 0.0){ for (int nTile = 0; nTile < num_tiles; nTile++) if (combo_mismatch[1][nTile] > 0.0){
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrection().3: nTile="+nTile);
}
double d = combo_mismatch[0][nTile]; double d = combo_mismatch[0][nTile];
double lev = lazyEyeDispVariation + lazyEyeDispRelVariation * d;
for (int dir = 0; dir <8; dir++){ for (int dir = 0; dir <8; dir++){
int nTile1 = tnImage.getNeibIndex(nTile, dir); int nTile1 = tnImage.getNeibIndex(nTile, dir);
if ((nTile1 >= 0) && (combo_mismatch[1][nTile1] > 0.0)){ if ((nTile1 >= 0) && (combo_mismatch[1][nTile1] > 0.0)){
if (Math.abs(combo_mismatch[0][nTile1] - d) > lazyEyeDispVariation){ if (Math.abs(combo_mismatch[0][nTile1] - d) > lev) { // azyEyeDispVariation){
combo_mismatch[1][nTile] = 0.0; combo_mismatch[1][nTile] = 0.0;
for (int i = 0; i < NUM_SLICES; i++) if (i != 1){ // for (int i = 0; i < NUM_SLICES; i++) if (i != 1){
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] = Double.NaN; combo_mismatch[i][nTile] = Double.NaN;
} }
break; break;
...@@ -1732,7 +1810,7 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1732,7 +1810,7 @@ B = |+dy0 -dy1 -2*dy3 |
} }
} }
if (debugLevel > 0) { if (debugLevel > 0) { // 0) {
String [] prefixes = {"disparity", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"}; 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); (new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
} }
...@@ -1939,7 +2017,7 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1939,7 +2017,7 @@ B = |+dy0 -dy1 -2*dy3 |
} }
} }
if (debugLevel > -1) { if (debugLevel > 0) {
double inf_weight = 0.0; double inf_weight = 0.0;
for (Sample s: inf_samples_list) { for (Sample s: inf_samples_list) {
inf_weight += s.weight; inf_weight += s.weight;
...@@ -1956,7 +2034,7 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1956,7 +2034,7 @@ B = |+dy0 -dy1 -2*dy3 |
titles[ns * NUM_SLICES + i] = prefixes[i]+"_"+ns; titles[ns * NUM_SLICES + i] = prefixes[i]+"_"+ns;
} }
} }
(new showDoubleFloatArrays()).showArrays(filtered_scans, tilesX, tilesY, true, "filtered_scans" , titles); (new showDoubleFloatArrays()).showArrays(filtered_scans, tilesX, tilesY, true, "filtered_scans_a" , titles);
} }
...@@ -1965,10 +2043,10 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1965,10 +2043,10 @@ B = |+dy0 -dy1 -2*dy3 |
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes); (new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
} }
ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>()); ArrayList<Mismatch> mismatch_list = use_poly? null : (new ArrayList<Mismatch>());
double [][][] mismatch_corr_coefficiants = infinityMismatchCorrection( double [][][] mismatch_corr_coefficients = infinityMismatchCorrection(
clt_parameters.disp_scan_start, // final double disp_scan_start, clt_parameters.disp_scan_start, // final double disp_scan_start,
clt_parameters.disp_scan_step, // final double disp_scan_step, clt_parameters.disp_scan_step, // final double disp_scan_step,
use_poly, // clt_parameters.ly_poly, // final boolean use_poly, use_poly, // final boolean use_poly,
clt_parameters.fcorr_quadratic, // final boolean use_quadratic, clt_parameters.fcorr_quadratic, // final boolean use_quadratic,
true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical, true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
false, // final boolean use_disparity, // for infinity false, // final boolean use_disparity, // for infinity
...@@ -1979,23 +2057,27 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -1979,23 +2057,27 @@ B = |+dy0 -dy1 -2*dy3 |
magic_coeff, // double , // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5 magic_coeff, // double , // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
mismatch_list, // ArrayList<Mismatch> mismatch_list, mismatch_list, // ArrayList<Mismatch> mismatch_list,
debugLevel); // int debugLevel) debugLevel); // int debugLevel)
if (debugLevel > -1) { if (debugLevel > -2) {
System.out.println("===== lazyEyeCorrection(): correction coefficients ====="); System.out.println("===== lazyEyeCorrection(): correction coefficients =====");
if (mismatch_corr_coefficiants != null) { if (mismatch_corr_coefficients != null) {
show_fine_corr( show_fine_corr(
mismatch_corr_coefficiants, mismatch_corr_coefficients,
"mismatch_corr_coefficiants"); "mismatch_corr_coefficients");
} }
} }
if (!use_poly && (mismatch_list != null)){ if (!use_poly && (mismatch_list != null)){
double [] old_new_rms = new double[1];
boolean apply_extrinsic = true; boolean apply_extrinsic = true;
GeometryCorrection.CorrVector corr_vector = solveCorr ( GeometryCorrection.CorrVector corr_vector = solveCorr (
clt_parameters.ly_inf_en, // boolean use_disparity, // if true will ignore disparity data even if available (was false) clt_parameters.ly_inf_en, // boolean use_disparity, // if true will ignore disparity data even if available (was false)
clt_parameters.ly_inf_force, // boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity clt_parameters.ly_inf_force, // boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity
clt_parameters.ly_com_roll, // boolean common_roll, // Enable common roll (valid for high disparity range only)
mismatch_list, // ArrayList<Mismatch> mismatch_list, mismatch_list, // ArrayList<Mismatch> mismatch_list,
qc.geometryCorrection, // GeometryCorrection geometryCorrection, qc.geometryCorrection, // GeometryCorrection geometryCorrection,
qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector, qc.geometryCorrection.getCorrVector(), // GeometryCorrection.CorrVector corr_vector,
2); // 1); // int debugLevel) old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // 2); // 1); // int debugLevel)
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("Old extrinsic corrections:"); System.out.println("Old extrinsic corrections:");
System.out.println(qc.geometryCorrection.getCorrVector().toString()); System.out.println(qc.geometryCorrection.getCorrVector().toString());
...@@ -2009,14 +2091,20 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2009,14 +2091,20 @@ B = |+dy0 -dy1 -2*dy3 |
System.out.println(qc.geometryCorrection.getCorrVector().toString()); System.out.println(qc.geometryCorrection.getCorrVector().toString());
} }
} }
mismatch_corr_coefficients = new double [1][2][];
mismatch_corr_coefficients[0][0] = corr_vector.toSymArray(null);
// mismatch_corr_coefficients[0][1] = new double[1];
// old_new_rms[1] = getRMS(getYminusFx(mismatch_list), getWeights(mismatch_list));
mismatch_corr_coefficients[0][1] = old_new_rms;
} else { } else {
if (debugLevel > -1){ if (debugLevel > -2){
System.out.println("Extrinsic parameters (tilt, azimuth, roll) of subcameras is disabled, clt_parameters.ly_poly="+ System.out.println("Extrinsic parameters (tilt, azimuth, roll) of subcameras is disabled, use_poly="+
clt_parameters.ly_poly+" (should be false for extrinsics)"); use_poly+" (should be false for extrinsics)");
System.out.println(qc.geometryCorrection.getCorrVector().toString()); System.out.println(qc.geometryCorrection.getCorrVector().toString());
} }
return mismatch_corr_coefficients;
} }
return mismatch_corr_coefficiants; return mismatch_corr_coefficients;
} }
public double [][] combineCltMismatches( public double [][] combineCltMismatches(
...@@ -2458,9 +2546,12 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2458,9 +2546,12 @@ B = |+dy0 -dy1 -2*dy3 |
boolean use_disparity, // if true will ignore disparity data even if available boolean use_disparity, // if true will ignore disparity data even if available
boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity boolean force_convergence, // if true try to adjust convergence (disparity, symmetrical parameter 0) even with no disparity
// data, using just radial distortions // data, using just radial distortions
boolean common_roll, // Enable common roll (valid for high disparity range only)
ArrayList<Mismatch> mismatch_list, ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection, GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector, GeometryCorrection.CorrVector corr_vector,
double [] old_new_rms, // should be double[2]
int debugLevel) int debugLevel)
{ {
boolean has_disparity = force_convergence; // force false; boolean has_disparity = force_convergence; // force false;
...@@ -2471,10 +2562,26 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2471,10 +2562,26 @@ B = |+dy0 -dy1 -2*dy3 |
break; break;
} }
} }
boolean [] par_mask = new boolean[10]; // boolean [] par_mask = new boolean[10];
for (int i = (has_disparity ? 0 : 1); i < par_mask.length; i++){ // for (int i = (has_disparity ? 0 : 1); i < par_mask.length; i++){
par_mask[i] = true; // par_mask[i] = true;
} // }
boolean [] par_mask = geometryCorrection.getParMask(
has_disparity, // boolean use_disparity,
common_roll); // boolean common_roll);
/* { // TODO: move to GeometryCorrection
has_disparity, //sym0
true, //sym1
true, //sym2
true, //sym3
true, //sym4
true, //sym5
common_roll, //sym6 // common roll
true, //sym7
true, //sym8
true //sym9
};
*/
double [][] jta = getJacobianTransposed( double [][] jta = getJacobianTransposed(
par_mask, // boolean [] par_mask, par_mask, // boolean [] par_mask,
...@@ -2502,6 +2609,10 @@ B = |+dy0 -dy1 -2*dy3 | ...@@ -2502,6 +2609,10 @@ B = |+dy0 -dy1 -2*dy3 |
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("--- solveCorr(): initial RMS = " + rms0); System.out.println("--- solveCorr(): initial RMS = " + rms0);
} }
if (old_new_rms != null){
old_new_rms[0] =rms0;
}
Matrix y_minus_fx_weighted = new Matrix(y_minus_fx_a_weighted, y_minus_fx_a_weighted.length); Matrix y_minus_fx_weighted = new Matrix(y_minus_fx_a_weighted, y_minus_fx_a_weighted.length);
// double [][] jtja = getJTJ(jta, weights); // double [][] jtja = getJTJ(jta, weights);
double [][] jtja = getJTJ(jta_mv, weights); double [][] jtja = getJTJ(jta_mv, weights);
......
...@@ -27,6 +27,7 @@ import java.awt.Rectangle; ...@@ -27,6 +27,7 @@ import java.awt.Rectangle;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class CLTPass3d{ public class CLTPass3d{
// static double max_overexposed = 0.8; // TODO: make parameter
public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX] public double [][] disparity; // per-tile disparity set for the pass[tileY][tileX]
public int [][] tile_op; // what was done in the current pass public int [][] tile_op; // what was done in the current pass
private double [][] disparity_sav; // saved disaprity private double [][] disparity_sav; // saved disaprity
...@@ -192,8 +193,7 @@ public class CLTPass3d{ ...@@ -192,8 +193,7 @@ public class CLTPass3d{
*/ */
public void resetProcessed(){ public void resetProcessed(){
fixNaNDisparity(); if (disparity_map != null) fixNaNDisparity();
calc_disparity = null; // composite disparity, calculated from "disparity", and "disparity_map" fields calc_disparity = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
calc_disparity_hor = null; // composite disparity, calculated from "disparity", and "disparity_map" fields calc_disparity_hor = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
calc_disparity_vert = null; // composite disparity, calculated from "disparity", and "disparity_map" fields calc_disparity_vert = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
...@@ -356,15 +356,21 @@ public class CLTPass3d{ ...@@ -356,15 +356,21 @@ public class CLTPass3d{
} }
return disparity; return disparity;
} }
public double [] getOverexposedFraction(){
return (disparity_map != null)? disparity_map[ImageDtt.OVEREXPOSED] : null;
}
/** /**
* Returns per-tile correlation "strength". Initially - copy of the FPGA-generated data, b ut later may be replaced by a combination * Returns per-tile correlation "strength". Initially - copy of the FPGA-generated data, but later may be replaced by a combination
* of the combined data from 4-sensor (4-pair) correlation and horizontal/vertical pairs only to improve detection of vertical/ * of the combined data from 4-sensor (4-pair) correlation and horizontal/vertical pairs only to improve detection of vertical/
* horizontal features * horizontal features
* @return line-scan array of per-tile correlation strength by reference (not a copy), so it can be modified * @return line-scan array of per-tile correlation strength by reference (not a copy), so it can be modified
*/ */
public double [] getStrength(){ public double [] getStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation(); double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength == null){ if (strength == null){
strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone(); strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
if (trustedCorrelation > 0.0){ if (trustedCorrelation > 0.0){
...@@ -372,6 +378,12 @@ public class CLTPass3d{ ...@@ -372,6 +378,12 @@ public class CLTPass3d{
if (Math.abs(disparity_map[disparity_index][i]) > trustedCorrelation) strength[i] = 0.0; // too far if (Math.abs(disparity_map[disparity_index][i]) > trustedCorrelation) strength[i] = 0.0; // too far
} }
} }
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength.length; i++){
if (overexposed[i] > max_overexposure) strength[i] = 0.0; // too overexposed
}
}
} }
return strength; return strength;
} }
...@@ -388,6 +400,7 @@ public class CLTPass3d{ ...@@ -388,6 +400,7 @@ public class CLTPass3d{
*/ */
public double [] getHorStrength(){ public double [] getHorStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation(); double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_hor == null) { if (strength_hor == null) {
strength_hor = disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH].clone(); strength_hor = disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH].clone();
if (trustedCorrelation > 0.0){ if (trustedCorrelation > 0.0){
...@@ -395,15 +408,23 @@ public class CLTPass3d{ ...@@ -395,15 +408,23 @@ public class CLTPass3d{
if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_HOR][i]) > trustedCorrelation) strength_hor[i] = 0.0; // too far if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_HOR][i]) > trustedCorrelation) strength_hor[i] = 0.0; // too far
} }
} }
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength_hor.length; i++){
if (overexposed[i] > max_overexposure) strength_hor[i] = 0.0; // too overexposed
}
}
} }
return strength_hor; return strength_hor;
} }
/** /**
* Get veriical pairs correlation strength for horizontal features. Not a copy * Get vertical pairs correlation strength for horizontal features. Not a copy
* @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy) * @return line-scan array of per-tile horizontal pairs correlation strength by reference (not a copy)
*/ */
public double [] getVertStrength(){ public double [] getVertStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation(); double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_vert == null) { if (strength_vert == null) {
strength_vert = disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH].clone(); strength_vert = disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH].clone();
if (trustedCorrelation > 0.0){ if (trustedCorrelation > 0.0){
...@@ -411,6 +432,12 @@ public class CLTPass3d{ ...@@ -411,6 +432,12 @@ public class CLTPass3d{
if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_VERT][i]) > trustedCorrelation) strength_vert[i] = 0.0; // too far if (Math.abs(disparity_map[ImageDtt.DISPARITY_INDEX_VERT][i]) > trustedCorrelation) strength_vert[i] = 0.0; // too far
} }
} }
double [] overexposed = disparity_map[ImageDtt.OVEREXPOSED];
if ((max_overexposure > 0.0) && (overexposed != null)){
for (int i = 0; i < strength_hor.length; i++){
if (overexposed[i] > max_overexposure) strength_vert[i] = 0.0; // too overexposed
}
}
} }
return strength_vert; return strength_vert;
...@@ -704,6 +731,7 @@ public class CLTPass3d{ ...@@ -704,6 +731,7 @@ public class CLTPass3d{
selection, // boolean [] selection, selection, // boolean [] selection,
disparity); // double [] disparity) disparity); // double [] disparity)
} }
public int setTileOpDisparity( public int setTileOpDisparity(
int tile_op, int tile_op,
boolean [] selection, boolean [] selection,
...@@ -712,26 +740,39 @@ public class CLTPass3d{ ...@@ -712,26 +740,39 @@ public class CLTPass3d{
final int tilesX = tileProcessor.getTilesX(); final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY(); final int tilesY = tileProcessor.getTilesY();
this.disparity = new double [tilesY][tilesX]; this.disparity = new double [tilesY][tilesX];
this.tile_op = new int [tilesY][tilesX]; if (selection != null) {
this.tile_op = new int [tilesY][tilesX];
}
int num_op_tiles = 0; int num_op_tiles = 0;
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){ for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx; int indx = tilesX * ty + tx;
if (this.selected[indx]) { if (selection == null) {
this.disparity[ty][tx] = disparity[indx]; this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
this.tile_op[ty][tx] = tile_op; if (this.tile_op[ty][tx] != 0){
num_op_tiles ++; num_op_tiles ++;
}
} else { } else {
this.disparity[ty][tx] = 0.0; if (selection[indx]) {
this.tile_op[ty][tx] = 0; this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
this.tile_op[ty][tx] = tile_op;
num_op_tiles ++;
} else {
this.disparity[ty][tx] = 0.0;
this.tile_op[ty][tx] = 0;
}
} }
} }
return num_op_tiles; return num_op_tiles;
} }
/**
* Set next measurement disparity from last calculated
*/
public void updateDisparity()
{
setTileOpDisparity(null, getDisparity(0));
}
public double [] getSecondMaxDiff ( public double [] getSecondMaxDiff (
......
...@@ -368,10 +368,10 @@ public class EyesisCorrectionParameters { ...@@ -368,10 +368,10 @@ public class EyesisCorrectionParameters {
gd.addStringField("Equirectangular maps directory (may be empty)", this.equirectangularDirectory, 60); gd.addStringField("Equirectangular maps directory (may be empty)", this.equirectangularDirectory, 60);
gd.addCheckbox("Select equirectangular maps directory", false); gd.addCheckbox("Select equirectangular maps directory", false);
gd.addStringField("Results directory", this.resultsDirectory, 40); gd.addStringField("Results directory", this.resultsDirectory, 60);
gd.addCheckbox("Select results directory", false); gd.addCheckbox("Select results directory", false);
gd.addStringField("Source files prefix", this.sourcePrefix, 40); gd.addStringField("Source files prefix", this.sourcePrefix, 60);
gd.addStringField("Source files suffix", this.sourceSuffix, 40); gd.addStringField("Source files suffix", this.sourceSuffix, 60);
gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0); gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0);
gd.addStringField("Sensor files prefix", this.sensorPrefix, 40); gd.addStringField("Sensor files prefix", this.sensorPrefix, 40);
...@@ -457,13 +457,6 @@ public class EyesisCorrectionParameters { ...@@ -457,13 +457,6 @@ public class EyesisCorrectionParameters {
this.firstSubCamera= (int) gd.getNextNumber(); this.firstSubCamera= (int) gd.getNextNumber();
this.sensorPrefix= gd.getNextString(); this.sensorPrefix= gd.getNextString();
this.sensorSuffix= gd.getNextString(); this.sensorSuffix= gd.getNextString();
this.sharpKernelPrefix= gd.getNextString();
this.sharpKernelSuffix= gd.getNextString();
this.smoothKernelPrefix= gd.getNextString();
this.smoothKernelSuffix= gd.getNextString();
this.dctKernelPrefix= gd.getNextString();
this.dctSymSuffix= gd.getNextString();
this.dctAsymSuffix= gd.getNextString();
this.cltKernelPrefix= gd.getNextString(); this.cltKernelPrefix= gd.getNextString();
this.cltSuffix= gd.getNextString(); this.cltSuffix= gd.getNextString();
this.equirectangularPrefix= gd.getNextString(); this.equirectangularPrefix= gd.getNextString();
...@@ -479,6 +472,60 @@ public class EyesisCorrectionParameters { ...@@ -479,6 +472,60 @@ public class EyesisCorrectionParameters {
return true; return true;
} }
public boolean showCLTDialog(String title) {
GenericDialog gd = new GenericDialog(title);
gd.addCheckbox ("Save current settings with results", this.saveSettings); // 1
gd.addStringField ("Source files directory", this.sourceDirectory, 60); // 2
gd.addCheckbox ("Select source directory", false); // 3
gd.addStringField ("Sensor calibration directory", this.sensorDirectory, 60); // 4
gd.addCheckbox ("Select sensor calibration directory", false); // 5
gd.addStringField ("Aberration kernels for CLT directory", this.cltKernelDirectory, 60); // 6
gd.addCheckbox ("Select aberration kernels for CLT directory", false); // 7
gd.addStringField ("x3d output directory", this.x3dDirectory, 60); // 8
gd.addCheckbox ("Select x3d output directory", false); // 9
gd.addStringField("Results directory", this.resultsDirectory, 60); // 10
gd.addCheckbox("Select results directory", false); // 11
gd.addStringField("Source files prefix", this.sourcePrefix, 60); // 12
gd.addStringField("Source files suffix", this.sourceSuffix, 60); // 13
gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0); // 14
gd.addStringField("Sensor files prefix", this.sensorPrefix, 40); // 15
gd.addStringField("Sensor files suffix", this.sensorSuffix, 40); // 16
gd.addStringField("CLT kernel files prefix", this.cltKernelPrefix, 40); // 17
gd.addStringField("CLT symmetical kernel files", this.cltSuffix, 40); // 18
gd.addMessage("============ batch parameters ============");
WindowTools.addScrollBars(gd);
gd.showDialog();
if (gd.wasCanceled()) return false;
this.saveSettings= gd.getNextBoolean(); // 1
this.sourceDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSourceDirectory(false, false); // 3
this.sensorDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectSensorDirectory(false, false); // 5
this.cltKernelDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectCLTKernelDirectory(false, true); // 7
this.x3dDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectX3dDirectory(false, true); // 9
this.resultsDirectory= gd.getNextString(); if (gd.getNextBoolean()) selectResultsDirectory(false, true); // 11
this.sourcePrefix= gd.getNextString(); // 12
this.sourceSuffix= gd.getNextString(); // 13
this.firstSubCamera= (int) gd.getNextNumber(); // 14
this.sensorPrefix= gd.getNextString(); // 15
this.sensorSuffix= gd.getNextString(); // 16
this.cltKernelPrefix= gd.getNextString(); // 17
this.cltSuffix= gd.getNextString(); // 18
return true;
}
// TODO: extract timestamnp from JP4 or, at least combine movie timestamp+frame into a single filename string // TODO: extract timestamnp from JP4 or, at least combine movie timestamp+frame into a single filename string
public String [] getSourcePaths(){ public String [] getSourcePaths(){
...@@ -1923,12 +1970,15 @@ public class EyesisCorrectionParameters { ...@@ -1923,12 +1970,15 @@ public class EyesisCorrectionParameters {
public double fat_zero = 0.0; // modify phase correlation to prevent division by very small numbers public double fat_zero = 0.0; // modify phase correlation to prevent division by very small numbers
public double corr_sigma = 0.8; // LPF correlation sigma public double corr_sigma = 0.8; // LPF correlation sigma
public boolean norm_kern = true; // normalize kernels public boolean norm_kern = true; // normalize kernels
public boolean gain_equalize = false;// equalize green channel gain public boolean gain_equalize = false;// equalize green channel gain (bug fix for wrong exposure in Exif ?)
public boolean colors_equalize = true; // equalize R/G, B/G of the individual channels public boolean colors_equalize = true; // equalize R/G, B/G of the individual channels
public boolean nosat_equalize = true; // Skip saturated when adjusting gains
public double sat_level = 0.95; // Saturation level of the most saturated color channel
public double max_overexposure = 0.6; // Do not use tiles with higher fraction of (near) saturated tiles
public double novignetting_r = 0.2644; // reg gain in the center of sensor calibration R (instead of vignetting) public double novignetting_r = 0.2644; // reg gain in the center of sensor calibration R (instead of vignetting)
public double novignetting_g = 0.3733; // green gain in the center of sensor calibration G public double novignetting_g = 0.3733; // green gain in the center of sensor calibration G
public double novignetting_b = 0.2034; // blue gain in the center of sensor calibration B public double novignetting_b = 0.2034; // blue gain in the center of sensor calibration B
public double scale_r = 1.0; // extra gain correction after vignetting or nonvignetting, before other processing public double scale_r = 1.0; // extra gain correction after vignetting or non-vignetting, before other processing
public double scale_g = 1.0; public double scale_g = 1.0;
public double scale_b = 1.0; public double scale_b = 1.0;
public double vignetting_max = 0.4; // value in vignetting data to correspond to 1x in the kernel public double vignetting_max = 0.4; // value in vignetting data to correspond to 1x in the kernel
...@@ -2048,12 +2098,22 @@ public class EyesisCorrectionParameters { ...@@ -2048,12 +2098,22 @@ public class EyesisCorrectionParameters {
// public double ly_meas_disp = 1.5; // Maximal measured relative disparity - using (0.8*disp_scan_step) // public double ly_meas_disp = 1.5; // Maximal measured relative disparity - using (0.8*disp_scan_step)
public double ly_smpl_rms = 0.2; // 1; // Maximal RMS of the remaining tiles in a sample public double ly_smpl_rms = 0.2; // 1; // Maximal RMS of the remaining tiles in a sample
public double ly_disp_var = 0.5; // 2; // Maximal full disparity difference to 8 neighbors public double ly_disp_var = 0.5; // 2; // Maximal full disparity difference to 8 neighbors
public double ly_disp_rvar = 0.02; // Maximal relative full disparity difference to 8 neighbors
public double ly_norm_disp = 5.0; // Reduce weight of higher disparity tiles
public double ly_inf_frac = 0.5; // Relative weight of infinity calibration data 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 (poly or extrinsic) public boolean ly_on_scan = true; // Calculate and apply lazy eye correction after disparity scan (poly or extrinsic)
public boolean ly_inf_en = false; // true; // Simultaneously correct disparity at infinity (both poly and extrinsic) public boolean ly_inf_en = false; // true; // Simultaneously correct disparity at infinity (both poly and extrinsic)
public boolean ly_inf_force= false; // Force convergence correction during extrinsic, even with no infinity data public boolean ly_inf_force= false; // Force convergence correction during extrinsic, even with no infinity data
public boolean ly_com_roll= false; // Enable common roll (valid for high disparity range only)
public boolean ly_poly = false; // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor public boolean ly_poly = false; // Use polynomial correction, false - correct tilt/azimuth/roll of each sensor
// Lazy eye multi-step fitting
public double lym_overexp = 0.0001; // Any (near) saturated pixels - discard tile (see sat_level also)
public boolean lym_update_disp = true; // Update target disparity after each step
public int lym_iter = 25; // Maximal number of iterations
public double lym_change = 1e-5; // Parameter vector difference to exit 4e-6 - OK
public double lym_poly_change = 0.002; // Parameter vector difference to exit from polynomial correction
public boolean lyf_filter = true; // Filter lazy eye pairs by their values public boolean lyf_filter = true; // Filter lazy eye pairs by their values
public int lyf_smpl_side = 8; // 8 x8 masked, 16x16 sampled public int lyf_smpl_side = 8; // 8 x8 masked, 16x16 sampled
public double lyf_rms_max = 0.25; // Maximal RMS (all components to components average) public double lyf_rms_max = 0.25; // Maximal RMS (all components to components average)
...@@ -2537,6 +2597,7 @@ public class EyesisCorrectionParameters { ...@@ -2537,6 +2597,7 @@ public class EyesisCorrectionParameters {
public boolean dbg_migrate = true; public boolean dbg_migrate = true;
// other debug images // other debug images
public boolean show_extrinsic = false; // show extrinsic adjustment differences
public boolean show_ortho_combine = false; // Show 'ortho_combine' public boolean show_ortho_combine = false; // Show 'ortho_combine'
public boolean show_refine_supertiles = false; // show 'refine_disparity_supertiles' public boolean show_refine_supertiles = false; // show 'refine_disparity_supertiles'
public boolean show_bgnd_nonbgnd = false; // show 'bgnd_nonbgnd' public boolean show_bgnd_nonbgnd = false; // show 'bgnd_nonbgnd'
...@@ -2574,6 +2635,10 @@ public class EyesisCorrectionParameters { ...@@ -2574,6 +2635,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"norm_kern", this.norm_kern+""); properties.setProperty(prefix+"norm_kern", this.norm_kern+"");
properties.setProperty(prefix+"gain_equalize", this.gain_equalize+""); properties.setProperty(prefix+"gain_equalize", this.gain_equalize+"");
properties.setProperty(prefix+"colors_equalize", this.colors_equalize+""); properties.setProperty(prefix+"colors_equalize", this.colors_equalize+"");
properties.setProperty(prefix+"nosat_equalize",this.nosat_equalize+"");
properties.setProperty(prefix+"sat_level", this.sat_level+"");
properties.setProperty(prefix+"max_overexposure", this.max_overexposure+"");
properties.setProperty(prefix+"novignetting_r", this.novignetting_r+""); properties.setProperty(prefix+"novignetting_r", this.novignetting_r+"");
properties.setProperty(prefix+"novignetting_g", this.novignetting_g+""); properties.setProperty(prefix+"novignetting_g", this.novignetting_g+"");
properties.setProperty(prefix+"novignetting_b", this.novignetting_b+""); properties.setProperty(prefix+"novignetting_b", this.novignetting_b+"");
...@@ -2684,11 +2749,20 @@ public class EyesisCorrectionParameters { ...@@ -2684,11 +2749,20 @@ public class EyesisCorrectionParameters {
// properties.setProperty(prefix+"ly_meas_disp", this.ly_meas_disp +""); // properties.setProperty(prefix+"ly_meas_disp", this.ly_meas_disp +"");
properties.setProperty(prefix+"ly_smpl_rms", this.ly_smpl_rms +""); properties.setProperty(prefix+"ly_smpl_rms", this.ly_smpl_rms +"");
properties.setProperty(prefix+"ly_disp_var", this.ly_disp_var +""); properties.setProperty(prefix+"ly_disp_var", this.ly_disp_var +"");
properties.setProperty(prefix+"ly_disp_rvar", this.ly_disp_rvar +"");
properties.setProperty(prefix+"ly_norm_disp", this.ly_norm_disp +"");
properties.setProperty(prefix+"ly_inf_frac", this.ly_inf_frac +""); properties.setProperty(prefix+"ly_inf_frac", this.ly_inf_frac +"");
properties.setProperty(prefix+"ly_on_scan", this.ly_on_scan+""); properties.setProperty(prefix+"ly_on_scan", this.ly_on_scan+"");
properties.setProperty(prefix+"ly_inf_en", this.ly_inf_en+""); properties.setProperty(prefix+"ly_inf_en", this.ly_inf_en+"");
properties.setProperty(prefix+"ly_inf_force", this.ly_inf_force+""); properties.setProperty(prefix+"ly_inf_force", this.ly_inf_force+"");
properties.setProperty(prefix+"ly_com_roll", this.ly_com_roll+"");
properties.setProperty(prefix+"ly_poly", this.ly_poly+""); properties.setProperty(prefix+"ly_poly", this.ly_poly+"");
properties.setProperty(prefix+"lym_overexp", this.lym_overexp +"");
properties.setProperty(prefix+"lym_update_disp", this.lym_update_disp+"");
properties.setProperty(prefix+"lym_iter", this.lym_iter+"");
properties.setProperty(prefix+"lym_change", this.lym_change +"");
properties.setProperty(prefix+"lym_poly_change", this.lym_poly_change +"");
properties.setProperty(prefix+"lyf_filter", this.lyf_filter+""); properties.setProperty(prefix+"lyf_filter", this.lyf_filter+"");
properties.setProperty(prefix+"lyf_smpl_side", this.lyf_smpl_side+""); properties.setProperty(prefix+"lyf_smpl_side", this.lyf_smpl_side+"");
...@@ -3124,6 +3198,7 @@ public class EyesisCorrectionParameters { ...@@ -3124,6 +3198,7 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"dbg_migrate", this.dbg_migrate+""); properties.setProperty(prefix+"dbg_migrate", this.dbg_migrate+"");
properties.setProperty(prefix+"show_extrinsic", this.show_extrinsic+"");
properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+""); properties.setProperty(prefix+"show_ortho_combine", this.show_ortho_combine+"");
properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+""); properties.setProperty(prefix+"show_refine_supertiles", this.show_refine_supertiles+"");
properties.setProperty(prefix+"show_bgnd_nonbgnd", this.show_bgnd_nonbgnd+""); properties.setProperty(prefix+"show_bgnd_nonbgnd", this.show_bgnd_nonbgnd+"");
...@@ -3162,6 +3237,10 @@ public class EyesisCorrectionParameters { ...@@ -3162,6 +3237,10 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"norm_kern")!=null) this.norm_kern=Boolean.parseBoolean(properties.getProperty(prefix+"norm_kern")); if (properties.getProperty(prefix+"norm_kern")!=null) this.norm_kern=Boolean.parseBoolean(properties.getProperty(prefix+"norm_kern"));
if (properties.getProperty(prefix+"gain_equalize")!=null) this.gain_equalize=Boolean.parseBoolean(properties.getProperty(prefix+"gain_equalize")); if (properties.getProperty(prefix+"gain_equalize")!=null) this.gain_equalize=Boolean.parseBoolean(properties.getProperty(prefix+"gain_equalize"));
if (properties.getProperty(prefix+"colors_equalize")!=null)this.colors_equalize=Boolean.parseBoolean(properties.getProperty(prefix+"colors_equalize")); if (properties.getProperty(prefix+"colors_equalize")!=null)this.colors_equalize=Boolean.parseBoolean(properties.getProperty(prefix+"colors_equalize"));
if (properties.getProperty(prefix+"nosat_equalize")!=null)this.nosat_equalize=Boolean.parseBoolean(properties.getProperty(prefix+"nosat_equalize"));
if (properties.getProperty(prefix+"sat_level")!=null) this.sat_level=Double.parseDouble(properties.getProperty(prefix+"sat_level"));
if (properties.getProperty(prefix+"max_overexposure")!=null)this.max_overexposure=Double.parseDouble(properties.getProperty(prefix+"max_overexposure"));
if (properties.getProperty(prefix+"novignetting_r")!=null) this.novignetting_r=Double.parseDouble(properties.getProperty(prefix+"novignetting_r")); if (properties.getProperty(prefix+"novignetting_r")!=null) this.novignetting_r=Double.parseDouble(properties.getProperty(prefix+"novignetting_r"));
if (properties.getProperty(prefix+"novignetting_g")!=null) this.novignetting_g=Double.parseDouble(properties.getProperty(prefix+"novignetting_g")); if (properties.getProperty(prefix+"novignetting_g")!=null) this.novignetting_g=Double.parseDouble(properties.getProperty(prefix+"novignetting_g"));
if (properties.getProperty(prefix+"novignetting_b")!=null) this.novignetting_b=Double.parseDouble(properties.getProperty(prefix+"novignetting_b")); if (properties.getProperty(prefix+"novignetting_b")!=null) this.novignetting_b=Double.parseDouble(properties.getProperty(prefix+"novignetting_b"));
...@@ -3272,12 +3351,21 @@ public class EyesisCorrectionParameters { ...@@ -3272,12 +3351,21 @@ public class EyesisCorrectionParameters {
// 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_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_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_disp_var")!=null) this.ly_disp_var=Double.parseDouble(properties.getProperty(prefix+"ly_disp_var"));
if (properties.getProperty(prefix+"ly_disp_rvar")!=null) this.ly_disp_rvar=Double.parseDouble(properties.getProperty(prefix+"ly_disp_rvar"));
if (properties.getProperty(prefix+"ly_norm_disp")!=null) this.ly_norm_disp=Double.parseDouble(properties.getProperty(prefix+"ly_norm_disp"));
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_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_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+"ly_inf_en")!=null) this.ly_inf_en=Boolean.parseBoolean(properties.getProperty(prefix+"ly_inf_en"));
if (properties.getProperty(prefix+"ly_inf_force")!=null) this.ly_inf_force=Boolean.parseBoolean(properties.getProperty(prefix+"ly_inf_force")); if (properties.getProperty(prefix+"ly_inf_force")!=null) this.ly_inf_force=Boolean.parseBoolean(properties.getProperty(prefix+"ly_inf_force"));
if (properties.getProperty(prefix+"ly_com_roll")!=null) this.ly_com_roll=Boolean.parseBoolean(properties.getProperty(prefix+"ly_com_roll"));
if (properties.getProperty(prefix+"ly_poly")!=null) this.ly_poly=Boolean.parseBoolean(properties.getProperty(prefix+"ly_poly")); if (properties.getProperty(prefix+"ly_poly")!=null) this.ly_poly=Boolean.parseBoolean(properties.getProperty(prefix+"ly_poly"));
if (properties.getProperty(prefix+"lym_overexp")!=null) this.lym_overexp=Double.parseDouble(properties.getProperty(prefix+"lym_overexp"));
if (properties.getProperty(prefix+"lym_update_disp")!=null) this.lym_update_disp=Boolean.parseBoolean(properties.getProperty(prefix+"lym_update_disp"));
if (properties.getProperty(prefix+"lym_iter")!=null) this.lym_iter=Integer.parseInt(properties.getProperty(prefix+"lym_iter"));
if (properties.getProperty(prefix+"lym_change")!=null) this.lym_change=Double.parseDouble(properties.getProperty(prefix+"lym_change"));
if (properties.getProperty(prefix+"lym_poly_change")!=null) this.lym_poly_change=Double.parseDouble(properties.getProperty(prefix+"lym_poly_change"));
if (properties.getProperty(prefix+"lyf_filter")!=null) this.lyf_filter=Boolean.parseBoolean(properties.getProperty(prefix+"lyf_filter")); if (properties.getProperty(prefix+"lyf_filter")!=null) this.lyf_filter=Boolean.parseBoolean(properties.getProperty(prefix+"lyf_filter"));
if (properties.getProperty(prefix+"lyf_smpl_side")!=null) this.lyf_smpl_side=Integer.parseInt(properties.getProperty(prefix+"lyf_smpl_side")); if (properties.getProperty(prefix+"lyf_smpl_side")!=null) this.lyf_smpl_side=Integer.parseInt(properties.getProperty(prefix+"lyf_smpl_side"));
if (properties.getProperty(prefix+"lyf_rms_max")!=null) this.lyf_rms_max=Double.parseDouble(properties.getProperty(prefix+"lyf_rms_max")); if (properties.getProperty(prefix+"lyf_rms_max")!=null) this.lyf_rms_max=Double.parseDouble(properties.getProperty(prefix+"lyf_rms_max"));
...@@ -3711,6 +3799,7 @@ public class EyesisCorrectionParameters { ...@@ -3711,6 +3799,7 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"dbg_migrate")!=null) this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate")); if (properties.getProperty(prefix+"dbg_migrate")!=null) this.dbg_migrate=Boolean.parseBoolean(properties.getProperty(prefix+"dbg_migrate"));
if (properties.getProperty(prefix+"show_extrinsic")!=null) this.show_extrinsic=Boolean.parseBoolean(properties.getProperty(prefix+"show_extrinsic"));
if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine")); if (properties.getProperty(prefix+"show_ortho_combine")!=null) this.show_ortho_combine=Boolean.parseBoolean(properties.getProperty(prefix+"show_ortho_combine"));
if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles")); if (properties.getProperty(prefix+"show_refine_supertiles")!=null) this.show_refine_supertiles=Boolean.parseBoolean(properties.getProperty(prefix+"show_refine_supertiles"));
if (properties.getProperty(prefix+"show_bgnd_nonbgnd")!=null) this.show_bgnd_nonbgnd=Boolean.parseBoolean(properties.getProperty(prefix+"show_bgnd_nonbgnd")); if (properties.getProperty(prefix+"show_bgnd_nonbgnd")!=null) this.show_bgnd_nonbgnd=Boolean.parseBoolean(properties.getProperty(prefix+"show_bgnd_nonbgnd"));
...@@ -3751,9 +3840,13 @@ public class EyesisCorrectionParameters { ...@@ -3751,9 +3840,13 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Modify phase correlation to prevent division by very small numbers", this.fat_zero, 4); gd.addNumericField("Modify phase correlation to prevent division by very small numbers", this.fat_zero, 4);
gd.addNumericField("LPF correlarion sigma ", this.corr_sigma, 3); gd.addNumericField("LPF correlarion sigma ", this.corr_sigma, 3);
gd.addCheckbox ("Normalize kernels ", this.norm_kern); gd.addCheckbox ("Normalize kernels ", this.norm_kern);
gd.addCheckbox ("Equalize green channel gain of the individual cnannels", this.gain_equalize); gd.addCheckbox ("Equalize green channel gain of the individual cnannels (bug fix for exposure)", this.gain_equalize);
gd.addCheckbox ("Equalize R/G, B/G balance of the individual channels", this.colors_equalize); gd.addCheckbox ("Equalize R/G, B/G balance of the individual channels", this.colors_equalize);
gd.addNumericField("Reg gain in the center of sensor calibration R (instead of vignetting)", this.novignetting_r, 4); gd.addCheckbox ("Skip saturated when adjusting gains", this.nosat_equalize);
gd.addNumericField("Saturation level of the most saturated color channel", this.sat_level, 4);
gd.addNumericField("Do not use tiles with higher fraction of (near) saturated tiles", this.max_overexposure, 4);
gd.addNumericField("Red gain in the center of sensor calibration R (instead of vignetting)", this.novignetting_r, 4);
gd.addNumericField("Green gain in the center of sensor calibration G (instead of vignetting)",this.novignetting_g, 4); gd.addNumericField("Green gain in the center of sensor calibration G (instead of vignetting)",this.novignetting_g, 4);
gd.addNumericField("Blue gain in the center of sensor calibration B (instead of vignetting)", this.novignetting_b, 4); gd.addNumericField("Blue gain in the center of sensor calibration B (instead of vignetting)", this.novignetting_b, 4);
gd.addNumericField("Extra red correction to compensate for light temperature", this.scale_r, 4); gd.addNumericField("Extra red correction to compensate for light temperature", this.scale_r, 4);
...@@ -3874,13 +3967,23 @@ public class EyesisCorrectionParameters { ...@@ -3874,13 +3967,23 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Number after removing worst (should be >1)", this.ly_smpl_num, 0); gd.addNumericField("Number after removing worst (should be >1)", this.ly_smpl_num, 0);
gd.addMessage ("Maximal measured relative disparity = "+ (0.8*disp_scan_step)+" (0.8 * disp_scan_step)"); gd.addMessage ("Maximal measured relative disparity = "+ (0.8*disp_scan_step)+" (0.8 * disp_scan_step)");
// gd.addNumericField("Maximal measured relative disparity", this.ly_meas_disp, 3); // 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 RMS of the remaining tiles in a sample", this.ly_smpl_rms, 5);
gd.addNumericField("Maximal full disparity difference to 8 neighbors", this.ly_disp_var, 3); gd.addNumericField("Maximal full disparity difference to 8 neighbors", this.ly_disp_var, 5);
gd.addNumericField("Maximal relative full disparity difference to 8 neighbors", this.ly_disp_rvar, 5);
gd.addNumericField("Reduce weight of higher disparity tiles", this.ly_norm_disp, 5);
gd.addNumericField("Relative weight of infinity calibration data", this.ly_inf_frac, 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 (poly or extrinsic), may repeat",this.ly_on_scan); gd.addCheckbox ("Calculate and apply lazy eye correction after disparity scan (poly or extrinsic), may repeat",this.ly_on_scan);
gd.addCheckbox ("Use infinity disparity (disable if there is not enough of infinity data), both poly and extrinsic", this.ly_inf_en); gd.addCheckbox ("Use infinity disparity (disable if there is not enough of infinity data), both poly and extrinsic", this.ly_inf_en);
gd.addCheckbox ("Force convergence correction during extrinsic, even with no infinity data", this.ly_inf_force); gd.addCheckbox ("Force convergence correction during extrinsic, even with no infinity data", this.ly_inf_force);
gd.addCheckbox ("Enable common roll adjustment (valid for high disparity range scans only)", this.ly_com_roll);
gd.addCheckbox ("*Use polynomial correction, false - correct tilt/azimuth/roll of each sensor)", this.ly_poly); gd.addCheckbox ("*Use polynomial correction, false - correct tilt/azimuth/roll of each sensor)", this.ly_poly);
gd.addMessage ("--- Lazy eye multi-step fitting ---");
gd.addNumericField("Any (near) saturated pixels - discard tile (see sat_level also)", this.lym_overexp, 10);
gd.addCheckbox ("Update target disparity after each step", this.lym_update_disp);
gd.addNumericField("Maximal number of iterations", this.lym_iter, 0);
gd.addNumericField("Parameter vector difference to exit", this.lym_change, 10);
gd.addNumericField("Parameter vector difference to exit from polynomial correction", this.lym_poly_change, 10);
gd.addMessage ("--- Lazy eye samples filter ---"); gd.addMessage ("--- Lazy eye samples filter ---");
gd.addCheckbox ("Filter lazy eye pairs by their values", this.lyf_filter); gd.addCheckbox ("Filter lazy eye pairs by their values", this.lyf_filter);
...@@ -4351,6 +4454,7 @@ public class EyesisCorrectionParameters { ...@@ -4351,6 +4454,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Test new mode after migration", this.dbg_migrate); gd.addCheckbox ("Test new mode after migration", this.dbg_migrate);
gd.addMessage ("--- Other debug images ---"); gd.addMessage ("--- Other debug images ---");
gd.addCheckbox ("Show extrinsic adjustment differences", this.show_extrinsic);
gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine); gd.addCheckbox ("Show 'ortho_combine'", this.show_ortho_combine);
gd.addCheckbox ("Show 'refine_disparity_supertiles'", this.show_refine_supertiles); gd.addCheckbox ("Show 'refine_disparity_supertiles'", this.show_refine_supertiles);
gd.addCheckbox ("Show 'bgnd_nonbgnd'", this.show_bgnd_nonbgnd); gd.addCheckbox ("Show 'bgnd_nonbgnd'", this.show_bgnd_nonbgnd);
...@@ -4389,6 +4493,10 @@ public class EyesisCorrectionParameters { ...@@ -4389,6 +4493,10 @@ public class EyesisCorrectionParameters {
this.norm_kern= gd.getNextBoolean(); this.norm_kern= gd.getNextBoolean();
this.gain_equalize= gd.getNextBoolean(); this.gain_equalize= gd.getNextBoolean();
this.colors_equalize= gd.getNextBoolean(); this.colors_equalize= gd.getNextBoolean();
this.nosat_equalize= gd.getNextBoolean();
this.sat_level= gd.getNextNumber();
this.max_overexposure= gd.getNextNumber();
this.novignetting_r= gd.getNextNumber(); this.novignetting_r= gd.getNextNumber();
this.novignetting_g= gd.getNextNumber(); this.novignetting_g= gd.getNextNumber();
this.novignetting_b= gd.getNextNumber(); this.novignetting_b= gd.getNextNumber();
...@@ -4502,11 +4610,20 @@ public class EyesisCorrectionParameters { ...@@ -4502,11 +4610,20 @@ public class EyesisCorrectionParameters {
// this.ly_meas_disp= gd.getNextNumber(); // this.ly_meas_disp= gd.getNextNumber();
this.ly_smpl_rms= gd.getNextNumber(); this.ly_smpl_rms= gd.getNextNumber();
this.ly_disp_var= gd.getNextNumber(); this.ly_disp_var= gd.getNextNumber();
this.ly_disp_rvar= gd.getNextNumber();
this.ly_norm_disp= gd.getNextNumber();
this.ly_inf_frac= gd.getNextNumber(); this.ly_inf_frac= gd.getNextNumber();
this.ly_on_scan= gd.getNextBoolean(); this.ly_on_scan= gd.getNextBoolean();
this.ly_inf_en= gd.getNextBoolean(); this.ly_inf_en= gd.getNextBoolean();
this.ly_inf_force= gd.getNextBoolean(); this.ly_inf_force= gd.getNextBoolean();
this.ly_com_roll= gd.getNextBoolean();
this.ly_poly= gd.getNextBoolean(); this.ly_poly= gd.getNextBoolean();
this.lym_overexp= gd.getNextNumber();
this.lym_update_disp= gd.getNextBoolean();
this.lym_iter= (int) gd.getNextNumber();
this.lym_change= gd.getNextNumber();
this.lym_poly_change= gd.getNextNumber();
this.lyf_filter= gd.getNextBoolean(); this.lyf_filter= gd.getNextBoolean();
this.lyf_smpl_side= (int) gd.getNextNumber(); this.lyf_smpl_side= (int) gd.getNextNumber();
...@@ -4946,6 +5063,7 @@ public class EyesisCorrectionParameters { ...@@ -4946,6 +5063,7 @@ public class EyesisCorrectionParameters {
this.dbg_migrate= gd.getNextBoolean(); this.dbg_migrate= gd.getNextBoolean();
this.show_extrinsic= gd.getNextBoolean();
this.show_ortho_combine= gd.getNextBoolean(); this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean(); this.show_refine_supertiles=gd.getNextBoolean();
this.show_bgnd_nonbgnd= gd.getNextBoolean(); // first on second pass this.show_bgnd_nonbgnd= gd.getNextBoolean(); // first on second pass
......
...@@ -78,7 +78,8 @@ private Panel panel1, ...@@ -78,7 +78,8 @@ private Panel panel1,
panelPostProcessing3, panelPostProcessing3,
panelDct1, panelDct1,
panelClt1, panelClt1,
panelClt2 panelClt2,
panelClt3
; ;
JP46_Reader_camera JP4_INSTANCE=null; JP46_Reader_camera JP4_INSTANCE=null;
...@@ -370,7 +371,7 @@ private Panel panel1, ...@@ -370,7 +371,7 @@ private Panel panel1,
instance = this; instance = this;
addKeyListener(IJ.getInstance()); addKeyListener(IJ.getInstance());
int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?3:0); int menuRows=4 + (ADVANCED_MODE?4:0) + (MODE_3D?3:0) + (DCT_MODE?4:0);
setLayout(new GridLayout(menuRows, 1)); setLayout(new GridLayout(menuRows, 1));
panel6 = new Panel(); panel6 = new Panel();
...@@ -518,16 +519,6 @@ private Panel panel1, ...@@ -518,16 +519,6 @@ private Panel panel1,
panelClt2 = new Panel(); panelClt2 = new Panel();
panelClt2.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap panelClt2.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT parameters", panelClt2, color_configure); addButton("Setup CLT parameters", panelClt2, color_configure);
// addButton("Select CLT image", panelClt2, color_configure);
// addButton("CLT stack", panelClt2, color_process);
// addButton("Select second CLT image", panelClt2, color_configure);
// addButton("CLT correlate", panelClt2, color_process);
// addButton("Create CLT kernels", panelClt2, color_process);
// addButton("Read CLT kernels", panelClt2, color_process);
// addButton("Reset CLT kernels", panelClt2, color_stop);
// addButton("CLT process files", panelClt2, color_process);
// addButton("CLT process sets", panelClt2, color_process);
// addButton("CLT process quads", panelClt2, color_process);
addButton("CLT 4 images", panelClt2, color_conf_process); addButton("CLT 4 images", panelClt2, color_conf_process);
addButton("CLT disparity scan", panelClt2, color_conf_process); addButton("CLT disparity scan", panelClt2, color_conf_process);
addButton("CLT reset fine corr", panelClt2, color_stop); addButton("CLT reset fine corr", panelClt2, color_stop);
...@@ -539,6 +530,8 @@ private Panel panel1, ...@@ -539,6 +530,8 @@ private Panel panel1,
addButton("CLT infinity corr", panelClt2, color_conf_process); addButton("CLT infinity corr", panelClt2, color_conf_process);
addButton("CLT ext infinity corr", panelClt2, color_conf_process); addButton("CLT ext infinity corr", panelClt2, color_conf_process);
addButton("CLT reset 3D", panelClt2, color_stop); addButton("CLT reset 3D", panelClt2, color_stop);
addButton("CLT Extrinsics", panelClt2, color_process);
addButton("CLT Poly corr", panelClt2, color_process);
addButton("CLT 3D", panelClt2, color_process); addButton("CLT 3D", panelClt2, color_process);
addButton("CLT planes", panelClt2, color_conf_process); addButton("CLT planes", panelClt2, color_conf_process);
addButton("CLT ASSIGN", panelClt2, color_process); addButton("CLT ASSIGN", panelClt2, color_process);
...@@ -546,6 +539,14 @@ private Panel panel1, ...@@ -546,6 +539,14 @@ private Panel panel1,
add(panelClt2); add(panelClt2);
} }
if (DCT_MODE) {
panelClt3 = new Panel();
panelClt3.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Setup CLT Batch parameters", panelClt3, color_configure);
addButton("Setup CLT parameters", panelClt3, color_configure);
addButton("CLT Batch process", panelClt3, color_process);
add(panelClt3);
}
pack(); pack();
GUI.center(this); GUI.center(this);
...@@ -3667,6 +3668,12 @@ private Panel panel1, ...@@ -3667,6 +3668,12 @@ private Panel panel1,
// EyesisCorrectionParameters.DCTParameters dCTParameters, // EyesisCorrectionParameters.DCTParameters dCTParameters,
// int srcKernelSize, // int srcKernelSize,
EYESIS_DCT.showKernels(); // show restored kernels EYESIS_DCT.showKernels(); // show restored kernels
/* ======================================================================== */
} else if (label.equals("Setup CLT Batch parameters")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
CORRECTION_PARAMETERS.showCLTDialog("CLT Batch parameters");
return;
/* ======================================================================== */ /* ======================================================================== */
} else if (label.equals("Setup CLT parameters")) { } else if (label.equals("Setup CLT parameters")) {
CLT_PARAMETERS.showDialog(); CLT_PARAMETERS.showDialog();
...@@ -4762,7 +4769,9 @@ private Panel panel1, ...@@ -4762,7 +4769,9 @@ private Panel panel1,
/// ============================================ /// ============================================
} else if (label.equals("CLT 3D")) { } else if (label.equals("CLT 3D") || label.equals("CLT Extrinsics") || label.equals("CLT Poly corr")) {
boolean adjust_extrinsics = label.equals("CLT Extrinsics") || label.equals("CLT Poly corr");
boolean adjust_poly = label.equals("CLT Poly corr");
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL); EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){ if (QUAD_CLT == null){
...@@ -4834,6 +4843,8 @@ private Panel panel1, ...@@ -4834,6 +4843,8 @@ private Panel panel1,
} }
QUAD_CLT.processCLTQuads3d( QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters, CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters, DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters, NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
......
...@@ -111,6 +111,15 @@ public class GeometryCorrection { ...@@ -111,6 +111,15 @@ public class GeometryCorrection {
extrinsic_corr = vector; extrinsic_corr = vector;
} }
public boolean [] getParMask(
boolean use_disparity,
boolean common_roll)
{
return (new CorrVector()).getParMask(
use_disparity,
common_roll);
}
public class CorrVector{ public class CorrVector{
...@@ -208,10 +217,15 @@ public class GeometryCorrection { ...@@ -208,10 +217,15 @@ public class GeometryCorrection {
s = String.format("tilt (up): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[0], v[1], v[2], -(v[0] + v[1] + v[2]) ); s = String.format("tilt (up): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[0], v[1], v[2], -(v[0] + v[1] + v[2]) );
s += String.format("azimuth (right): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[3], v[4], v[5], -(v[3] + v[4] + v[5]) ); s += String.format("azimuth (right): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[3], v[4], v[5], -(v[3] + v[4] + v[5]) );
s += String.format("roll (CW): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[6], v[7], v[8], v[9] ); s += String.format("roll (CW): %8.5f° %8.5f° %8.5f° %8.5f°\n" , v[6], v[7], v[8], v[9] );
s += "Symmetrical vector first 5 as last 4 (rolls) are the same:\n"; s += "Symmetrical vector:\n";
s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘|\n"; s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘| 6: common roll 7:(r0-r3)/2, \n";
s += "0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖|\n"; s += "0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖| 8:(r1-r2)/2 9:(r0+r3-r1-r2)/4\n";
s += String.format("0: %8.5f° 1:%8.5f° 2:%8.5f° 3:%8.5f° 4:%8.5f° 5:%8.5f°\n" , sv[0], sv[1], sv[2], sv[3], sv[4], sv[5]); s += String.format("0: %8.5f° 1:%8.5f° 2:%8.5f° 3:%8.5f° 4:%8.5f° 5:%8.5f° 6:%8.5f° 7:%8.5f° 8:%8.5f° 9:%8.5f°\n" ,
sv[0], sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7], sv[8], sv[9] );
// s += String.format("sym_vect: 0: %10.7f 1:%10.7f 2:%10.7f 3:%10.7f 4:%10.7f 5:%10.7f 6:%10.7f 7:%10.7f 8:%10.7f 9:%10.7f\n" ,
// sym_vect[0], sym_vect[1], sym_vect[2], sym_vect[3], sym_vect[4], sym_vect[5], sym_vect[6], sym_vect[7], sym_vect[8], sym_vect[9] );
// s += String.format("vector: 0: %10.7f 1:%10.7f 2:%10.7f 3:%10.7f 4:%10.7f 5:%10.7f 6:%10.7f 7:%10.7f 8:%10.7f 9:%10.7f\n" ,
// vector[0], vector[1], vector[2], vector[3], vector[4], vector[5], vector[6], vector[7], vector[8], vector[9] );
return s; return s;
} }
...@@ -244,18 +258,22 @@ public class GeometryCorrection { ...@@ -244,18 +258,22 @@ public class GeometryCorrection {
{ {
//Previous does not consider movement of the 4-th sensor, so t3 = -t0+t1+t2), a3 = -(a0+a1+a2) //Previous does not consider movement of the 4-th sensor, so t3 = -t0+t1+t2), a3 = -(a0+a1+a2)
double [][] tar_to_sym = { double [][] tar_to_sym = {
{-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0 {-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0
{-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t1 {-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t1
{ 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t2 { 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0}, // t2
{ 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // a0 { 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // a0
{ 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a1 { 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a1
{ 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a2 { 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0}, // a2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // roll 0 // { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // roll 0
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // roll 1 // { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // roll 1
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // roll 2 // { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // roll 2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}};// roll 3 // { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}};// roll 3
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.0, 0.25}, // roll 0
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.5, -0.25}, // roll 1
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, -0.5, -0.25}, // roll 2
{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, -0.5, 0.0, 0.25}};// roll 3
return tar_to_sym; return tar_to_sym;
} }
...@@ -289,6 +307,29 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0. ...@@ -289,6 +307,29 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. ]]) [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 1. ]])
a=[[-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[-2.0, 0.0, 0.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, -2.0, 2.0, 0.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0],
[ 2.0, 2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, 2.0, 2.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0],
[ 2.0, 0.0, 0.0, -2.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.0, 0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.5, -0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, -0.5, -0.25],
[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, -0.5, 0.0, 0.25]]
matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. , -0. ],
[-0.125, 0.125, -0.125, 0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[ 0.125, -0.125, 0.125, 0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[-0.125, -0.125, 0.125, -0.125, 0.125, -0.125, 0. , 0. , 0. , 0. ],
[-0.125, 0.125, 0.125, -0.125, 0.125, 0.125, 0. , 0. , 0. , 0. ],
[ 0.125, -0.125, -0.125, -0.125, 0.125, 0.125, 0. , 0. , 0. , 0. ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 1. , 1. , 1. , 1. ],
[-0. , -0. , -0. , -0. , -0. , -0. , 1. , -0. , -0. , -1. ],
[-0. , -0. , -0. , -0. , -0. , -0. , -0. , 1. , -1. , -0. ],
[-0. , -0. , -0. , -0. , -0. , -0. , 1. , -1. , -1. , 1. ]])
*/ */
double [][] sym_to_tar= { double [][] sym_to_tar= {
// t0 t1 t2 a0 a1 a2 r0 r1 r2 r3 // t0 t1 t2 a0 a1 a2 r0 r1 r2 r3
...@@ -298,12 +339,38 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0. ...@@ -298,12 +339,38 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
{-0.125, -0.125, 0.125, -0.125, 0.125, -0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym3 {-0.125, -0.125, 0.125, -0.125, 0.125, -0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym3
{-0.125, 0.125, 0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym4 {-0.125, 0.125, 0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym4
{ 0.125, -0.125, -0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym5 { 0.125, -0.125, -0.125, -0.125, 0.125, 0.125, 0.0 , 0.0 , 0.0 , 0.0 }, // sym5
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 }, // sym6 = r0 // { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 }, // sym6 = r0
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 }, // sym7 = r1 // { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 }, // sym7 = r1
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 }, // sym8 = r2 // { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 }, // sym8 = r2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 }}; // sym9 = r3 // { 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 }}; // sym9 = r3
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 1.0 , 1.0 , 1.0 }, // sym6 = (r0+r1+r2+r3)/4
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , -1.0 }, // sym7 = (r0-r3)/2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , -1.0 , 0.0 }, // sym8 = (r1-r2)/2
{ 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1.0 , -1.0 , -1.0 , 1.0 }}; // sym9 = (r0+r3-r1-r2)/4
return sym_to_tar; return sym_to_tar;
} }
public boolean [] getParMask(
boolean use_disparity,
boolean common_roll)
{
boolean [] par_mask = { // TODO: move to GeometryCorrection
use_disparity, //sym0
true, //sym1
true, //sym2
true, //sym3
true, //sym4
true, //sym5
common_roll, //sym6 // common roll
true, //sym7
true, //sym8
true //sym9
};
return par_mask;
}
/** /**
* Get partial transposed Jacobian as 2d array (for one measurement set) from partial Jacobian for each sample * Get partial transposed Jacobian as 2d array (for one measurement set) from partial Jacobian for each sample
* with derivatives of port coordinates (all 4) by 3 tilts (ports 0..2), 3 azimuths (ports 0..2) and all 4 rolls * with derivatives of port coordinates (all 4) by 3 tilts (ports 0..2), 3 azimuths (ports 0..2) and all 4 rolls
...@@ -385,11 +452,11 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0. ...@@ -385,11 +452,11 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, 0. , -0. , -0.
} }
return tar_array; return tar_array;
} }
} }
public void setDistortion( public void setDistortion(
double focalLength, double focalLength,
double distortionC, double distortionC,
......
...@@ -50,6 +50,7 @@ public class ImageDtt { ...@@ -50,6 +50,7 @@ public class ImageDtt {
// public static int FORCE_DISPARITY_BIT = 8; // move to parameters? // public static int FORCE_DISPARITY_BIT = 8; // move to parameters?
static int QUAD = 4; // number of cameras in camera static int QUAD = 4; // number of cameras in camera
static int GREEN_CHN = 2; // index of green channel
static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho static int DISPARITY_INDEX_INT = 0; // 0 - disparity from correlation integer pixels, 1 - ortho
static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction) static int DISPARITY_INDEX_CM = 2; // 2 - disparity from correlation "center mass", 3 - ortho (only used for fine correction)
static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed static int DISPARITY_INDEX_HOR = 4; // disparity from correlation of the horizontal pairs with center suppressed
...@@ -60,9 +61,10 @@ public class ImageDtt { ...@@ -60,9 +61,10 @@ public class ImageDtt {
static int DISPARITY_STRENGTH_INDEX = 10; // index of strength data in disparity map ==6 static int DISPARITY_STRENGTH_INDEX = 10; // index of strength data in disparity map ==6
static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6 static int DISPARITY_VARIATIONS_INDEX = 11; // index of strength data in disparity map ==6
static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map static int IMG_DIFF0_INDEX = 12; // index of noise- normalized image difference for port 0 in disparity map
static int OVEREXPOSED = 16; // index of overexposed fraction of all pixels
static String [] DISPARITY_TITLES = { static String [] DISPARITY_TITLES = {
"int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength", "int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
"poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3"}; "poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp"};
static int TCORR_COMBO_RSLT = 0; // normal combined correlation from all selected pairs (mult/sum) static int TCORR_COMBO_RSLT = 0; // normal combined correlation from all selected pairs (mult/sum)
static int TCORR_COMBO_SUM = 1; // sum of channle correlations from all selected pairs static int TCORR_COMBO_SUM = 1; // sum of channle correlations from all selected pairs
...@@ -773,7 +775,11 @@ public class ImageDtt { ...@@ -773,7 +775,11 @@ public class ImageDtt {
centerY, // centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare ((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
no_deconvolution, no_deconvolution,
transpose); transpose,
// no saturation processing
null, // boolean [] saturation_imp, // (near) saturated pixels or null
null); // int [] overexp_all ) // {number of overexposed, number of all tiles} or null
if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) { if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = {"CC","SC","CS","SS"}; String [] titles = {"CC","SC","CS","SS"};
...@@ -898,7 +904,10 @@ public class ImageDtt { ...@@ -898,7 +904,10 @@ public class ImageDtt {
centersXY[i][1], // centerY, // centersXY[i][1], // centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare ((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
no_deconvolution, no_deconvolution,
transpose); transpose,
// no saturation processing
null, // boolean [] saturation_imp, // (near) saturated pixels or null
null); // int [] overexp_all ) // {number of overexposed, number of all tiles} or null
} }
if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) { if ((globalDebugLevel > 0) && (debug_tileX == tileX) && (debug_tileY == tileY) && (chn == 2)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging? showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
...@@ -956,6 +965,7 @@ public class ImageDtt { ...@@ -956,6 +965,7 @@ public class ImageDtt {
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity final double [][] disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial // correlation results - final and partial
final double [][][][] clt_corr_combo, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate final double [][][][] clt_corr_combo, // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [type][tilesY][tilesX] should be set by caller // [type][tilesY][tilesX] should be set by caller
...@@ -1127,7 +1137,9 @@ public class ImageDtt { ...@@ -1127,7 +1137,9 @@ public class ImageDtt {
} }
if (disparity_map != null){ if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){ for (int i = 0; i<disparity_map.length;i++){
disparity_map[i] = new double [tilesY*tilesX]; if ((i != OVEREXPOSED) || (saturation_imp!= null)){
disparity_map[i] = new double [tilesY*tilesX];
}
} }
} }
if (clt_mismatch != null){ if (clt_mismatch != null){
...@@ -1151,7 +1163,8 @@ public class ImageDtt { ...@@ -1151,7 +1163,8 @@ public class ImageDtt {
sdfa_instance.showArrays(lt_window, 2*transform_size, 2*transform_size, "lt_window"); sdfa_instance.showArrays(lt_window, 2*transform_size, 2*transform_size, "lt_window");
} }
// final double [] overexposed = disparity_map[OVEREXPOSED];
// final int [][] overexp_all = (saturation_imp != null) ? ( new int [tilesX*tilesY][2]): null;
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
...@@ -1182,6 +1195,9 @@ public class ImageDtt { ...@@ -1182,6 +1195,9 @@ public class ImageDtt {
} }
} }
boolean debugTile =(tileX == debug_tileX) && (tileY == debug_tileY); boolean debugTile =(tileX == debug_tileX) && (tileY == debug_tileY);
final int [] overexp_all = (saturation_imp != null) ? ( new int [2]): null;
for (int chn = 0; chn <numcol; chn++) { for (int chn = 0; chn <numcol; chn++) {
centerX = tileX * transform_size + transform_size/2 - shiftX; centerX = tileX * transform_size + transform_size/2 - shiftX;
centerY = tileY * transform_size + transform_size/2 - shiftY; centerY = tileY * transform_size + transform_size/2 - shiftY;
...@@ -1261,7 +1277,6 @@ public class ImageDtt { ...@@ -1261,7 +1277,6 @@ public class ImageDtt {
centersXY[2][0]+"\t"+centersXY[2][1]+"\t"+ centersXY[2][0]+"\t"+centersXY[2][1]+"\t"+
centersXY[3][0]+"\t"+centersXY[3][1]+"\t"); centersXY[3][0]+"\t"+centersXY[3][1]+"\t");
} }
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) {
clt_data[i][chn][tileY][tileX] = new double [4][]; clt_data[i][chn][tileY][tileX] = new double [4][];
...@@ -1281,7 +1296,10 @@ public class ImageDtt { ...@@ -1281,7 +1296,10 @@ public class ImageDtt {
// (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2), // external tile compare // (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2), // external tile compare
no_deconvolution, no_deconvolution,
false); // transpose); false, // ); // transpose);
((saturation_imp != null) ? saturation_imp[i] : null), //final boolean [][] saturation_imp, // (near) saturated pixels or null
((saturation_imp != null) ? overexp_all: null)); // final double [] overexposed)
} }
if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) { if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) {
System.out.println(); System.out.println();
...@@ -1323,6 +1341,11 @@ public class ImageDtt { ...@@ -1323,6 +1341,11 @@ public class ImageDtt {
} }
} }
} }
// calculate overexposed fraction
if (saturation_imp != null) {
disparity_map[OVEREXPOSED][nTile] = (1.0 * overexp_all[0]) / overexp_all[1];
}
// all color channels are done here // all color channels are done here
double extra_disparity = 0.0; // if allowed, shift images extra before trying to combine double extra_disparity = 0.0; // if allowed, shift images extra before trying to combine
if (clt_corr_combo != null){ // not null - calculate correlations if (clt_corr_combo != null){ // not null - calculate correlations
...@@ -3571,7 +3594,10 @@ public class ImageDtt { ...@@ -3571,7 +3594,10 @@ public class ImageDtt {
int debugLevel, int debugLevel,
// boolean bdebug0, // external tile compare // boolean bdebug0, // external tile compare
boolean dbg_no_deconvolution, boolean dbg_no_deconvolution,
boolean dbg_transpose) boolean dbg_transpose,
boolean [] saturation_imp, // (near) saturated pixels or null
int [] overexp_all ) // {number of overexposed, number of all tiles} or null
{ {
boolean use_kernels = (clt_kernels != null) && !dbg_no_deconvolution; boolean use_kernels = (clt_kernels != null) && !dbg_no_deconvolution;
boolean bdebug0 = debugLevel > 0; boolean bdebug0 = debugLevel > 0;
...@@ -3632,6 +3658,39 @@ public class ImageDtt { ...@@ -3632,6 +3658,39 @@ public class ImageDtt {
} }
} }
} }
if ((chn == GREEN_CHN) && (saturation_imp != null)) {
// double overexp_fract = 1.0/(transform_size2 * transform_size2 * QUAD);
// int num_overexp = 0;
//overexp_all
if ((ctile_left >= 0) && (ctile_left < (width - transform_size2)) &&
(ctile_top >= 0) && (ctile_top < (height - transform_size2))) {
for (int i = 0; i < transform_size2; i++){
int indx = (ctile_top + i) * width + ctile_left;
for (int j = 0; j < transform_size2; j++) {
if (saturation_imp[indx++]) {
overexp_all[0] ++;
}
}
}
overexp_all[1] += transform_size2 * transform_size2;
} else { // copy by 1
for (int i = 0; i < transform_size2; i++){
int pi = ctile_top + i;
if (pi < 0) pi &= 1;
else if (pi >= height) pi = height - 2 + (pi & 1);
for (int j = 0; j < transform_size2; j++){
int pj = ctile_left + j;
if (pj < 0) pj &= 1;
else if (pj >= width) pj = width - 2 + (pj & 1);
if (saturation_imp[pi * width + pj]) {
overexp_all[0] ++;
}
}
}
overexp_all[1] += transform_size2 * transform_size2;
}
}
// Fold and transform // Fold and transform
double [][][] fold_coeff = null; double [][][] fold_coeff = null;
if (!dbg_transpose){ if (!dbg_transpose){
......
...@@ -48,6 +48,7 @@ public class MacroCorrelation { ...@@ -48,6 +48,7 @@ public class MacroCorrelation {
tp.superTileSize, // int superTileSize, tp.superTileSize, // int superTileSize,
tp.getMagicScale(), // double scale, tp.getMagicScale(), // double scale,
trusted_correlation, // double trustedCorrelation, trusted_correlation, // double trustedCorrelation,
0.0, // double maxOverexposure,
tp.getThreadsMax()); // int threadsMax) tp.getThreadsMax()); // int threadsMax)
} }
public TileProcessor CLTMacroScan( // perform single pass according to prepared tiles operations and disparity public TileProcessor CLTMacroScan( // perform single pass according to prepared tiles operations and disparity
...@@ -225,6 +226,7 @@ public class MacroCorrelation { ...@@ -225,6 +226,7 @@ public class MacroCorrelation {
macro_scan.tile_op, // per-tile operation bit codes macro_scan.tile_op, // per-tile operation bit codes
macro_scan.disparity, // clt_parameters.disparity, // final double disparity, macro_scan.disparity, // clt_parameters.disparity, // final double disparity,
input_data, // final double [][][] imade_data, // first index - number of image in a quad input_data, // final double [][][] imade_data, // first index - number of image in a quad
null, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial // correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_corr_partial, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate clt_corr_partial, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -35,8 +35,9 @@ public class TileProcessor { ...@@ -35,8 +35,9 @@ public class TileProcessor {
private int tilesX; private int tilesX;
private int tilesY; private int tilesY;
private double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood) private double corr_magic_scale = 0.85; // reported correlation offset vs. actual one (not yet understood)
private double trustedCorrelation = 4.0; // trusted measured disparity difference (before scaling) private double trustedCorrelation = 4.0; // trusted measured disparity difference (before scaling)
private int tileSize = 8; // number of linear pixels in a tile (tile is square tileSize*tileSize) private double maxOverexposure = 0.5;
private int tileSize = 8; // number of linear pixels in a tile (tile is square tileSize*tileSize)
int superTileSize = 8; // number of linear tiles in a super-tile (supertile is square superTileSize*superTileSize tiles int superTileSize = 8; // number of linear tiles in a super-tile (supertile is square superTileSize*superTileSize tiles
// or (superTileSize*tileSize) * (superTileSize*tileSize) pixels, currently 64x64 pixels) // or (superTileSize*tileSize) * (superTileSize*tileSize) pixels, currently 64x64 pixels)
public int threadsMax = 100; // maximal number of frames to run public int threadsMax = 100; // maximal number of frames to run
...@@ -53,6 +54,7 @@ public class TileProcessor { ...@@ -53,6 +54,7 @@ public class TileProcessor {
int superTileSize, int superTileSize,
double scale, double scale,
double trustedCorrelation, double trustedCorrelation,
double maxOverexposure,
int threadsMax) int threadsMax)
{ {
this.tilesX = tilesX; this.tilesX = tilesX;
...@@ -61,6 +63,7 @@ public class TileProcessor { ...@@ -61,6 +63,7 @@ public class TileProcessor {
this.superTileSize = superTileSize; this.superTileSize = superTileSize;
this.corr_magic_scale = scale; this.corr_magic_scale = scale;
this.trustedCorrelation = trustedCorrelation; this.trustedCorrelation = trustedCorrelation;
this.maxOverexposure = maxOverexposure;
this.threadsMax = threadsMax; this.threadsMax = threadsMax;
} }
public int getTilesX() {return tilesX;}; public int getTilesX() {return tilesX;};
...@@ -75,6 +78,14 @@ public class TileProcessor { ...@@ -75,6 +78,14 @@ public class TileProcessor {
{ {
return this.trustedCorrelation; return this.trustedCorrelation;
} }
public void setMaxOverexposure(double maxOverexposure)
{
this.maxOverexposure = maxOverexposure;
}
public double getMaxOverexposure()
{
return this.maxOverexposure;
}
public double getMagicScale() public double getMagicScale()
{ {
return this.corr_magic_scale; return this.corr_magic_scale;
...@@ -373,6 +384,7 @@ public class TileProcessor { ...@@ -373,6 +384,7 @@ public class TileProcessor {
* @param firstPass index of the first pass to use * @param firstPass index of the first pass to use
* @param lastPassPlus1 index plus 1 of the last pass to use * @param lastPassPlus1 index plus 1 of the last pass to use
* @param trustedCorrelation maximal absolute value of measured correlation (no scaling) to trust (may use global trustedCorrelation) * @param trustedCorrelation maximal absolute value of measured correlation (no scaling) to trust (may use global trustedCorrelation)
* @param max_overexposure maximal fraction of (near) overexposed pixels in a tile to discard it
* @param disp_far lowest disparity value to consider (does not apply to max_tried_disparity) * @param disp_far lowest disparity value to consider (does not apply to max_tried_disparity)
* @param disp_near highest disparity value to consider (does not apply to max_tried_disparity) * @param disp_near highest disparity value to consider (does not apply to max_tried_disparity)
* @param minStrength full correlation strength to consider data to be reliable * @param minStrength full correlation strength to consider data to be reliable
...@@ -389,6 +401,7 @@ public class TileProcessor { ...@@ -389,6 +401,7 @@ public class TileProcessor {
final int firstPass, final int firstPass,
final int lastPassPlus1, final int lastPassPlus1,
final double trustedCorrelation, final double trustedCorrelation,
final double max_overexposure,
final double disp_far, // limit results to the disparity range final double disp_far, // limit results to the disparity range
final double disp_near, final double disp_near,
final double minStrength, final double minStrength,
...@@ -477,15 +490,19 @@ public class TileProcessor { ...@@ -477,15 +490,19 @@ public class TileProcessor {
double strength = pass.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][nt]; double strength = pass.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX][nt];
double strength_hor = pass.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH][nt]; double strength_hor = pass.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH][nt];
double strength_vert = pass.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH][nt]; double strength_vert = pass.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH][nt];
double adiff = Math.abs(mdisp);
double adiff_hor = Math.abs(mdisp_hor);
double adiff_vert = Math.abs(mdisp_vert);
if (adiff <= trustedCorrelation){ boolean overexposed = (max_overexposure > 0.0) &&
double disp = mdisp/corr_magic_scale + pass.disparity[ty][tx]; (pass.disparity_map[ImageDtt.OVEREXPOSED] != null) &&
// do not consider tiles over background if they are far and initially identified as background (pass.disparity_map[ImageDtt.OVEREXPOSED][nt] > max_overexposure);
// if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) { if (!overexposed) {
double adiff = Math.abs(mdisp);
double adiff_hor = Math.abs(mdisp_hor);
double adiff_vert = Math.abs(mdisp_vert);
if (adiff <= trustedCorrelation){
double disp = mdisp/corr_magic_scale + pass.disparity[ty][tx];
// do not consider tiles over background if they are far and initially identified as background
// if ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) {
if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){ if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){
if (strength >= minStrength) { if (strength >= minStrength) {
if (!(adiff >= adiff_best)){ // adiff_best == Double.NaN works too if (!(adiff >= adiff_best)){ // adiff_best == Double.NaN works too
...@@ -499,38 +516,39 @@ public class TileProcessor { ...@@ -499,38 +516,39 @@ public class TileProcessor {
} }
} }
} }
// } // }
} }
if (!Double.isNaN(minStrengthHor) && (adiff_hor <= trustedCorrelation)){ if (!Double.isNaN(minStrengthHor) && (adiff_hor <= trustedCorrelation)){
double disp_hor = mdisp_hor/corr_magic_scale + pass.disparity[ty][tx]; double disp_hor = mdisp_hor/corr_magic_scale + pass.disparity[ty][tx];
if ((disp_hor >= disp_far) && (disp_hor <= disp_near) && !Double.isNaN(adiff_hor)){ if ((disp_hor >= disp_far) && (disp_hor <= disp_near) && !Double.isNaN(adiff_hor)){
if (strength_hor >= minStrengthHor) { if (strength_hor >= minStrengthHor) {
if (!(adiff_hor >= adiff_best_hor)){ // adiff_best == Double.NaN works too if (!(adiff_hor >= adiff_best_hor)){ // adiff_best == Double.NaN works too
adiff_best_hor = adiff_hor; adiff_best_hor = adiff_hor;
best_index_hor = ipass; best_index_hor = ipass;
} }
} else { } else {
if ((last && (strength_hor > 0.0)) || (!no_weak && (strength_hor > strongest_weak_hor))){ if ((last && (strength_hor > 0.0)) || (!no_weak && (strength_hor > strongest_weak_hor))){
strongest_weak_hor = strength_hor; strongest_weak_hor = strength_hor;
best_weak_index_hor = ipass; best_weak_index_hor = ipass;
}
} }
} }
} }
}
if (!Double.isNaN(minStrengthVert) && (adiff_vert <= trustedCorrelation)){
if (!Double.isNaN(minStrengthVert) && (adiff_vert <= trustedCorrelation)){ double disp_vert = mdisp_vert/corr_magic_scale + pass.disparity[ty][tx];
double disp_vert = mdisp_vert/corr_magic_scale + pass.disparity[ty][tx]; if ((disp_vert >= disp_far) && (disp_vert <= disp_near) && !Double.isNaN(adiff_vert)){
if ((disp_vert >= disp_far) && (disp_vert <= disp_near) && !Double.isNaN(adiff_vert)){ if (strength_vert >= minStrengthVert) {
if (strength_vert >= minStrengthVert) { if (!(adiff_vert >= adiff_best_vert)){ // adiff_best == Double.NaN works too
if (!(adiff_vert >= adiff_best_vert)){ // adiff_best == Double.NaN works too adiff_best_vert = adiff_vert;
adiff_best_vert = adiff_vert; best_index_vert = ipass;
best_index_vert = ipass; }
} } else {
} else { if ((last && (strength_vert > 0.0)) || (!no_weak && (strength_vert > strongest_weak_vert))){
if ((last && (strength_vert > 0.0)) || (!no_weak && (strength_vert > strongest_weak_vert))){ strongest_weak_vert = strength_vert;
strongest_weak_vert = strength_vert; best_weak_index_vert = ipass;
best_weak_index_vert = ipass; }
} }
} }
} }
...@@ -1544,8 +1562,8 @@ public class TileProcessor { ...@@ -1544,8 +1562,8 @@ public class TileProcessor {
// scan.restoreKeepTileOpDisparity();// it is not used from this scan, but from last_scan // scan.restoreKeepTileOpDisparity();// it is not used from this scan, but from last_scan
continue; continue;
} }
if (debugLevel > 0){ if (debugLevel > -1){
System.out.println("prepareExpandVariants(): remaining "+num_left+" tiles to be processed, used variant "+num_var); System.out.println("prepareExpandVariants(): remaining "+num_left+" tiles to be processed, used variant "+num_var+" ("+num_left+")");
} }
int [] rslt = {num_left, num_var}; int [] rslt = {num_left, num_var};
return rslt; return rslt;
...@@ -2060,7 +2078,7 @@ public class TileProcessor { ...@@ -2060,7 +2078,7 @@ public class TileProcessor {
sdfa_instance = new showDoubleFloatArrays(); // just for debugging? sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = { String [] titles = {
"tile_op", // 0 "tile_op", // 0
"final", // 1 - calculated, filetered, combined disparity "final", // 1 - calculated, filtered, combined disparity
"disparity", // 2 "disparity", // 2
"disp_cm", // 3 "disp_cm", // 3
"disp_hor", // 4 "disp_hor", // 4
...@@ -2078,7 +2096,8 @@ public class TileProcessor { ...@@ -2078,7 +2096,8 @@ public class TileProcessor {
"diff3", // 16 "diff3", // 16
"diff2max", // 17 "diff2max", // 17
"diff2maxAvg", // 18 "diff2maxAvg", // 18
"normStrength"}; // 19 "normStrength", // 19
"overexp"}; // 20
int tlen = tilesX*tilesY; int tlen = tilesX*tilesY;
...@@ -2101,12 +2120,13 @@ public class TileProcessor { ...@@ -2101,12 +2120,13 @@ public class TileProcessor {
double [] strength4 = null; double [] strength4 = null;
if (scan.disparity_map != null){ if (scan.disparity_map != null){
strength4 = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; strength4 = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[3] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM]; dbg_img[ 3] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM];
dbg_img[4] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR]; dbg_img[ 4] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR];
dbg_img[5] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT]; dbg_img[ 5] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT];
dbg_img[7] = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX]; dbg_img[ 7] = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[8] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH]; dbg_img[ 8] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH];
dbg_img[9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH]; dbg_img[ 9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
dbg_img[20] = scan.disparity_map[ImageDtt.OVEREXPOSED];
} }
dbg_img[1] = scan.calc_disparity_combo; dbg_img[1] = scan.calc_disparity_combo;
dbg_img[6] = scan.strength; dbg_img[6] = scan.strength;
...@@ -3681,9 +3701,6 @@ public class TileProcessor { ...@@ -3681,9 +3701,6 @@ public class TileProcessor {
for (int i = 0; i<dbg_img[0].length;i++){ for (int i = 0; i<dbg_img[0].length;i++){
dbg_img[ 0][i] = this_disparity_masked[i]; dbg_img[ 0][i] = this_disparity_masked[i];
dbg_img[ 1][i] = this_disparity[i]; dbg_img[ 1][i] = this_disparity[i];
// dbg_img[ 2][i] = dbg_orig_disparity[i];
// dbg_img[ 3][i] = this_hor_disparity[i];
// dbg_img[ 4][i] = this_vert_disparity[i];
dbg_img[ 5][i] = bg_tiles [i] ? 1 : -1; dbg_img[ 5][i] = bg_tiles [i] ? 1 : -1;
dbg_img[ 6][i] = far_tiles [i] ? 1 : -1; dbg_img[ 6][i] = far_tiles [i] ? 1 : -1;
dbg_img[ 7][i] = dbg_before_small [i] ? 1 : -1; dbg_img[ 7][i] = dbg_before_small [i] ? 1 : -1;
...@@ -4197,7 +4214,7 @@ public class TileProcessor { ...@@ -4197,7 +4214,7 @@ public class TileProcessor {
clt_parameters.poles_min_strength, // double min_new_strength, // set strength to hor_strength, but not less than this clt_parameters.poles_min_strength, // double min_new_strength, // set strength to hor_strength, but not less than this
clt_parameters.poles_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity clt_parameters.poles_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity
true); true);
if (debugLevel > -1){ if (debugLevel > 0){
System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles."); System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles.");
} }
replaced0 = replaced.clone(); replaced0 = replaced.clone();
...@@ -4263,28 +4280,6 @@ public class TileProcessor { ...@@ -4263,28 +4280,6 @@ public class TileProcessor {
debugLevel); debugLevel);
// }
/*
boolean [] these_tiles = combineHorVertDisparity(
scan_prev, // final CLTPass3d scan,
scan_prev.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
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,
debugLevel);
scan_prev.combineHorVertStrength(true, false); // strength now max of original and horizontal. Use scale instead of boolean?
*/
// double [] this_disparity = scan_prev.getDisparity(); // returns a copy of the FPGA-generated disparity combined with the target one
// double [] this_strength = scan_prev.getStrength(); // cloned, can be modified/ read back
//************************************************ //************************************************
// Show supertiles histograms // Show supertiles histograms
...@@ -4587,39 +4582,18 @@ public class TileProcessor { ...@@ -4587,39 +4582,18 @@ public class TileProcessor {
name + "-TXTOL-D", name + "-TXTOL-D",
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles)); (clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
} }
/* }
if (clt_parameters.show_rgba_color) { if (debugLevel > -1) {
// for now - use just RGB. Later add oprion for RGBA double [][] tiles_tone = scan_prev.getTileRBGA(
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]}; 12); // int num_layers);
double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]}; sdfa_instance.showArrays(
// ImagePlus img_texture = tiles_tone,
linearStackToColor( tilesX,
clt_parameters, tilesY,
colorProcParameters, true,
rgbParameters, name + "tiles_tone",
name+"-texture", // String name, (clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
"-D"+clt_parameters.disparity, //String suffix, // such as disparity=... }
toRGB,
!this.correctionsParameters.jpeg, // boolean bpp16, // 16-bit per channel color mode for result
true, // boolean saveShowIntermediate, // save/show if set globally
true, // boolean saveShowFinal, // save/show result (color image?)
((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb),
tilesX * clt_parameters.transform_size,
tilesY * clt_parameters.transform_size,
1.0, // double scaleExposure, // is it needed?
debugLevel );
}
*/
}
double [][] tiles_tone = scan_prev.getTileRBGA(
12); // int num_layers);
sdfa_instance.showArrays(
tiles_tone,
tilesX,
tilesY,
true,
name + "tiles_tone",
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
} }
TileAssignment ta = new TileAssignment( TileAssignment ta = new TileAssignment(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -4630,14 +4604,17 @@ public class TileProcessor { ...@@ -4630,14 +4604,17 @@ public class TileProcessor {
Double.NaN, // double kR, Double.NaN, // double kR,
Double.NaN, // double kB, Double.NaN, // double kB,
Double.NaN); // double fatZero) Double.NaN); // double fatZero)
if (debugLevel > -1) {
ta.showToneDiffWeights3("Raw_"); ta.showToneDiffWeights3("Raw_");
ta.showToneDiffWeights1("Raw_"); ta.showToneDiffWeights1("Raw_");
}
ta.blurMixTones( ta.blurMixTones(
false, // final boolean use_sqrt, false, // final boolean use_sqrt,
true); //final boolean weighted) // blur weighted true); //final boolean weighted) // blur weighted
ta.showToneDiffWeights3("Mixed_"); if (debugLevel >-1) {
ta.showToneDiffWeights1("Mixed_"); ta.showToneDiffWeights3("Mixed_");
ta.showToneDiffWeights1("Mixed_");
}
// } // }
...@@ -4868,7 +4845,8 @@ public class TileProcessor { ...@@ -4868,7 +4845,8 @@ public class TileProcessor {
} }
} }
tileSurface.compareAssignments( tileSurface.compareAssignments(
tile_assignments); // final int [][][] tileAssignments) tile_assignments, // final int [][][] tileAssignments)
debugLevel); //
int [][][] opinions = new int [tile_layers.length][][]; int [][][] opinions = new int [tile_layers.length][][];
tile_layers = tileSurface.getConsensusAssignment( tile_layers = tileSurface.getConsensusAssignment(
...@@ -4887,8 +4865,10 @@ public class TileProcessor { ...@@ -4887,8 +4865,10 @@ public class TileProcessor {
} }
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf"); (new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf");
} }
ta.showTileCost("before_",tile_layers_surf); if (debugLevel > -1) {
ta.showTileCosts("before_",tile_layers_surf); ta.showTileCost("before_",tile_layers_surf);
ta.showTileCosts("before_",tile_layers_surf);
}
TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf); TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf);
for (int i = 0; i < ta_stats.length; i++){ for (int i = 0; i < ta_stats.length; i++){
...@@ -4913,8 +4893,12 @@ public class TileProcessor { ...@@ -4913,8 +4893,12 @@ public class TileProcessor {
} }
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf"); (new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf");
} }
ta.showTileCost("after_",tile_layers_surf); if (debugLevel > -2) {
ta.showTileCosts("after_",tile_layers_surf); ta.showTileCost("after_",tile_layers_surf);
}
if (debugLevel > -1) {
ta.showTileCosts("after_",tile_layers_surf);
}
ta_stats = ta.statTileCosts(tile_layers_surf); ta_stats = ta.statTileCosts(tile_layers_surf);
System.out.println("Optimized:"); System.out.println("Optimized:");
for (int i = 0; i < ta_stats.length; i++){ for (int i = 0; i < ta_stats.length; i++){
...@@ -4935,7 +4919,7 @@ public class TileProcessor { ...@@ -4935,7 +4919,7 @@ public class TileProcessor {
tileSel, // final boolean [][] tileSel, tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel, debugLevel); // final int debugLevel,
if (clt_parameters.tsShow){ if (clt_parameters.tsShow && (debugLevel > -2)){
tileSurface.showAssignment( tileSurface.showAssignment(
"assignments", // String title, "assignments", // String title,
dispStrength); // final double [][][] dispStrength) dispStrength); // final double [][][] dispStrength)
...@@ -5058,7 +5042,7 @@ public class TileProcessor { ...@@ -5058,7 +5042,7 @@ public class TileProcessor {
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
if (clt_parameters.tsShow){ if (clt_parameters.tsShow && (debugLevel > -1)){
int numToShow = clt_parameters.tsNumClust; int numToShow = clt_parameters.tsNumClust;
int num_surf = tileSurface.getSurfaceDataLength(); int num_surf = tileSurface.getSurfaceDataLength();
if (numToShow > num_surf) numToShow = num_surf; if (numToShow > num_surf) numToShow = num_surf;
...@@ -5223,7 +5207,7 @@ public class TileProcessor { ...@@ -5223,7 +5207,7 @@ public class TileProcessor {
// Trying new class // Trying new class
LinkPlanes lp = new LinkPlanes (clt_parameters, st); LinkPlanes lp = new LinkPlanes (clt_parameters, st);
if (clt_parameters.show_planes){ if (clt_parameters.show_planes && (debugLevel > -1)){
showPlaneData( showPlaneData(
"initial", "initial",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -5568,7 +5552,7 @@ public class TileProcessor { ...@@ -5568,7 +5552,7 @@ public class TileProcessor {
true, // final boolean weak_connected, // select connected planes even if they are weak/thick true, // final boolean weak_connected, // select connected planes even if they are weak/thick
st.getPlanesMod()); st.getPlanesMod());
if (clt_parameters.show_planes){ if (clt_parameters.show_planes && (debugLevel > -2)){
showPlaneData( showPlaneData(
"final", "final",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -5582,7 +5566,7 @@ public class TileProcessor { ...@@ -5582,7 +5566,7 @@ public class TileProcessor {
clt_parameters.msScaleProj, // final double scale_projection, clt_parameters.msScaleProj, // final double scale_projection,
clt_parameters.msFractUni, // final double fraction_uni, clt_parameters.msFractUni, // final double fraction_uni,
st.planes_mod, // st.planes, // final TilePlanes.PlaneData [][] planes, st.planes_mod, // st.planes, // final TilePlanes.PlaneData [][] planes,
0, // -1, // debugLevel, // final int debugLevel) debugLevel, // final int debugLevel)
clt_parameters.tileX, clt_parameters.tileX,
clt_parameters.tileY); clt_parameters.tileY);
...@@ -5951,7 +5935,7 @@ public class TileProcessor { ...@@ -5951,7 +5935,7 @@ public class TileProcessor {
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); // 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_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
CLTPass3d scan_lm = getLastMeasured(-1); CLTPass3d scan_lm = getLastMeasured(-1);
boolean [] border_tiles = (scan_lm != null) ? scan_lm.getBorderTiles() : null; // boolean [] border_tiles = (scan_lm != null) ? scan_lm.getBorderTiles() : null;
showDoubleFloatArrays sdfa_instance = null; showDoubleFloatArrays sdfa_instance = null;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging? if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
...@@ -5994,7 +5978,7 @@ public class TileProcessor { ...@@ -5994,7 +5978,7 @@ public class TileProcessor {
clt_parameters.poles_min_strength, // double min_new_strength, // set strength to hor_strength, but not less than this clt_parameters.poles_min_strength, // double min_new_strength, // set strength to hor_strength, but not less than this
clt_parameters.poles_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity clt_parameters.poles_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity
true); true);
if (debugLevel > -1){ if (debugLevel > 0){
System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles."); System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles.");
} }
// replaced0 = replaced.clone(); // replaced0 = replaced.clone();
......
...@@ -1671,8 +1671,9 @@ public class TileSurface { ...@@ -1671,8 +1671,9 @@ public class TileSurface {
debugLevel, // final int debugLevel, debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X, dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y); dbg_Y); // final int dbg_Y);
if (debugLevel >- 1) {
showSurfaceDS (tileData, "tileData"); showSurfaceDS (tileData, "tileData");
}
this.tileData = tileData; this.tileData = tileData;
return tileData; return tileData;
} }
...@@ -2220,7 +2221,8 @@ public class TileSurface { ...@@ -2220,7 +2221,8 @@ public class TileSurface {
} }
public void compareAssignments( public void compareAssignments(
final int [][][] tileAssignments) final int [][][] tileAssignments,
final int debugLevel)
{ {
final int imgTiles = imageTilesX * imageTilesY; final int imgTiles = imageTilesX * imageTilesY;
final int num_in = tileAssignments.length; final int num_in = tileAssignments.length;
...@@ -2259,8 +2261,10 @@ public class TileSurface { ...@@ -2259,8 +2261,10 @@ public class TileSurface {
img_data[num_in+1][nTile] = combo[nTile]; img_data[num_in+1][nTile] = combo[nTile];
} }
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); if (debugLevel > -1) {
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, "consensus",titles); showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, "consensus",titles);
}
} }
public int [][] getConsensusAssignment( public int [][] getConsensusAssignment(
......
...@@ -49,6 +49,8 @@ public class WavefrontExport { ...@@ -49,6 +49,8 @@ public class WavefrontExport {
public int v_index = 1; // first index is 1, not 0 public int v_index = 1; // first index is 1, not 0
public int vt_index = 1; // first index is 1, not 0 public int vt_index = 1; // first index is 1, not 0
public int f_index = 1; // first index is 1, not 0 public int f_index = 1; // first index is 1, not 0
public String obj_path;
public String mtl_path;
public WavefrontExport( public WavefrontExport(
String out_dir, String out_dir,
...@@ -61,8 +63,10 @@ public class WavefrontExport { ...@@ -61,8 +63,10 @@ public class WavefrontExport {
this.correctionsParameters = correctionsParameters; this.correctionsParameters = correctionsParameters;
this.geometry_correction = geometry_correction; this.geometry_correction = geometry_correction;
this.clt_3d_passes = clt_3d_passes; this.clt_3d_passes = clt_3d_passes;
mtl_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT); mtl_path = out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT;
obj_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+OBJ_EXT); // .close(); obj_path = out_dir+Prefs.getFileSeparator()+project_name+OBJ_EXT;
mtl_writer = new FileWriter(mtl_path);
obj_writer = new FileWriter(obj_path); // .close();
mtl_writer.write("#\n# Wavefront material file\n#\n"); mtl_writer.write("#\n# Wavefront material file\n#\n");
obj_writer.write("#\n# Wavefront object file\n#\n"); obj_writer.write("#\n# Wavefront object file\n#\n");
obj_writer.write("mtllib ./"+project_name+MTL_EXT+"\n\n"); // add "./" to indicate relative path? // ./1488240527_408296.obj.mtl\n"); obj_writer.write("mtllib ./"+project_name+MTL_EXT+"\n\n"); // add "./" to indicate relative path? // ./1488240527_408296.obj.mtl\n");
......
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