Commit f5a43005 authored by Andrey Filippov's avatar Andrey Filippov

correcting wrongly reported exposure

parent 8d207d39
......@@ -315,13 +315,13 @@ public class AlignmentCorrection {
magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
debugLevel);
double [][][] mismatch_corr_coefficiants = null;
double [][][] mismatch_corr_coefficients = null;
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_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_vert, // final boolean use_vertical,
clt_parameters.ly_inf_en, // final boolean use_disparity, // for infinity
......@@ -335,10 +335,10 @@ public class AlignmentCorrection {
if (debugLevel > -1){
System.out.println("infinityCorrection(): coefficient increments from infinityMismatchCorrection");
show_fine_corr(
mismatch_corr_coefficiants, // double [][][] corr,
mismatch_corr_coefficients, // double [][][] corr,
"");// String prefix)
}
return mismatch_corr_coefficiants;
return mismatch_corr_coefficients;
}
/**
......@@ -789,7 +789,7 @@ public class AlignmentCorrection {
Matrix AINV = A.inverse();
double scale = 0.5/magic_coeff;
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];
}
for (Sample s: samples_list){
......@@ -1586,11 +1586,45 @@ B = |+dy0 -dy1 -2*dy3 |
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(
// 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 double fcorr_radius,
final double min_strength_in,
......@@ -1604,7 +1638,9 @@ B = |+dy0 -dy1 -2*dy3 |
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 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 smplNum, // = 3; // Number after removing worst (should be >1)
final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
......@@ -1620,9 +1656,14 @@ B = |+dy0 -dy1 -2*dy3 |
final double inf_fraction, // fraction of the weight for the infinity tiles
EyesisCorrectionParameters.CLTParameters clt_parameters,
double [][] scans_14,
double [][] target_disparity, // null or programmed disparity (1 per each 14 entries of scans_14)
int tilesX,
double magic_coeff, // still not understood coefficient that reduces reported disparity value. Seems to be around 8.5
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_tiles = scans_14[0].length;
final int tilesY = num_tiles/tilesX;
......@@ -1671,7 +1712,15 @@ B = |+dy0 -dy1 -2*dy3 |
lazyEyeSmplRms, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
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);
}
......@@ -1679,6 +1728,9 @@ B = |+dy0 -dy1 -2*dy3 |
double [] combo_comp_rms = new double [num_tiles];
for (int ns = 0; ns < num_scans; ns++){
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];
if (w > 0.0){
double disp = filtered_scans[ns * NUM_SLICES + 0][nTile];
......@@ -1686,9 +1738,15 @@ B = |+dy0 -dy1 -2*dy3 |
for (int i = 2; i < NUM_SLICES; i++) if (i != 1){
combo_mismatch[i][nTile] += filtered_scans[ns * NUM_SLICES + i][nTile] * w;
}
if (target_disparity != null){
combo_mismatch[0][nTile] += (
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;
(clt_parameters.disp_scan_start + clt_parameters.disp_scan_step * ns ) )* w;
}
combo_mismatch[1][nTile] += w;
combo_comp_rms[nTile] += w * comp_strength_rms[ns][nTile];
}
......@@ -1697,6 +1755,10 @@ B = |+dy0 -dy1 -2*dy3 |
}
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];
if (w > 0.0){
for (int i = 0; i < NUM_SLICES; i++) if (i != 1){
......@@ -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");
}
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){
if (nTile == dbg_nTile){
System.out.println("lazyEyeCorrection().3: nTile="+nTile);
}
double d = combo_mismatch[0][nTile];
double lev = lazyEyeDispVariation + lazyEyeDispRelVariation * d;
for (int dir = 0; dir <8; dir++){
int nTile1 = tnImage.getNeibIndex(nTile, dir);
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;
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;
}
break;
......@@ -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"};
(new showDoubleFloatArrays()).showArrays(combo_mismatch, tilesX, combo_mismatch[0].length/tilesX, true, "combo_mismatch" , prefixes);
}
......@@ -1939,7 +2017,7 @@ B = |+dy0 -dy1 -2*dy3 |
}
}
if (debugLevel > -1) {
if (debugLevel > 0) {
double inf_weight = 0.0;
for (Sample s: inf_samples_list) {
inf_weight += s.weight;
......@@ -1956,7 +2034,7 @@ B = |+dy0 -dy1 -2*dy3 |
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 |
(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>());
double [][][] mismatch_corr_coefficiants = infinityMismatchCorrection(
double [][][] mismatch_corr_coefficients = infinityMismatchCorrection(
clt_parameters.disp_scan_start, // final double disp_scan_start,
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,
true, // clt_parameters.fcorr_inf_vert, // final boolean use_vertical,
false, // final boolean use_disparity, // for infinity
......@@ -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
mismatch_list, // ArrayList<Mismatch> mismatch_list,
debugLevel); // int debugLevel)
if (debugLevel > -1) {
if (debugLevel > -2) {
System.out.println("===== lazyEyeCorrection(): correction coefficients =====");
if (mismatch_corr_coefficiants != null) {
if (mismatch_corr_coefficients != null) {
show_fine_corr(
mismatch_corr_coefficiants,
"mismatch_corr_coefficiants");
mismatch_corr_coefficients,
"mismatch_corr_coefficients");
}
}
if (!use_poly && (mismatch_list != null)){
double [] old_new_rms = new double[1];
boolean apply_extrinsic = true;
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_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,
qc.geometryCorrection, // GeometryCorrection geometryCorrection,
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){
System.out.println("Old extrinsic corrections:");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
......@@ -2009,14 +2091,20 @@ B = |+dy0 -dy1 -2*dy3 |
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 {
if (debugLevel > -1){
System.out.println("Extrinsic parameters (tilt, azimuth, roll) of subcameras is disabled, clt_parameters.ly_poly="+
clt_parameters.ly_poly+" (should be false for extrinsics)");
if (debugLevel > -2){
System.out.println("Extrinsic parameters (tilt, azimuth, roll) of subcameras is disabled, use_poly="+
use_poly+" (should be false for extrinsics)");
System.out.println(qc.geometryCorrection.getCorrVector().toString());
}
return mismatch_corr_coefficients;
}
return mismatch_corr_coefficiants;
return mismatch_corr_coefficients;
}
public double [][] combineCltMismatches(
......@@ -2458,9 +2546,12 @@ B = |+dy0 -dy1 -2*dy3 |
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
// data, using just radial distortions
boolean common_roll, // Enable common roll (valid for high disparity range only)
ArrayList<Mismatch> mismatch_list,
GeometryCorrection geometryCorrection,
GeometryCorrection.CorrVector corr_vector,
double [] old_new_rms, // should be double[2]
int debugLevel)
{
boolean has_disparity = force_convergence; // force false;
......@@ -2471,10 +2562,26 @@ B = |+dy0 -dy1 -2*dy3 |
break;
}
}
boolean [] par_mask = new boolean[10];
for (int i = (has_disparity ? 0 : 1); i < par_mask.length; i++){
par_mask[i] = true;
}
// boolean [] par_mask = new boolean[10];
// for (int i = (has_disparity ? 0 : 1); i < par_mask.length; i++){
// 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(
par_mask, // boolean [] par_mask,
......@@ -2502,6 +2609,10 @@ B = |+dy0 -dy1 -2*dy3 |
if (debugLevel > -1){
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);
// double [][] jtja = getJTJ(jta, weights);
double [][] jtja = getJTJ(jta_mv, weights);
......
......@@ -27,6 +27,7 @@ import java.awt.Rectangle;
import java.util.concurrent.atomic.AtomicInteger;
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 int [][] tile_op; // what was done in the current pass
private double [][] disparity_sav; // saved disaprity
......@@ -192,8 +193,7 @@ public class CLTPass3d{
*/
public void resetProcessed(){
fixNaNDisparity();
if (disparity_map != null) fixNaNDisparity();
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_vert = null; // composite disparity, calculated from "disparity", and "disparity_map" fields
......@@ -357,14 +357,20 @@ public class CLTPass3d{
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/
* horizontal features
* @return line-scan array of per-tile correlation strength by reference (not a copy), so it can be modified
*/
public double [] getStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength == null){
strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
if (trustedCorrelation > 0.0){
......@@ -372,6 +378,12 @@ public class CLTPass3d{
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;
}
......@@ -388,6 +400,7 @@ public class CLTPass3d{
*/
public double [] getHorStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_hor == null) {
strength_hor = disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH].clone();
if (trustedCorrelation > 0.0){
......@@ -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
}
}
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;
}
/**
* 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)
*/
public double [] getVertStrength(){
double trustedCorrelation = tileProcessor.getTrustedCorrelation();
double max_overexposure = tileProcessor.getMaxOverexposure();
if (strength_vert == null) {
strength_vert = disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH].clone();
if (trustedCorrelation > 0.0){
......@@ -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
}
}
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;
......@@ -704,6 +731,7 @@ public class CLTPass3d{
selection, // boolean [] selection,
disparity); // double [] disparity)
}
public int setTileOpDisparity(
int tile_op,
boolean [] selection,
......@@ -712,13 +740,21 @@ public class CLTPass3d{
final int tilesX = tileProcessor.getTilesX();
final int tilesY = tileProcessor.getTilesY();
this.disparity = new double [tilesY][tilesX];
if (selection != null) {
this.tile_op = new int [tilesY][tilesX];
}
int num_op_tiles = 0;
for (int ty = 0; ty < tilesY; ty++) for (int tx = 0; tx <tilesX; tx++){
int indx = tilesX * ty + tx;
if (this.selected[indx]) {
this.disparity[ty][tx] = disparity[indx];
if (selection == null) {
this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
if (this.tile_op[ty][tx] != 0){
num_op_tiles ++;
}
} else {
if (selection[indx]) {
this.disparity[ty][tx] = (disparity == null)? 0.0: disparity[indx];
this.tile_op[ty][tx] = tile_op;
num_op_tiles ++;
} else {
......@@ -726,12 +762,17 @@ public class CLTPass3d{
this.tile_op[ty][tx] = 0;
}
}
}
return num_op_tiles;
}
/**
* Set next measurement disparity from last calculated
*/
public void updateDisparity()
{
setTileOpDisparity(null, getDisparity(0));
}
public double [] getSecondMaxDiff (
......
......@@ -368,10 +368,10 @@ public class EyesisCorrectionParameters {
gd.addStringField("Equirectangular maps directory (may be empty)", this.equirectangularDirectory, 60);
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.addStringField("Source files prefix", this.sourcePrefix, 40);
gd.addStringField("Source files suffix", this.sourceSuffix, 40);
gd.addStringField("Source files prefix", this.sourcePrefix, 60);
gd.addStringField("Source files suffix", this.sourceSuffix, 60);
gd.addNumericField("First subcamera (in the source filename)", this.firstSubCamera, 0);
gd.addStringField("Sensor files prefix", this.sensorPrefix, 40);
......@@ -457,13 +457,6 @@ public class EyesisCorrectionParameters {
this.firstSubCamera= (int) gd.getNextNumber();
this.sensorPrefix= 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.cltSuffix= gd.getNextString();
this.equirectangularPrefix= gd.getNextString();
......@@ -479,6 +472,60 @@ public class EyesisCorrectionParameters {
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
public String [] getSourcePaths(){
......@@ -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 corr_sigma = 0.8; // LPF correlation sigma
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 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_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 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_b = 1.0;
public double vignetting_max = 0.4; // value in vignetting data to correspond to 1x in the kernel
......@@ -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_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_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 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_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
// 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 int lyf_smpl_side = 8; // 8 x8 masked, 16x16 sampled
public double lyf_rms_max = 0.25; // Maximal RMS (all components to components average)
......@@ -2537,6 +2597,7 @@ public class EyesisCorrectionParameters {
public boolean dbg_migrate = true;
// other debug images
public boolean show_extrinsic = false; // show extrinsic adjustment differences
public boolean show_ortho_combine = false; // Show 'ortho_combine'
public boolean show_refine_supertiles = false; // show 'refine_disparity_supertiles'
public boolean show_bgnd_nonbgnd = false; // show 'bgnd_nonbgnd'
......@@ -2574,6 +2635,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"norm_kern", this.norm_kern+"");
properties.setProperty(prefix+"gain_equalize", this.gain_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_g", this.novignetting_g+"");
properties.setProperty(prefix+"novignetting_b", this.novignetting_b+"");
......@@ -2684,12 +2749,21 @@ public class EyesisCorrectionParameters {
// properties.setProperty(prefix+"ly_meas_disp", this.ly_meas_disp +"");
properties.setProperty(prefix+"ly_smpl_rms", this.ly_smpl_rms +"");
properties.setProperty(prefix+"ly_disp_var", this.ly_disp_var +"");
properties.setProperty(prefix+"ly_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_on_scan", this.ly_on_scan+"");
properties.setProperty(prefix+"ly_inf_en", this.ly_inf_en+"");
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+"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_smpl_side", this.lyf_smpl_side+"");
properties.setProperty(prefix+"lyf_rms_max", this.lyf_rms_max +"");
......@@ -3124,6 +3198,7 @@ public class EyesisCorrectionParameters {
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_refine_supertiles", this.show_refine_supertiles+"");
properties.setProperty(prefix+"show_bgnd_nonbgnd", this.show_bgnd_nonbgnd+"");
......@@ -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+"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+"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_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"));
......@@ -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_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_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_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_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+"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_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"));
......@@ -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+"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_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"));
......@@ -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("LPF correlarion sigma ", this.corr_sigma, 3);
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.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("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);
......@@ -3874,14 +3967,24 @@ public class EyesisCorrectionParameters {
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.addNumericField("Maximal measured relative disparity", this.ly_meas_disp, 3);
gd.addNumericField("Maximal RMS of the remaining tiles in a sample", this.ly_smpl_rms, 3);
gd.addNumericField("Maximal full disparity difference to 8 neighbors", this.ly_disp_var, 3);
gd.addNumericField("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, 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.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 ("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.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.addCheckbox ("Filter lazy eye pairs by their values", this.lyf_filter);
gd.addNumericField("Fileter sample side (if 8, 8 x8 masked, 16x16 sampled)", this.lyf_smpl_side, 0);
......@@ -4351,6 +4454,7 @@ public class EyesisCorrectionParameters {
gd.addCheckbox ("Test new mode after migration", this.dbg_migrate);
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 'refine_disparity_supertiles'", this.show_refine_supertiles);
gd.addCheckbox ("Show 'bgnd_nonbgnd'", this.show_bgnd_nonbgnd);
......@@ -4389,6 +4493,10 @@ public class EyesisCorrectionParameters {
this.norm_kern= gd.getNextBoolean();
this.gain_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_g= gd.getNextNumber();
this.novignetting_b= gd.getNextNumber();
......@@ -4502,12 +4610,21 @@ public class EyesisCorrectionParameters {
// this.ly_meas_disp= gd.getNextNumber();
this.ly_smpl_rms= 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_on_scan= gd.getNextBoolean();
this.ly_inf_en= gd.getNextBoolean();
this.ly_inf_force= gd.getNextBoolean();
this.ly_com_roll= 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_smpl_side= (int) gd.getNextNumber();
this.lyf_rms_max= gd.getNextNumber();
......@@ -4946,6 +5063,7 @@ public class EyesisCorrectionParameters {
this.dbg_migrate= gd.getNextBoolean();
this.show_extrinsic= gd.getNextBoolean();
this.show_ortho_combine= gd.getNextBoolean();
this.show_refine_supertiles=gd.getNextBoolean();
this.show_bgnd_nonbgnd= gd.getNextBoolean(); // first on second pass
......
......@@ -78,7 +78,8 @@ private Panel panel1,
panelPostProcessing3,
panelDct1,
panelClt1,
panelClt2
panelClt2,
panelClt3
;
JP46_Reader_camera JP4_INSTANCE=null;
......@@ -370,7 +371,7 @@ private Panel panel1,
instance = this;
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));
panel6 = new Panel();
......@@ -518,16 +519,6 @@ private Panel panel1,
panelClt2 = new Panel();
panelClt2.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
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 disparity scan", panelClt2, color_conf_process);
addButton("CLT reset fine corr", panelClt2, color_stop);
......@@ -539,6 +530,8 @@ private Panel panel1,
addButton("CLT infinity corr", panelClt2, color_conf_process);
addButton("CLT ext infinity corr", panelClt2, color_conf_process);
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 planes", panelClt2, color_conf_process);
addButton("CLT ASSIGN", panelClt2, color_process);
......@@ -546,6 +539,14 @@ private Panel panel1,
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();
GUI.center(this);
......@@ -3667,6 +3668,12 @@ private Panel panel1,
// EyesisCorrectionParameters.DCTParameters dCTParameters,
// int srcKernelSize,
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")) {
CLT_PARAMETERS.showDialog();
......@@ -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;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
......@@ -4834,6 +4843,8 @@ private Panel panel1,
}
QUAD_CLT.processCLTQuads3d(
adjust_extrinsics, // boolean adjust_extrinsics,
adjust_poly, // boolean adjust_poly,
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
......
......@@ -111,6 +111,15 @@ public class GeometryCorrection {
extrinsic_corr = vector;
}
public boolean [] getParMask(
boolean use_disparity,
boolean common_roll)
{
return (new CorrVector()).getParMask(
use_disparity,
common_roll);
}
public class CorrVector{
......@@ -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("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 += "Symmetrical vector first 5 as last 4 (rolls) are the same:\n";
s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘|\n";
s += "0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖|\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 += "Symmetrical vector:\n";
s += " |↘ ↙| |↘ ↗| |↗ ↘| |↙ ↘| |↙ ↗| |↖ ↘| 6: common roll 7:(r0-r3)/2, \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° 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;
}
......@@ -252,10 +266,14 @@ public class GeometryCorrection {
{ 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
{ 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, 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, 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, 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.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;
}
......@@ -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. , 0. , 1. , 0. ],
[ 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= {
// 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.
{-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 }, // 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 , 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 , 0.0 , 1.0 }}; // sym9 = r3
// { 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 , 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 , 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;
}
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
* 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.
}
return tar_array;
}
}
}
public void setDistortion(
double focalLength,
double distortionC,
......
......@@ -50,6 +50,7 @@ public class ImageDtt {
// public static int FORCE_DISPARITY_BIT = 8; // move to parameters?
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_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
......@@ -60,9 +61,10 @@ public class ImageDtt {
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 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 = {
"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_SUM = 1; // sum of channle correlations from all selected pairs
......@@ -773,7 +775,11 @@ public class ImageDtt {
centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
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)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = {"CC","SC","CS","SS"};
......@@ -898,7 +904,10 @@ public class ImageDtt {
centersXY[i][1], // centerY, //
((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2)) ? 1 : 0, // external tile compare
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)) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
......@@ -956,6 +965,7 @@ public class ImageDtt {
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 [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null
// 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
// [type][tilesY][tilesX] should be set by caller
......@@ -1127,9 +1137,11 @@ public class ImageDtt {
}
if (disparity_map != null){
for (int i = 0; i<disparity_map.length;i++){
if ((i != OVEREXPOSED) || (saturation_imp!= null)){
disparity_map[i] = new double [tilesY*tilesX];
}
}
}
if (clt_mismatch != null){
for (int i = 0; i<clt_mismatch.length;i++){
clt_mismatch[i] = new double [tilesY*tilesX]; // will use only "center of mass" centers
......@@ -1151,7 +1163,8 @@ public class ImageDtt {
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++) {
threads[ithread] = new Thread() {
......@@ -1182,6 +1195,9 @@ public class ImageDtt {
}
}
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++) {
centerX = tileX * transform_size + transform_size/2 - shiftX;
centerY = tileY * transform_size + transform_size/2 - shiftY;
......@@ -1262,7 +1278,6 @@ public class ImageDtt {
centersXY[3][0]+"\t"+centersXY[3][1]+"\t");
}
for (int i = 0; i < quad; i++) {
clt_data[i][chn][tileY][tileX] = new double [4][];
fract_shiftsXY[i] = extract_correct_tile( // return a pair of residual offsets
......@@ -1281,7 +1296,10 @@ public class ImageDtt {
// (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (chn == 2), // external tile compare
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)) {
System.out.println();
......@@ -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
double extra_disparity = 0.0; // if allowed, shift images extra before trying to combine
if (clt_corr_combo != null){ // not null - calculate correlations
......@@ -3571,7 +3594,10 @@ public class ImageDtt {
int debugLevel,
// boolean bdebug0, // external tile compare
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 bdebug0 = debugLevel > 0;
......@@ -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
double [][][] fold_coeff = null;
if (!dbg_transpose){
......
......@@ -48,6 +48,7 @@ public class MacroCorrelation {
tp.superTileSize, // int superTileSize,
tp.getMagicScale(), // double scale,
trusted_correlation, // double trustedCorrelation,
0.0, // double maxOverexposure,
tp.getThreadsMax()); // int threadsMax)
}
public TileProcessor CLTMacroScan( // perform single pass according to prepared tiles operations and disparity
......@@ -225,6 +226,7 @@ public class MacroCorrelation {
macro_scan.tile_op, // per-tile operation bit codes
macro_scan.disparity, // clt_parameters.disparity, // final double disparity,
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
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
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,6 +36,7 @@ public class TileProcessor {
private int tilesY;
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 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
// or (superTileSize*tileSize) * (superTileSize*tileSize) pixels, currently 64x64 pixels)
......@@ -53,6 +54,7 @@ public class TileProcessor {
int superTileSize,
double scale,
double trustedCorrelation,
double maxOverexposure,
int threadsMax)
{
this.tilesX = tilesX;
......@@ -61,6 +63,7 @@ public class TileProcessor {
this.superTileSize = superTileSize;
this.corr_magic_scale = scale;
this.trustedCorrelation = trustedCorrelation;
this.maxOverexposure = maxOverexposure;
this.threadsMax = threadsMax;
}
public int getTilesX() {return tilesX;};
......@@ -75,6 +78,14 @@ public class TileProcessor {
{
return this.trustedCorrelation;
}
public void setMaxOverexposure(double maxOverexposure)
{
this.maxOverexposure = maxOverexposure;
}
public double getMaxOverexposure()
{
return this.maxOverexposure;
}
public double getMagicScale()
{
return this.corr_magic_scale;
......@@ -373,6 +384,7 @@ public class TileProcessor {
* @param firstPass index of the first 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 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_near highest disparity value to consider (does not apply to max_tried_disparity)
* @param minStrength full correlation strength to consider data to be reliable
......@@ -389,6 +401,7 @@ public class TileProcessor {
final int firstPass,
final int lastPassPlus1,
final double trustedCorrelation,
final double max_overexposure,
final double disp_far, // limit results to the disparity range
final double disp_near,
final double minStrength,
......@@ -478,6 +491,10 @@ public class TileProcessor {
double strength_hor = pass.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH][nt];
double strength_vert = pass.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH][nt];
boolean overexposed = (max_overexposure > 0.0) &&
(pass.disparity_map[ImageDtt.OVEREXPOSED] != null) &&
(pass.disparity_map[ImageDtt.OVEREXPOSED][nt] > max_overexposure);
if (!overexposed) {
double adiff = Math.abs(mdisp);
double adiff_hor = Math.abs(mdisp_hor);
double adiff_vert = Math.abs(mdisp_vert);
......@@ -485,7 +502,7 @@ public class TileProcessor {
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 ((bg_tiles == null) || !bg_tiles[nt] || (disp >= ex_min_over)) {
if ((disp >= disp_far) && (disp <= disp_near) && !Double.isNaN(adiff)){
if (strength >= minStrength) {
if (!(adiff >= adiff_best)){ // adiff_best == Double.NaN works too
......@@ -499,7 +516,7 @@ public class TileProcessor {
}
}
}
// }
// }
}
if (!Double.isNaN(minStrengthHor) && (adiff_hor <= trustedCorrelation)){
......@@ -537,6 +554,7 @@ public class TileProcessor {
}
}
}
}
if (best_index < 0) best_index = best_weak_index;
if (best_index_hor < 0) best_index_hor = best_weak_index_hor;
if (best_index_vert < 0) best_index_vert = best_weak_index_vert;
......@@ -1544,8 +1562,8 @@ public class TileProcessor {
// scan.restoreKeepTileOpDisparity();// it is not used from this scan, but from last_scan
continue;
}
if (debugLevel > 0){
System.out.println("prepareExpandVariants(): remaining "+num_left+" tiles to be processed, used variant "+num_var);
if (debugLevel > -1){
System.out.println("prepareExpandVariants(): remaining "+num_left+" tiles to be processed, used variant "+num_var+" ("+num_left+")");
}
int [] rslt = {num_left, num_var};
return rslt;
......@@ -2060,7 +2078,7 @@ public class TileProcessor {
sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
String [] titles = {
"tile_op", // 0
"final", // 1 - calculated, filetered, combined disparity
"final", // 1 - calculated, filtered, combined disparity
"disparity", // 2
"disp_cm", // 3
"disp_hor", // 4
......@@ -2078,7 +2096,8 @@ public class TileProcessor {
"diff3", // 16
"diff2max", // 17
"diff2maxAvg", // 18
"normStrength"}; // 19
"normStrength", // 19
"overexp"}; // 20
int tlen = tilesX*tilesY;
......@@ -2101,12 +2120,13 @@ public class TileProcessor {
double [] strength4 = null;
if (scan.disparity_map != null){
strength4 = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[3] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM];
dbg_img[4] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR];
dbg_img[5] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT];
dbg_img[7] = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[8] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH];
dbg_img[9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
dbg_img[ 3] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_CM];
dbg_img[ 4] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR];
dbg_img[ 5] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT];
dbg_img[ 7] = scan.disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX];
dbg_img[ 8] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_HOR_STRENGTH];
dbg_img[ 9] = scan.disparity_map[ImageDtt.DISPARITY_INDEX_VERT_STRENGTH];
dbg_img[20] = scan.disparity_map[ImageDtt.OVEREXPOSED];
}
dbg_img[1] = scan.calc_disparity_combo;
dbg_img[6] = scan.strength;
......@@ -3681,9 +3701,6 @@ public class TileProcessor {
for (int i = 0; i<dbg_img[0].length;i++){
dbg_img[ 0][i] = this_disparity_masked[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[ 6][i] = far_tiles [i] ? 1 : -1;
dbg_img[ 7][i] = dbg_before_small [i] ? 1 : -1;
......@@ -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_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity
true);
if (debugLevel > -1){
if (debugLevel > 0){
System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles.");
}
replaced0 = replaced.clone();
......@@ -4263,28 +4280,6 @@ public class TileProcessor {
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
......@@ -4587,30 +4582,8 @@ public class TileProcessor {
name + "-TXTOL-D",
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
}
/*
if (clt_parameters.show_rgba_color) {
// for now - use just RGB. Later add oprion for RGBA
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]};
double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]};
// ImagePlus img_texture =
linearStackToColor(
clt_parameters,
colorProcParameters,
rgbParameters,
name+"-texture", // String name,
"-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 );
}
*/
}
if (debugLevel > -1) {
double [][] tiles_tone = scan_prev.getTileRBGA(
12); // int num_layers);
sdfa_instance.showArrays(
......@@ -4621,6 +4594,7 @@ public class TileProcessor {
name + "tiles_tone",
(clt_parameters.keep_weights?rgba_weights_titles:rgba_titles));
}
}
TileAssignment ta = new TileAssignment(
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
tileSurface, // TileSurface ts,
......@@ -4630,14 +4604,17 @@ public class TileProcessor {
Double.NaN, // double kR,
Double.NaN, // double kB,
Double.NaN); // double fatZero)
if (debugLevel > -1) {
ta.showToneDiffWeights3("Raw_");
ta.showToneDiffWeights1("Raw_");
}
ta.blurMixTones(
false, // final boolean use_sqrt,
true); //final boolean weighted) // blur weighted
if (debugLevel >-1) {
ta.showToneDiffWeights3("Mixed_");
ta.showToneDiffWeights1("Mixed_");
}
// }
......@@ -4868,7 +4845,8 @@ public class TileProcessor {
}
}
tileSurface.compareAssignments(
tile_assignments); // final int [][][] tileAssignments)
tile_assignments, // final int [][][] tileAssignments)
debugLevel); //
int [][][] opinions = new int [tile_layers.length][][];
tile_layers = tileSurface.getConsensusAssignment(
......@@ -4887,8 +4865,10 @@ public class TileProcessor {
}
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "tile_layers_surf");
}
if (debugLevel > -1) {
ta.showTileCost("before_",tile_layers_surf);
ta.showTileCosts("before_",tile_layers_surf);
}
TileAssignment.TACosts [] ta_stats = ta.statTileCosts(tile_layers_surf);
for (int i = 0; i < ta_stats.length; i++){
......@@ -4913,8 +4893,12 @@ public class TileProcessor {
}
(new showDoubleFloatArrays()).showArrays(dbg_tls, ta.getSurfTilesX(), ta.getSurfTilesY(), true, "optimized_tile_layers_surf");
}
if (debugLevel > -2) {
ta.showTileCost("after_",tile_layers_surf);
}
if (debugLevel > -1) {
ta.showTileCosts("after_",tile_layers_surf);
}
ta_stats = ta.statTileCosts(tile_layers_surf);
System.out.println("Optimized:");
for (int i = 0; i < ta_stats.length; i++){
......@@ -4935,7 +4919,7 @@ public class TileProcessor {
tileSel, // final boolean [][] tileSel,
debugLevel); // final int debugLevel,
if (clt_parameters.tsShow){
if (clt_parameters.tsShow && (debugLevel > -2)){
tileSurface.showAssignment(
"assignments", // String title,
dispStrength); // final double [][][] dispStrength)
......@@ -5058,7 +5042,7 @@ public class TileProcessor {
clt_parameters.tileX,
clt_parameters.tileY);
if (clt_parameters.tsShow){
if (clt_parameters.tsShow && (debugLevel > -1)){
int numToShow = clt_parameters.tsNumClust;
int num_surf = tileSurface.getSurfaceDataLength();
if (numToShow > num_surf) numToShow = num_surf;
......@@ -5223,7 +5207,7 @@ public class TileProcessor {
// Trying new class
LinkPlanes lp = new LinkPlanes (clt_parameters, st);
if (clt_parameters.show_planes){
if (clt_parameters.show_planes && (debugLevel > -1)){
showPlaneData(
"initial",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -5568,7 +5552,7 @@ public class TileProcessor {
true, // final boolean weak_connected, // select connected planes even if they are weak/thick
st.getPlanesMod());
if (clt_parameters.show_planes){
if (clt_parameters.show_planes && (debugLevel > -2)){
showPlaneData(
"final",
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
......@@ -5582,7 +5566,7 @@ public class TileProcessor {
clt_parameters.msScaleProj, // final double scale_projection,
clt_parameters.msFractUni, // final double fraction_uni,
st.planes_mod, // st.planes, // final TilePlanes.PlaneData [][] planes,
0, // -1, // debugLevel, // final int debugLevel)
debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
......@@ -5951,7 +5935,7 @@ public class TileProcessor {
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); //
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
CLTPass3d scan_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;
if (debugLevel > -1) sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
......@@ -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_force_disp, // boolean force_disparity // copy disparity down (false - use horDisparity
true);
if (debugLevel > -1){
if (debugLevel > 0){
System.out.println("fixVerticalPoles() replaced "+ numFixed+ " tiles.");
}
// replaced0 = replaced.clone();
......
......@@ -1671,8 +1671,9 @@ public class TileSurface {
debugLevel, // final int debugLevel,
dbg_X, // final int dbg_X,
dbg_Y); // final int dbg_Y);
if (debugLevel >- 1) {
showSurfaceDS (tileData, "tileData");
}
this.tileData = tileData;
return tileData;
}
......@@ -2220,7 +2221,8 @@ public class TileSurface {
}
public void compareAssignments(
final int [][][] tileAssignments)
final int [][][] tileAssignments,
final int debugLevel)
{
final int imgTiles = imageTilesX * imageTilesY;
final int num_in = tileAssignments.length;
......@@ -2259,9 +2261,11 @@ public class TileSurface {
img_data[num_in+1][nTile] = combo[nTile];
}
if (debugLevel > -1) {
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays();
sdfa_instance.showArrays(img_data, imageTilesX, imageTilesY, true, "consensus",titles);
}
}
public int [][] getConsensusAssignment(
final int min_agree,
......
......@@ -49,6 +49,8 @@ public class WavefrontExport {
public int v_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 String obj_path;
public String mtl_path;
public WavefrontExport(
String out_dir,
......@@ -61,8 +63,10 @@ public class WavefrontExport {
this.correctionsParameters = correctionsParameters;
this.geometry_correction = geometry_correction;
this.clt_3d_passes = clt_3d_passes;
mtl_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT);
obj_writer = new FileWriter(out_dir+Prefs.getFileSeparator()+project_name+OBJ_EXT); // .close();
mtl_path = out_dir+Prefs.getFileSeparator()+project_name+MTL_EXT;
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");
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");
......
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