Commit 65bac413 authored by Andrey Filippov's avatar Andrey Filippov

detecting periodic by a single camera

parent b5f3d42a
......@@ -2892,6 +2892,17 @@ public class EyesisCorrectionParameters {
public double fds_abs_tilt = 2.0; // pix per tile
public double fds_rel_tilt = 0.2; // (pix / disparity) per tile
public boolean per_filter = true; // detect and filter periodic structures
public double per_trustedCorrelation = 2.0;
public double per_initial_diff = 0.8; // initial disparity difference to merge to maximum
public double per_strength_floor = 0.1; //
public double per_strength_max_over = 0.03; //
public double per_min_period = 4.0; //
public int per_min_num_periods = 3; // minimal number of periods
public double per_disp_tolerance = 1.0; // maximal difference between the average of fundamental and
public double per_disp_match = 1.0; // disparity difference to match neighbors
public double per_strong_match_inc = 0.02; // extra strength to treat match as strong (for hysteresis)
// Macro disparity scanning parameters
public double mc_disp8_step = 2.0; // Macro disparity scan step (actual disparity step is 8x)
public double mc_disp8_trust = 2.0; //Trust measured disparity within +/- this value
......@@ -2909,9 +2920,6 @@ public class EyesisCorrectionParameters {
public double mc_weight_Y = 1.0; // weight of average intensity
public double mc_weight_RBmG = 5.0; // weight of average color difference (0.5*(R+B)-G), shoukld be ~5*weight_Y
// 0x1e, // 0x1f, // final int variants_mask,
public int gr_min_new = 20; // Discard variant if it requests too few tiles
public boolean gr_var_new_sngl = false;// Expand only unambiguous tiles over previously undefined
......@@ -3594,6 +3602,17 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"fds_abs_tilt", this.fds_abs_tilt +"");
properties.setProperty(prefix+"fds_rel_tilt", this.fds_rel_tilt +"");
properties.setProperty(prefix+"per_filter", this.per_filter +"");
properties.setProperty(prefix+"per_trustedCorrelation", this.per_trustedCorrelation +"");
properties.setProperty(prefix+"per_initial_diff", this.per_initial_diff +"");
properties.setProperty(prefix+"per_strength_floor", this.per_strength_floor +"");
properties.setProperty(prefix+"per_strength_max_over", this.per_strength_max_over +"");
properties.setProperty(prefix+"per_min_period", this.per_min_period +"");
properties.setProperty(prefix+"per_min_num_periods", this.per_min_num_periods +"");
properties.setProperty(prefix+"per_disp_tolerance", this.per_disp_tolerance +"");
properties.setProperty(prefix+"per_disp_match", this.per_disp_match +"");
properties.setProperty(prefix+"per_strong_match_inc", this.per_strong_match_inc +"");
properties.setProperty(prefix+"mc_disp8_step", this.mc_disp8_step +"");
properties.setProperty(prefix+"mc_disp8_trust", this.mc_disp8_trust +"");
properties.setProperty(prefix+"mc_strength", this.mc_strength +"");
......@@ -4282,6 +4301,18 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"fds_abs_tilt")!=null) this.fds_abs_tilt=Double.parseDouble(properties.getProperty(prefix+"fds_abs_tilt"));
if (properties.getProperty(prefix+"fds_rel_tilt")!=null) this.fds_rel_tilt=Double.parseDouble(properties.getProperty(prefix+"fds_rel_tilt"));
if (properties.getProperty(prefix+"per_filter")!=null) this.per_filter=Boolean.parseBoolean(properties.getProperty(prefix+"per_filter"));
if (properties.getProperty(prefix+"per_trustedCorrelation")!=null) this.per_trustedCorrelation=Double.parseDouble(properties.getProperty(prefix+"per_trustedCorrelation"));
if (properties.getProperty(prefix+"per_initial_diff")!=null) this.per_initial_diff=Double.parseDouble(properties.getProperty(prefix+"per_initial_diff"));
if (properties.getProperty(prefix+"per_strength_floor")!=null) this.per_strength_floor=Double.parseDouble(properties.getProperty(prefix+"per_strength_floor"));
if (properties.getProperty(prefix+"per_strength_max_over")!=null) this.per_strength_max_over=Double.parseDouble(properties.getProperty(prefix+"per_strength_max_over"));
if (properties.getProperty(prefix+"per_min_period")!=null) this.per_min_period=Double.parseDouble(properties.getProperty(prefix+"per_min_period"));
if (properties.getProperty(prefix+"per_min_num_periods")!=null) this.per_min_num_periods=Integer.parseInt(properties.getProperty(prefix+"per_min_num_periods"));
if (properties.getProperty(prefix+"per_disp_tolerance")!=null) this.per_disp_tolerance=Double.parseDouble(properties.getProperty(prefix+"per_disp_tolerance"));
if (properties.getProperty(prefix+"per_disp_match")!=null) this.per_disp_match=Double.parseDouble(properties.getProperty(prefix+"per_disp_match"));
if (properties.getProperty(prefix+"per_strong_match_inc")!=null) this.per_strong_match_inc=Double.parseDouble(properties.getProperty(prefix+"per_strong_match_inc"));
if (properties.getProperty(prefix+"mc_disp8_step")!=null) this.mc_disp8_step=Double.parseDouble(properties.getProperty(prefix+"mc_disp8_step"));
if (properties.getProperty(prefix+"mc_disp8_trust")!=null) this.mc_disp8_trust=Double.parseDouble(properties.getProperty(prefix+"mc_disp8_trust"));
if (properties.getProperty(prefix+"mc_strength")!=null) this.mc_strength=Double.parseDouble(properties.getProperty(prefix+"mc_strength"));
......@@ -5055,6 +5086,29 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Maximal growing plate tilt in disparity pix per tile", this.fds_abs_tilt, 6);
gd.addNumericField("Maximal relative growing plate tilt in disparity pix per tile per disparity pixel", this.fds_rel_tilt, 6);
gd.addTab ("Periodic", "Detect and filter periodic features");
gd.addCheckbox ("Apply filter to remove false correlations of periodic structures", this.per_filter,
"Detect repetitive features (such as windows grid) and remove false matches");
gd.addNumericField("Maximal residual disparity difference to use for periodic features", this.per_trustedCorrelation, 4, 6,"pix",
"do not trust correlation results with larger absolute value of residual disparity");
gd.addNumericField("Initial half-width of the disparity range per cluster", this.per_initial_diff, 4, 6,"pix",
"Select tiles this far from the local maximums");
gd.addNumericField("Strength floor to detect periodic features", this.per_strength_floor, 4, 6,"",
"Only use stronger correlations, subtract this value for weighted averages");
gd.addNumericField("Maximums seeds should have at least this much over strength floor", this.per_strength_max_over, 4, 6,"",
"When growing clusters, only start with the correlations this much stronger than strength floor ");
gd.addNumericField("Minimal feature period", this.per_min_period, 4, 6,"",
"Only detect/filter feature that have period above this value");
gd.addNumericField("Minimal number of periods in periodic structures", this.per_min_num_periods, 0, 2,"",
"Minimal number of full periods to be detected");
gd.addNumericField("Maximal period variations", this.per_disp_tolerance, 4, 6,"pix",
"The detected periods should be higher than this value");
gd.addNumericField("Disparity difference to match neighbors", this.per_disp_match, 0, 2,"",
"Neighbor tiles should have smaller disparity difference from gthe center to qualify");
gd.addNumericField("Extra strength to treat match as strong (for hysteresis)", this.per_strong_match_inc, 0, 2,"",
"The layer that does not have any match in the direction where some other layer has a strong match will be removed");
gd.addTab ("Macro", "Macro tiles correlation parameters");
gd.addMessage ("--- Macro correlation parameters ---");
gd.addNumericField("Macro disparity scan step (actual disparity step is 8x)", this.mc_disp8_step, 6);
......@@ -5771,6 +5825,17 @@ public class EyesisCorrectionParameters {
this.fds_abs_tilt= gd.getNextNumber();
this.fds_rel_tilt= gd.getNextNumber();
this.per_filter= gd.getNextBoolean();
this.per_trustedCorrelation= gd.getNextNumber();
this.per_initial_diff= gd.getNextNumber();
this.per_strength_floor= gd.getNextNumber();
this.per_strength_max_over= gd.getNextNumber();
this.per_min_period= gd.getNextNumber();
this.per_min_num_periods=(int) gd.getNextNumber();
this.per_disp_tolerance= gd.getNextNumber();
this.per_disp_match= gd.getNextNumber();
this.per_strong_match_inc= gd.getNextNumber();
this.mc_disp8_step= gd.getNextNumber();
this.mc_disp8_trust= gd.getNextNumber();
this.mc_strength= gd.getNextNumber();
......
......@@ -571,6 +571,7 @@ private Panel panel1,
addButton("CM Test", panelClt3, color_stop);
addButton("Show scan", panelClt3, color_configure);
addButton("Show all scans", panelClt3, color_configure);
addButton("Periodic", panelClt3, color_configure);
add(panelClt3);
}
......@@ -4373,6 +4374,23 @@ private Panel panel1,
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
return;
} else if (label.equals("Periodic")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
System.out.println("QUAD_CLT is null, nothing to show");
return;
}
QUAD_CLT.showPeriodic(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
return;
} else if (label.equals("CLT ASSIGN")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
......
......@@ -83,6 +83,11 @@ public class GeometryCorrection {
public CorrVector extrinsic_corr;
public RigOffset rigOffset = null;
int [] woi_tops; // used to calculate scanline timing
public int [] getWOITops() {
return woi_tops;
}
public int [] getSensorWH() {
......
......@@ -7589,7 +7589,7 @@ public class ImageDtt {
final double [][][][][][] clt_kernels_aux, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
final double corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
final boolean keep_clt_data,
final int [][] woi_tops,
// final int [][] woi_tops,
final double [][][] ers_delay, // if not null - fill with tile center acquisition delay
final int threadsMax, // maximal number of threads to launch
final int debugLevel)
......@@ -7828,8 +7828,8 @@ public class ImageDtt {
disparity_aux); // + disparity_corr);
// acquisition time of the tiles centers in scanline times
if (ers_delay != null) {
for (int i = 0; i < quad_main; i++) ers_delay[0][i][nTile] = centersXY_main[i][1]-woi_tops[0][i];
for (int i = 0; i < quad_aux; i++) ers_delay[1][i][nTile] = centersXY_aux[i][1]- woi_tops[1][i];
for (int i = 0; i < quad_main; i++) ers_delay[0][i][nTile] = centersXY_main[i][1]-geometryCorrection_main.woi_tops[i];
for (int i = 0; i < quad_aux; i++) ers_delay[1][i][nTile] = centersXY_aux[i][1]- geometryCorrection_aux.woi_tops[i];
}
if ((globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)) {
......
......@@ -80,7 +80,7 @@ public class QuadCLT {
double [][][] image_data = null;
boolean [][] saturation_imp = null; // (near) saturated pixels or null
boolean is_aux = false;
int [] woi_tops; // used to calculate scanline timing
// int [] woi_tops; // used to calculate scanline timing
// magic scale should be set before using TileProcessor (calculated disparities depend on it)
......@@ -2672,7 +2672,7 @@ public class QuadCLT {
}
ImagePlus [] imp_srcs = new ImagePlus[channelFiles.length];
this.woi_tops = new int [channelFiles.length];
this.geometryCorrection.woi_tops = new int [channelFiles.length];
double [] scaleExposures = new double[channelFiles.length];
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
int nFile=channelFiles[srcChannel];
......@@ -2707,7 +2707,7 @@ public class QuadCLT {
imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate);
woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
scaleExposures[srcChannel] = 1.0;
if (!Double.isNaN(referenceExposures[nFile]) && (imp_srcs[srcChannel].getProperty("EXPOSURE")!=null)){
scaleExposures[srcChannel] = referenceExposures[nFile]/Double.parseDouble((String) imp_srcs[srcChannel].getProperty("EXPOSURE"));
......@@ -3367,7 +3367,7 @@ public class QuadCLT {
int debugLevel)
{
ImagePlus [] imp_srcs = new ImagePlus[channelFiles.length];
this.woi_tops = new int [channelFiles.length];
this.geometryCorrection.woi_tops = new int [channelFiles.length];
// double [] scaleExposures = new double[channelFiles.length]; //
double [][] dbg_dpixels = new double [channelFiles.length][];
// int [] fullWindowWH = geometryCorrection.getSensorWH();
......@@ -3404,7 +3404,7 @@ public class QuadCLT {
}
// imp_srcs[srcChannel].show(); // REMOVE ME!
woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
imp_srcs[srcChannel] = padBayerToFullSize(
imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
......@@ -4869,7 +4869,7 @@ public class QuadCLT {
}
ImagePlus [] imp_srcs = new ImagePlus[channelFiles.length];
this.woi_tops = new int [channelFiles.length];
this.geometryCorrection.woi_tops = new int [channelFiles.length];
boolean [][] saturation_imp = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
double [] scaleExposures = new double[channelFiles.length];
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
......@@ -4905,7 +4905,7 @@ public class QuadCLT {
imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate);
woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
scaleExposures[srcChannel] = 1.0;
if (!Double.isNaN(referenceExposures[nFile]) && (imp_srcs[srcChannel].getProperty("EXPOSURE")!=null)){
scaleExposures[srcChannel] = referenceExposures[nFile]/Double.parseDouble((String) imp_srcs[srcChannel].getProperty("EXPOSURE"));
......@@ -7440,6 +7440,50 @@ public class QuadCLT {
"after_combo_pass-"+(passes.size() -1)); // (refine_pass)); //String title)
return num_extended; // [0];
}
// Separate method to detect and remove periodic structures
public boolean showPeriodic(
EyesisCorrectionParameters.CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel) {
final boolean usePoly = false; // use polynomial method to find max), valid if useCombo == false
double [][] periodics = tp.getPeriodics(
tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,// List, first, last - to search for the already tried disparity
0, // final int firstPass,
tp.clt_3d_passes.size(), // final int lastPassPlus1,
clt_parameters.per_trustedCorrelation,// final double trustedCorrelation,
clt_parameters.per_initial_diff, // final double initial_diff, // initial disparity difference to merge to maximum
clt_parameters.per_strength_floor, // final double strength_floor,
clt_parameters.per_strength_max_over, // final double strength_max_over, // maximum should have strength by this more than the floor
clt_parameters.per_min_period, // final double min_period,
clt_parameters.per_min_num_periods, // final int min_num_periods, // minimal number of periods
clt_parameters.per_disp_tolerance, // final double disp_tolerance, // maximal difference between the average of fundamental and 2-nd and first
// TODO: replace next parameter
clt_parameters.per_disp_tolerance, // final double disp_tol_center, // tolerance to match this (center) tile ds to that of the merged with neighbors - should be < min_period/2
clt_parameters.per_disp_match, // final double disp_match, // disparity difference to match neighbors
clt_parameters.per_strong_match_inc, // final double strong_match_inc, // extra strength to treat match as strong (for hysteresis)
usePoly, // final boolean usePoly, // use polynomial method to find max), valid if useCombo == false
clt_parameters.tileX, // final int dbg_tileX,
clt_parameters.tileY, // final int dbg_tileY,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
debugLevel+3); // final int debugLevel) // update status info
String [] dbg_titles= {"fundamental","period", "strength", "num_layers"};
(new showDoubleFloatArrays()).showArrays(
periodics,
tp.getTilesX(),
periodics[0].length/tp.getTilesX(),
true,
image_name+"-PERIODIC",
dbg_titles);
return true;
}
//*****************************************************************
......@@ -8714,7 +8758,7 @@ public class QuadCLT {
}
ImagePlus [] imp_srcs = new ImagePlus[channelFiles.length];
this.woi_tops = new int [channelFiles.length];
this.geometryCorrection.woi_tops = new int [channelFiles.length];
double [][] dbg_dpixels = batch_mode? null : (new double [channelFiles.length][]);
for (int srcChannel=0; srcChannel<channelFiles.length; srcChannel++){
......@@ -8750,7 +8794,7 @@ public class QuadCLT {
imp_srcs[srcChannel], // ImagePlus imp_src,
eyesisCorrections.pixelMapping.sensors[srcChannel].getSensorWH(),
true); // boolean replicate);
woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
this.geometryCorrection.woi_tops[srcChannel] = Integer.parseInt((String) imp_srcs[srcChannel].getProperty("WOI_TOP"));
scaleExposures[srcChannel] = 1.0;
if (!Double.isNaN(referenceExposures[nFile]) && (imp_srcs[srcChannel].getProperty("EXPOSURE")!=null)){
scaleExposures[srcChannel] = referenceExposures[nFile]/Double.parseDouble((String) imp_srcs[srcChannel].getProperty("EXPOSURE"));
......
This diff is collapsed.
......@@ -406,7 +406,7 @@ public class TwoQuadCLT {
ImageDtt image_dtt = new ImageDtt();
double [][] ml_data = null;
int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
// int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
final double [][][] ers_delay = get_ers?(new double [2][][]):null;
......@@ -439,7 +439,7 @@ public class TwoQuadCLT {
quadCLT_aux.getCLTKernels(), // final double [][][][][][] clt_kernels_aux, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.corr_magic_scale, // final double corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
true, // final boolean keep_clt_data,
woi_tops, // final int [][] woi_tops,
// woi_tops, // final int [][] woi_tops,
ers_delay, // final double [][][] ers_delay, // if not null - fill with tile center acquisition delay
threadsMax, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel);
......@@ -1946,7 +1946,7 @@ if (debugLevel > -100) return true; // temporarily !
}
}
ImageDtt image_dtt = new ImageDtt();
int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
// int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
image_dtt.clt_bi_quad (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
clt_parameters.fat_zero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
......@@ -1974,7 +1974,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux.getCLTKernels(), // final double [][][][][][] clt_kernels_aux, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.corr_magic_scale, // final double corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
false, // true, // final boolean keep_clt_data,
woi_tops, // final int [][] woi_tops,
// woi_tops, // final int [][] woi_tops,
null, // final double [][][] ers_delay, // if not null - fill with tile center acquisition delay
threadsMax, // final int threadsMax, // maximal number of threads to launch
debugLevel-2); // final int globalDebugLevel);
......@@ -2154,7 +2154,7 @@ if (debugLevel > -100) return true; // temporarily !
clt_parameters.rig.ml_show_ml, // boolean show,
debugLevel); // int debugLevel
Runtime.getRuntime().gc();
System.out.println("Generated ML data, offset = "+disparity_offset+", --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
System.out.println("Generated ML data, offset = "+String.format("%8.5f",disparity_offset)+", --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
}
......@@ -5537,7 +5537,7 @@ if (debugLevel > -100) return true; // temporarily !
double [][] disparity_bimap = new double [ImageDtt.BIDISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
// int [][] woi_tops = {quadCLT_main.woi_tops,quadCLT_aux.woi_tops};
image_dtt.clt_bi_quad (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
......@@ -5564,7 +5564,7 @@ if (debugLevel > -100) return true; // temporarily !
quadCLT_aux.getCLTKernels(), // final double [][][][][][] clt_kernels_aux, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.corr_magic_scale, // final double corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
false, // true, // final boolean keep_clt_data,
woi_tops, // final int [][] woi_tops,
// woi_tops, // final int [][] woi_tops,
null, // final double [][][] ers_delay, // if not null - fill with tile center acquisition delay
threadsMax, // final int threadsMax, // maximal number of threads to launch
debugLevel-2); // final int globalDebugLevel);
......
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