Commit 21cc4033 authored by Andrey Filippov's avatar Andrey Filippov

fixed lazy eye correction

parent f2fa612b
This diff is collapsed.
...@@ -4609,10 +4609,16 @@ private Panel panel1, ...@@ -4609,10 +4609,16 @@ private Panel panel1,
System.out.println("Created new QuadCLT instance, will need to read CLT kernels"); System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
} }
} }
/*
QUAD_CLT.process_fine_corr( QUAD_CLT.process_fine_corr(
dry_run, // boolean dry_run dry_run, // boolean dry_run
CLT_PARAMETERS, CLT_PARAMETERS,
DEBUG_LEVEL); DEBUG_LEVEL);
*/
QUAD_CLT.processLazyEye(
CLT_PARAMETERS,
DEBUG_LEVEL);
return; return;
} else if (label.equals("CLT ext infinity corr")) { } else if (label.equals("CLT ext infinity corr")) {
......
...@@ -964,6 +964,7 @@ public class ImageDtt { ...@@ -964,6 +964,7 @@ public class ImageDtt {
final double [][][][][] clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate final double [][][][][] clt_corr_partial,// [tilesY][tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
// [tilesY][tilesX] should be set by caller // [tilesY][tilesX] should be set by caller
final double [][] clt_mismatch, // [12][tilesY * tilesX] // transpose unapplied. null - do not calculate final double [][] clt_mismatch, // [12][tilesY * tilesX] // transpose unapplied. null - do not calculate
// values in the "main" directions have disparity (*_CM) subtracted, in the perpendicular - as is
final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate final double [][] disparity_map, // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
// last 2 - contrast, avg/ "geometric average) // last 2 - contrast, avg/ "geometric average)
...@@ -1606,11 +1607,11 @@ public class ImageDtt { ...@@ -1606,11 +1607,11 @@ public class ImageDtt {
double yp,xp; double yp,xp;
if (corr_pairs[pair][2] > 0){ // transpose - switch x <-> y if (corr_pairs[pair][2] > 0){ // transpose - switch x <-> y
yp = transform_size - 1 -corr_max_XYmp[0] - disparity_map[DISPARITY_INDEX_CM][tIndex]; yp = transform_size - 1 -corr_max_XYmp[0] - disparity_map[DISPARITY_INDEX_CM][tIndex];
xp = transform_size - 1 -corr_max_XYmp[1]; // do not campare to average - it should be 0 anyway xp = transform_size - 1 -corr_max_XYmp[1]; // do not compare to average - it should be 0 anyway
} else { } else {
xp = transform_size - 1 -corr_max_XYmp[0] - disparity_map[DISPARITY_INDEX_CM][tIndex]; xp = transform_size - 1 -corr_max_XYmp[0] - disparity_map[DISPARITY_INDEX_CM][tIndex];
yp = transform_size - 1 -corr_max_XYmp[1]; // do not campare to average - it should be 0 anyway yp = transform_size - 1 -corr_max_XYmp[1]; // do not compare to average - it should be 0 anyway
} }
double strength = tcorr_partial[pair][numcol][max_index]; // using the new location than for combined double strength = tcorr_partial[pair][numcol][max_index]; // using the new location than for combined
clt_mismatch[3*pair + 0 ][tIndex] = xp; clt_mismatch[3*pair + 0 ][tIndex] = xp;
......
...@@ -5237,22 +5237,22 @@ public class QuadCLT { ...@@ -5237,22 +5237,22 @@ public class QuadCLT {
double [][][] new_corr = ac.infinityCorrection( double [][][] new_corr = ac.infinityCorrection(
clt_parameters.fcorr_inf_strength, // final double min_strenth, clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff, clt_parameters.fcorr_inf_diff, // final double max_diff,
20, // 0, // final int max_iterations, clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
0.0001, // final double max_coeff_diff, clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5; clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
1.0, // final double strength_pow, clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
3, // final int smplSide, // = 2; // Sample size (side of a square) clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
5, // final int smplNum, // = 3; // Number after removing worst (should be >1) clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters // histogram parameters
8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
-1.0, // final double hist_disp_min, clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
0.05, // final double hist_disp_step, clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
40, // final int hist_num_bins, clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
0.1, // final double hist_sigma, clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
0.1, // final double hist_max_diff, clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
10, // final int hist_min_samples, clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
inf_disp_strength, // double [][] disp_strength, inf_disp_strength, // double [][] disp_strength,
tilesX, // int tilesX, tilesX, // int tilesX,
...@@ -5260,6 +5260,8 @@ public class QuadCLT { ...@@ -5260,6 +5260,8 @@ public class QuadCLT {
debugLevel + 1); // int debugLevel) debugLevel + 1); // int debugLevel)
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("process_infinity_corr(): ready to apply infinity correction"); System.out.println("process_infinity_corr(): ready to apply infinity correction");
show_fine_corr( show_fine_corr(
...@@ -5274,11 +5276,85 @@ public class QuadCLT { ...@@ -5274,11 +5276,85 @@ public class QuadCLT {
debugLevel + 2); debugLevel + 2);
} }
} }
public void processLazyEye(
EyesisCorrectionParameters.CLTParameters clt_parameters,
int debugLevel
) {
ImagePlus imp_src = WindowManager.getCurrentImage();
if (imp_src==null){
IJ.showMessage("Error","2*n-layer file with disparities/strengthspairs measured at infinity is required");
return;
}
ImageStack disp_strength_stack= imp_src.getStack();
final int tilesX = disp_strength_stack.getWidth(); // tp.getTilesX();
final int tilesY = disp_strength_stack.getHeight(); // tp.getTilesY();
final int nTiles =tilesX * tilesY;
AlignmentCorrection ac = new AlignmentCorrection(this);
double [][] scans = ac.getFineCorrFromImage(
imp_src,
// 0.2, // double min_comp_strength, // 0.2
debugLevel);
double [][][] new_corr = ac.lazyEyeCorrection(
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff,
1.3, // final double comp_strength_var,
clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
1.5, // final double lazyEyeCompDiff, // clt_parameters.fcorr_disp_diff
clt_parameters.inf_smpl_side, // final int lazyEyeSmplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // final int lazyEyeSmplNum, // = 3; // Number after removing worst (should be >1)
0.1, // final double lazyEyeSmplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
0.2, // final double lazyEyeDispVariation, // 0.2, maximal full disparity difference between tgh tile and 8 neighborxs
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
0.5, // final double inf_fraction, // fraction of the weight for the infinity tiles
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
scans, // double [][] disp_strength,
tilesX, // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel + 1); // int debugLevel)
if (debugLevel > -100){
apply_fine_corr(
new_corr,
debugLevel + 2);
}
}
public void process_fine_corr( public void process_fine_corr(
boolean dry_run, boolean dry_run,
EyesisCorrectionParameters.CLTParameters clt_parameters, EyesisCorrectionParameters.CLTParameters clt_parameters,
int debugLevel int debugLevel
) { ) {
if (dry_run) {
AlignmentCorrection ac = new AlignmentCorrection(this);
ac.process_fine_corr(
dry_run, // boolean dry_run,
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
debugLevel); // int debugLevel
return;
}
ImagePlus imp_src = WindowManager.getCurrentImage(); ImagePlus imp_src = WindowManager.getCurrentImage();
if (imp_src==null){ if (imp_src==null){
IJ.showMessage("Error","12*n-layer file clt_mismatches is required"); IJ.showMessage("Error","12*n-layer file clt_mismatches is required");
......
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