Commit 8c2ea7ed authored by Andrey Filippov's avatar Andrey Filippov
Browse files

debugging batch dsi

parent e12c624a
Loading
Loading
Loading
Loading
+50 −5
Original line number Original line Diff line number Diff line
@@ -586,6 +586,15 @@ public class CLTParameters {
	public double     gr_unique_tol        =   0.15; // Do not re-measure correlation if target disparity differs from some previous by this
	public double     gr_unique_tol        =   0.15; // Do not re-measure correlation if target disparity differs from some previous by this
	public double     gr_unique_pretol     =   0.5;  // Larger tolerance for expanding (not refining)
	public double     gr_unique_pretol     =   0.5;  // Larger tolerance for expanding (not refining)
	
	
	public int        gr_max_clust_radius  =     4; // 7x7
	public int        gr_num_refines =           4;
	public boolean    gr_exp_certain =           false;

	public boolean    gr_reduce_sngl =           true;
	public boolean    gr_reduce_multi =          true;
	public boolean    gr_all_last =              true;
	public boolean    gr_nan_bg =                true;
	


	public boolean    ft_mod_strength =          true;    // When set, multiply each tile strength by the number of selected neighbors
	public boolean    ft_mod_strength =          true;    // When set, multiply each tile strength by the number of selected neighbors
	public boolean    ft_clusterize_by_highest = true;    // Clusterize using disparity horizontal maximums for fronto planes and minimums - for horizontal. False - use histograms
	public boolean    ft_clusterize_by_highest = true;    // Clusterize using disparity horizontal maximums for fronto planes and minimums - for horizontal. False - use histograms
@@ -1468,6 +1477,13 @@ public class CLTParameters {
		properties.setProperty(prefix+"gr_fin_diff",                this.gr_fin_diff +"");
		properties.setProperty(prefix+"gr_fin_diff",                this.gr_fin_diff +"");
		properties.setProperty(prefix+"gr_unique_tol",              this.gr_unique_tol +"");
		properties.setProperty(prefix+"gr_unique_tol",              this.gr_unique_tol +"");
		properties.setProperty(prefix+"gr_unique_pretol",           this.gr_unique_pretol +"");
		properties.setProperty(prefix+"gr_unique_pretol",           this.gr_unique_pretol +"");
		properties.setProperty(prefix+"gr_max_clust_radius",        this.gr_max_clust_radius +"");
		properties.setProperty(prefix+"gr_num_refines",             this.gr_num_refines +"");
		properties.setProperty(prefix+"gr_exp_certain",             this.gr_exp_certain +"");
		properties.setProperty(prefix+"gr_reduce_sngl",             this.gr_reduce_sngl +"");
		properties.setProperty(prefix+"gr_reduce_multi",            this.gr_reduce_multi +"");
		properties.setProperty(prefix+"gr_all_last",                this.gr_all_last +"");
		properties.setProperty(prefix+"gr_nan_bg",                  this.gr_nan_bg +"");


		properties.setProperty(prefix+"ft_mod_strength",                    this.ft_mod_strength +"");
		properties.setProperty(prefix+"ft_mod_strength",                    this.ft_mod_strength +"");
		properties.setProperty(prefix+"ft_clusterize_by_highest",           this.ft_clusterize_by_highest +"");
		properties.setProperty(prefix+"ft_clusterize_by_highest",           this.ft_clusterize_by_highest +"");
@@ -2298,7 +2314,13 @@ public class CLTParameters {
		if (properties.getProperty(prefix+"gr_fin_diff")!=null)                   this.gr_fin_diff=Double.parseDouble(properties.getProperty(prefix+"gr_fin_diff"));
		if (properties.getProperty(prefix+"gr_fin_diff")!=null)                   this.gr_fin_diff=Double.parseDouble(properties.getProperty(prefix+"gr_fin_diff"));
		if (properties.getProperty(prefix+"gr_unique_tol")!=null)                 this.gr_unique_tol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_tol"));
		if (properties.getProperty(prefix+"gr_unique_tol")!=null)                 this.gr_unique_tol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_tol"));
		if (properties.getProperty(prefix+"gr_unique_pretol")!=null)              this.gr_unique_pretol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_pretol"));
		if (properties.getProperty(prefix+"gr_unique_pretol")!=null)              this.gr_unique_pretol=Double.parseDouble(properties.getProperty(prefix+"gr_unique_pretol"));

		if (properties.getProperty(prefix+"gr_max_clust_radius")!=null)           this.gr_max_clust_radius=Integer.parseInt(properties.getProperty(prefix+"gr_max_clust_radius"));
		if (properties.getProperty(prefix+"gr_num_refines")!=null)                this.gr_num_refines=Integer.parseInt(properties.getProperty(prefix+"gr_num_refines"));
		if (properties.getProperty(prefix+"gr_exp_certain")!=null)                this.gr_exp_certain=Boolean.parseBoolean(properties.getProperty(prefix+"gr_exp_certain"));
		if (properties.getProperty(prefix+"gr_reduce_sngl")!=null)                this.gr_reduce_sngl=Boolean.parseBoolean(properties.getProperty(prefix+"gr_reduce_sngl"));
		if (properties.getProperty(prefix+"gr_reduce_multi")!=null)               this.gr_reduce_multi=Boolean.parseBoolean(properties.getProperty(prefix+"gr_reduce_multi"));
		if (properties.getProperty(prefix+"gr_all_last")!=null)                   this.gr_all_last=Boolean.parseBoolean(properties.getProperty(prefix+"gr_all_last"));
		if (properties.getProperty(prefix+"gr_nan_bg")!=null)                     this.gr_nan_bg=Boolean.parseBoolean(properties.getProperty(prefix+"gr_nan_bg"));
		
		
		if (properties.getProperty(prefix+"ft_mod_strength")!=null)                    this.ft_mod_strength=Boolean.parseBoolean(properties.getProperty(prefix+"ft_mod_strength"));
		if (properties.getProperty(prefix+"ft_mod_strength")!=null)                    this.ft_mod_strength=Boolean.parseBoolean(properties.getProperty(prefix+"ft_mod_strength"));
		if (properties.getProperty(prefix+"ft_clusterize_by_highest")!=null)           this.ft_clusterize_by_highest=Boolean.parseBoolean(properties.getProperty(prefix+"ft_clusterize_by_highest"));
		if (properties.getProperty(prefix+"ft_clusterize_by_highest")!=null)           this.ft_clusterize_by_highest=Boolean.parseBoolean(properties.getProperty(prefix+"ft_clusterize_by_highest"));
@@ -2315,8 +2337,6 @@ public class CLTParameters {
		if (properties.getProperty(prefix+"ft_used_companions")!=null)                 this.ft_used_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_companions"));
		if (properties.getProperty(prefix+"ft_used_companions")!=null)                 this.ft_used_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_companions"));
		if (properties.getProperty(prefix+"ft_used_true_companions")!=null)            this.ft_used_true_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_true_companions"));
		if (properties.getProperty(prefix+"ft_used_true_companions")!=null)            this.ft_used_true_companions=Integer.parseInt(properties.getProperty(prefix+"ft_used_true_companions"));




		if (properties.getProperty(prefix+"plPreferDisparity")!=null)             this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
		if (properties.getProperty(prefix+"plPreferDisparity")!=null)             this.plPreferDisparity=Boolean.parseBoolean(properties.getProperty(prefix+"plPreferDisparity"));
		if (properties.getProperty(prefix+"plDispNorm")!=null)                    this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm"));
		if (properties.getProperty(prefix+"plDispNorm")!=null)                    this.plDispNorm=Double.parseDouble(properties.getProperty(prefix+"plDispNorm"));
		if (properties.getProperty(prefix+"plFrontoTol")!=null)                   this.plFrontoTol=Double.parseDouble(properties.getProperty(prefix+"plFrontoTol"));
		if (properties.getProperty(prefix+"plFrontoTol")!=null)                   this.plFrontoTol=Double.parseDouble(properties.getProperty(prefix+"plFrontoTol"));
@@ -3290,6 +3310,24 @@ public class CLTParameters {
		gd.addNumericField("Do not re-measure correlation if target disparity differs from some previous less",             this.gr_unique_tol,  6);
		gd.addNumericField("Do not re-measure correlation if target disparity differs from some previous less",             this.gr_unique_tol,  6);
		gd.addNumericField("Larger tolerance for expanding (not refining)",                                                 this.gr_unique_pretol,  6);
		gd.addNumericField("Larger tolerance for expanding (not refining)",                                                 this.gr_unique_pretol,  6);
		
		
		gd.addMessage     ("--- Mukti-tile DSI expansion ---");
		gd.addNumericField("Maximal cluster radius",                                                                        this.gr_max_clust_radius,  0,6,"",
				"2 - 3x3, 3 - 5x5, 4 - 7x7 tiles");
		gd.addNumericField("Number of refines for each cluster radius",                                                    this.gr_num_refines,  0,6,"",
				"Each tile will be processed until change fallls below gr_unique_tol ('Do not re-measure...' above), buit hard-limited by this value");
		gd.addCheckbox    ("Expand DSI over weak tiles",                                                                    this.gr_exp_certain,
				"Has problems (produces dips), disable");
		gd.addCheckbox    ("Reduce number of pairs when refining single-tile DSI",                                          this.gr_reduce_sngl,
				"Currently to 40 pairs: neigbors, squares, diameters");
		gd.addCheckbox    ("Reduce number of pairs when refining single-tile DSI",                                          this.gr_reduce_multi,
				"Currently to 40 pairs: neigbors, squares, diameters");
		gd.addCheckbox    ("Restore to all configured pairs for the last refine cycles",                                    this.gr_all_last,
				"Use configured (ImageDtt tab) pairs for the last refine cycles (both single and multi-tile");
		gd.addCheckbox    ("Undefine disparity for the background tiles",                                                   this.gr_nan_bg,
				"Set DSI disparity to NaN  for the BG tiles");

		
		
		gd.addTab         ("Alt CLusterize", "Alternative initial tiles clusterization");
		gd.addTab         ("Alt CLusterize", "Alternative initial tiles clusterization");


		gd.addCheckbox    ("Modify cluster strengths",                                                                      this.ft_mod_strength,
		gd.addCheckbox    ("Modify cluster strengths",                                                                      this.ft_mod_strength,
@@ -4170,6 +4208,13 @@ public class CLTParameters {
		this.gr_fin_diff=           gd.getNextNumber();
		this.gr_fin_diff=           gd.getNextNumber();
		this.gr_unique_tol=         gd.getNextNumber();
		this.gr_unique_tol=         gd.getNextNumber();
		this.gr_unique_pretol=      gd.getNextNumber();
		this.gr_unique_pretol=      gd.getNextNumber();
		this.gr_max_clust_radius= (int) gd.getNextNumber();
		this.gr_num_refines=      (int) gd.getNextNumber();
		this.gr_exp_certain=            gd.getNextBoolean();
		this.gr_reduce_sngl=            gd.getNextBoolean();
		this.gr_reduce_multi=           gd.getNextBoolean();
		this.gr_all_last=               gd.getNextBoolean();
		this.gr_nan_bg=                 gd.getNextBoolean();


		this.ft_mod_strength=               gd.getNextBoolean();
		this.ft_mod_strength=               gd.getNextBoolean();
		this.ft_clusterize_by_highest=      gd.getNextBoolean();
		this.ft_clusterize_by_highest=      gd.getNextBoolean();
+1 −1
Original line number Original line Diff line number Diff line
@@ -1019,7 +1019,7 @@ public class EyesisCorrectionParameters {
    		gd.addCheckbox    ("Include/genarate separate aux camera DSI data in the combo DSI",     this.clt_batch_dsi_aux,
    		gd.addCheckbox    ("Include/genarate separate aux camera DSI data in the combo DSI",     this.clt_batch_dsi_aux,
    				"8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+
    				"8-rig: DSI for the AUX camera is offset (by the rig baseline) from the main and rig DSI. Aux DSI requires extra processing time."+
    		" EO+LWIR - generate a separate GT+AUX file");
    		" EO+LWIR - generate a separate GT+AUX file");
    		gd.addCheckbox    ("Additional steps to calculate Auf DSI (more than for LY adjustment)",   this.clt_batch_dsi_aux_full,
    		gd.addCheckbox    ("Additional steps to calculate Aux DSI (more than for LY adjustment)",   this.clt_batch_dsi_aux_full,
    				"(Not yet tested)");
    				"(Not yet tested)");
    		
    		
    		
    		
+4 −2
Original line number Original line Diff line number Diff line
@@ -2468,7 +2468,7 @@ public class ImageDtt extends ImageDttCPU {
							}
							}
							nTile = tileY * tilesX + tileX;
							nTile = tileY * tilesX + tileX;
							if (tp_tasks[iTile].getTask() == 0) continue; // nothing to do for this tile
							if (tp_tasks[iTile].getTask() == 0) continue; // nothing to do for this tile
							boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > -6);
							boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > 0);
							if (debugTile0) {
							if (debugTile0) {
								System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY+", iTile="+iTile+", nTile="+nTile);
								System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY+", iTile="+iTile+", nTile="+nTile);
							}
							}
@@ -2517,7 +2517,9 @@ public class ImageDtt extends ImageDttCPU {
													corrs[npair] , //double [] corr_tile,
													corrs[npair] , //double [] corr_tile,
													npair);        // int       num_pair)
													npair);        // int       num_pair)
											if (pair_width < 0.1) {
											if (pair_width < 0.1) {
												if (globalDebugLevel > 0) {
													System.out.println("pair_width["+npair+"]="+pair_width);
													System.out.println("pair_width["+npair+"]="+pair_width);
												}
											} else {
											} else {
												weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
												weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
											}
											}
+8 −6
Original line number Original line Diff line number Diff line
@@ -15970,7 +15970,7 @@ public class ImageDttCPU {
								}
								}
							}
							}
						}
						}
						boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > -6);
						boolean debugTile0 =(tileX == debug_tileX) && (tileY == debug_tileY) && (globalDebugLevel > 0);
						if (debugTile0) {
						if (debugTile0) {
							System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY);
							System.out.println("clt_process_tl_correlations(): tileX="+tileX+", tileY="+tileY);
						}
						}
@@ -16027,7 +16027,9 @@ public class ImageDttCPU {
												corrs[npair] , //double [] corr_tile,
												corrs[npair] , //double [] corr_tile,
									    		npair);        // int       num_pair)
									    		npair);        // int       num_pair)
										if (pair_width < 0.1) {
										if (pair_width < 0.1) {
											if (globalDebugLevel > 0) {
												System.out.println("pair_width["+npair+"]="+pair_width);
												System.out.println("pair_width["+npair+"]="+pair_width);
											}
										} else {
										} else {
										weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
										weights[npair] /= Math.pow(pair_width, imgdtt_params.mcorr_weights_power);
										}
										}
@@ -16884,7 +16886,7 @@ public class ImageDttCPU {
						tileYC = tp_tasks[iTileC].getTileY(); //  /tilesX;
						tileYC = tp_tasks[iTileC].getTileY(); //  /tilesX;
						tileXC = tp_tasks[iTileC].getTileX(); //nTile % tilesX;
						tileXC = tp_tasks[iTileC].getTileX(); //nTile % tilesX;
						nTileC = tileYC * tilesX + tileXC;
						nTileC = tileYC * tilesX + tileXC;
						if ((tileXC == debug_tileX) && (tileYC == debug_tileY)) {
						if ((globalDebugLevel > -2) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
							System.out.println("quadCorrTD_tilted(): tileXC="+tileXC+", tileYC="+tileYC+", iTileC="+iTileC);
							System.out.println("quadCorrTD_tilted(): tileXC="+tileXC+", tileYC="+tileYC+", iTileC="+iTileC);
						}
						}
						//quadCorrTD_tilted
						//quadCorrTD_tilted
@@ -16963,7 +16965,7 @@ public class ImageDttCPU {
							} else {
							} else {
								tp_index_multi[offset_index][cindex]  =  iTileC;
								tp_index_multi[offset_index][cindex]  =  iTileC;
							}
							}
							if ((globalDebugLevel > 0) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
							if ((globalDebugLevel > -2) && (tileXC == debug_tileX) && (tileYC == debug_tileY)) {
								System.out.println("mindx="+mindx+", cindex="+cindex+", disparity_target="+disparity_target+
								System.out.println("mindx="+mindx+", cindex="+cindex+", disparity_target="+disparity_target+
										", offset_index="+offset_index+", cindex="+cindex+", tileX="+tileX+", tileY="+tileY );
										", offset_index="+offset_index+", cindex="+cindex+", tileX="+tileX+", tileY="+tileY );
							}
							}
@@ -17037,7 +17039,7 @@ public class ImageDttCPU {
							globalDebugLevel);
							globalDebugLevel);
					if (globalDebugLevel > 0) {
					if (globalDebugLevel > 0) {
						for (TpTask tt: tp_tasks_pass) {
						for (TpTask tt: tp_tasks_pass) {
							if ((globalDebugLevel > 0) && ((tt.getTileY() - idy) == debug_tileY) && ((tt.getTileX()-idx) == debug_tileX)) {
							if ((globalDebugLevel > -2) && ((tt.getTileY() - idy) == debug_tileY) && ((tt.getTileX()-idx) == debug_tileX)) {
								System.out.println(" +++ neib_index="+neib_index+" tX="+tt.getTileX()+" tY="+tt.getTileY()
								System.out.println(" +++ neib_index="+neib_index+" tX="+tt.getTileX()+" tY="+tt.getTileY()
										+ " target_disparity="+tt.getTargetDisparity()+" idx="+idx+" idy="+idy);
										+ " target_disparity="+tt.getTargetDisparity()+" idx="+idx+" idy="+idy);
							}
							}
@@ -17064,7 +17066,7 @@ public class ImageDttCPU {
									float [][] src_corrs = fcorr_td_part[tY_src][tX_src];
									float [][] src_corrs = fcorr_td_part[tY_src][tX_src];
									if (src_corrs != null) {
									if (src_corrs != null) {
										// TODO: finish checking correct fcorr_td_part
										// TODO: finish checking correct fcorr_td_part
										if ((globalDebugLevel > 0) && (tX_dst == debug_tileX) && (tY_dst == debug_tileY)) {
										if ((globalDebugLevel > -2) && (tX_dst == debug_tileX) && (tY_dst == debug_tileY)) {
											System.out.println("*** quadCorrTD_tilted_sum(): neib_index="+fneib_index+", tX_dst="+tX_dst+", tY_dst="+tY_dst+
											System.out.println("*** quadCorrTD_tilted_sum(): neib_index="+fneib_index+", tX_dst="+tX_dst+", tY_dst="+tY_dst+
													", iTileC="+iTileC+", tX_src="+tX_src+", tY_src="+tY_src+", w="+w);
													", iTileC="+iTileC+", tX_src="+tX_src+", tY_src="+tY_src+", w="+w);
										}
										}
+82 −49
Original line number Original line Diff line number Diff line
@@ -8243,7 +8243,7 @@ public class QuadCLTCPU {
		  tp.clt_3d_passes.add(bgnd_data);
		  tp.clt_3d_passes.add(bgnd_data);
		  //    	  if (show_init_refine)
		  //    	  if (show_init_refine)
//		  if ((debugLevel > -2) && clt_parameters.show_first_bg) {
//		  if ((debugLevel > -2) && clt_parameters.show_first_bg) {
		  if ((debugLevel > -3) && clt_parameters.show_first_bg) {
		  if ((debugLevel > -2) && clt_parameters.show_first_bg) {
			  tp.showScan(
			  tp.showScan(
					  tp.clt_3d_passes.get(0), // CLTPass3d   scan,
					  tp.clt_3d_passes.get(0), // CLTPass3d   scan,
					  "bgnd_data-"+tp.clt_3d_passes.size());
					  "bgnd_data-"+tp.clt_3d_passes.size());
@@ -8269,7 +8269,7 @@ public class QuadCLTCPU {
    			  updateStatus,
    			  updateStatus,
    			  debugLevel);
    			  debugLevel);
		  
		  
    	  if (debugLevel > -3) {
    	  if (debugLevel > -2) {
    		  imp_bgnd_int.show(); /// OK 
    		  imp_bgnd_int.show(); /// OK 
    	  }
    	  }
		  
		  
@@ -8448,8 +8448,9 @@ public class QuadCLTCPU {
    		  }
    		  }
    	  }
    	  }
    	  
//		  boolean reduce_pairs_multi = true;
    	  // Save pair selection and minimaize them for scanning, then restore;
//		  boolean last_iter_all = true;
    	  // Save pair selection and minimize them for scanning, then restore;
    	  int save_pairs_selection = clt_parameters.img_dtt.getMcorr(getNumSensors());
    	  int save_pairs_selection = clt_parameters.img_dtt.getMcorr(getNumSensors());
    	  clt_parameters.img_dtt.setMcorr(getNumSensors(), 0 ); // remove all
    	  clt_parameters.img_dtt.setMcorr(getNumSensors(), 0 ); // remove all
    	  clt_parameters.img_dtt.setMcorrNeib(getNumSensors(),true);
    	  clt_parameters.img_dtt.setMcorrNeib(getNumSensors(),true);
@@ -8458,14 +8459,14 @@ public class QuadCLTCPU {
    	  boolean save_run_lma = clt_parameters.correlate_lma;
    	  boolean save_run_lma = clt_parameters.correlate_lma;
    	  clt_parameters.correlate_lma = false;
    	  clt_parameters.correlate_lma = false;
    	  
    	  
    	  int num_macro_refine = 3;
//    	  int num_macro_refine = 3;
    	  int dbg_num_new = 0;
    	  int dbg_num_new = 0;
    	  for (CLTPass3d from_macro_pass: new_meas) {
    	  for (CLTPass3d from_macro_pass: new_meas) {
    		  if (debugLevel > -2) {
    		  if (debugLevel > -2) {
    			  System.out.println("Next from new_meas: "+dbg_num_new);
    			  System.out.println("Next from new_meas: "+dbg_num_new);
    		  }
    		  }
    		  dbg_num_new++;
    		  dbg_num_new++;
    		  for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
    		  for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
    			  refine_pass = tp.clt_3d_passes.size(); // 1
    			  refine_pass = tp.clt_3d_passes.size(); // 1
    			  CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
    			  CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
    					  //				  final double [][][]       image_data, // first index - number of image in a quad
    					  //				  final double [][][]       image_data, // first index - number of image in a quad
@@ -8516,6 +8517,7 @@ public class QuadCLTCPU {
    					  "after_refinePassSetup-"+tp.clt_3d_passes.size());
    					  "after_refinePassSetup-"+tp.clt_3d_passes.size());
    			  // Just debugging
    			  // Just debugging
    			  /*
    			  if (clt_parameters.gpu_debug_accum) { // 
    			  if (clt_parameters.gpu_debug_accum) { // 
    				  CLTMeasureCorrTesting( // perform single pass according to prepared tiles operations and disparity
    				  CLTMeasureCorrTesting( // perform single pass according to prepared tiles operations and disparity
    						  clt_parameters,
    						  clt_parameters,
@@ -8533,9 +8535,11 @@ public class QuadCLTCPU {
    						  updateStatus,
    						  updateStatus,
    						  debugLevel);
    						  debugLevel);
    			  }
    			  }
    			  */
      			  // End of just debugging
      			  // End of just debugging
    			  // will split old/new	  
    			  // will split old/new	  
    			  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
//    			  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
     			  CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
    					  //    			  CLTMeasCorr(
    					  //    			  CLTMeasCorr(
    					  clt_parameters,
    					  clt_parameters,
    					  refine_pass,
    					  refine_pass,
@@ -8551,7 +8555,7 @@ public class QuadCLTCPU {
    			  if (show_init_refine) tp.showScan(
    			  if (show_init_refine) tp.showScan(
    					  tp.clt_3d_passes.get(refine_pass), // CLTPass3d   scan,
    					  tp.clt_3d_passes.get(refine_pass), // CLTPass3d   scan,
    					  "after_measure-"+tp.clt_3d_passes.size());
    					  "after_measure-"+tp.clt_3d_passes.size());
    			  if (nnn < (num_macro_refine-1)) { // all but last
    			  if (nnn < (clt_parameters.gr_num_refines-1)) { // all but last
    				  //        	  if (clt_parameters.combine_refine){
    				  //        	  if (clt_parameters.combine_refine){
    				  CLTPass3d combo_pass = tp.compositeScan(
    				  CLTPass3d combo_pass = tp.compositeScan(
    						  tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
    						  tp.clt_3d_passes, // final ArrayList <CLTPass3d> passes,
@@ -8583,7 +8587,8 @@ public class QuadCLTCPU {
    		  }
    		  }
    		  // add new scan from macro
    		  // add new scan from macro
    		  tp.clt_3d_passes.add(from_macro_pass);
    		  tp.clt_3d_passes.add(from_macro_pass);
    		  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
//    		  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
      		  CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
//					  image_data, // first index - number of image in a quad
//					  image_data, // first index - number of image in a quad
//					  saturation_imp, //final boolean [][]  saturation_imp, // (near) saturated pixels or null
//					  saturation_imp, //final boolean [][]  saturation_imp, // (near) saturated pixels or null
					  clt_parameters,
					  clt_parameters,
@@ -8602,17 +8607,22 @@ public class QuadCLTCPU {
    	  }
    	  }
    	  // Restore pair selection and minimize them for scanning, then restore;
    	  // Restore pair selection and minimize them for scanning, then restore;
    	  if (!clt_parameters.gr_reduce_sngl) {
    		  clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
    		  clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
    	  }
    	  clt_parameters.correlate_lma = save_run_lma; // restore
    	  clt_parameters.correlate_lma = save_run_lma; // restore
    	  
    	  
    	  
    	  
/// Refining after all added
/// Refining after all added
		  if (debugLevel > -1){
		  if (debugLevel > -3){
			  System.out.println("---- Refining after all added ----");
			  System.out.println("---- Refining after all added ----");
		  }
		  }
		  // find out - why first pass corresponds to last scan step?
		  // find out - why first pass corresponds to last scan step?
    	  // first ("before_makeUnique-41-" was empty)
    	  // first ("before_makeUnique-41-" was empty)
		  for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
		  for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
	    	  if ((nnn == (clt_parameters.gr_num_refines - 1)) && clt_parameters.gr_all_last) {
	    		  clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
	    	  }
			  refine_pass = tp.clt_3d_passes.size(); // 1
			  refine_pass = tp.clt_3d_passes.size(); // 1
			  CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
			  CLTPass3d refined = tp.refinePassSetup( // prepare tile tasks for the refine pass (re-measure disparities)
					  //				  final double [][][]       image_data, // first index - number of image in a quad
					  //				  final double [][][]       image_data, // first index - number of image in a quad
@@ -8666,7 +8676,8 @@ public class QuadCLTCPU {
			  
			  
			  
			  
// first time - last scan step????
// first time - last scan step????
			  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
//			  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
			  CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
//					  image_data, // first index - number of image in a quad
//					  image_data, // first index - number of image in a quad
//					  saturation_imp, //final boolean [][]  saturation_imp, // (near) saturated pixels or null
//					  saturation_imp, //final boolean [][]  saturation_imp, // (near) saturated pixels or null
					  clt_parameters,
					  clt_parameters,
@@ -8704,16 +8715,23 @@ public class QuadCLTCPU {
			  tp.clt_3d_passes.add(combo_pass);
			  tp.clt_3d_passes.add(combo_pass);
		  }
		  }
		  
		  
		  
		  
		  // create and measure several variable-cluster scans from the same single-tile combo_pass
		  // create and measure several variable-cluster scans from the same single-tile combo_pass
		  CLTPass3d combo_pass = tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1); // last pass created by tp.compositeScan
		  CLTPass3d combo_pass = tp.clt_3d_passes.get(tp.clt_3d_passes.size() - 1); // last pass created by tp.compositeScan
		  int max_clust_radius =  4; // 7x7
//		  int max_clust_radius =  4; // 7x7
		  CLTPass3d [] combo_multi = new CLTPass3d[max_clust_radius+1];
		  CLTPass3d [] combo_multi = new CLTPass3d[clt_parameters.gr_max_clust_radius+1];
		  combo_multi[0] = combo_pass;
		  combo_multi[0] = combo_pass;
		  int max_expand_radius = 0; // max_clust_radius;
		  int max_expand_radius = 0; // max_clust_radius;
		  for (int clust_radius = 2; clust_radius <= max_clust_radius; clust_radius++) {
		  for (int clust_radius = 2; clust_radius <= clt_parameters.gr_max_clust_radius; clust_radius++) {
//		  for (int clust_radius = 4; clust_radius <= max_clust_radius; clust_radius++) { // just for faster testing
//		  for (int clust_radius = 4; clust_radius <= max_clust_radius; clust_radius++) { // just for faster testing
	    	  if (clt_parameters.gr_reduce_multi) {
		    	  clt_parameters.img_dtt.setMcorr(getNumSensors(), 0 ); // remove all
		    	  clt_parameters.img_dtt.setMcorrNeib(getNumSensors(),true);
		    	  clt_parameters.img_dtt.setMcorrSq  (getNumSensors(),true); // remove even more?
		    	  clt_parameters.img_dtt.setMcorrDia (getNumSensors(),true); // remove even more?
	    	  }
			  
			  
			  // using combo_pass (latest)
			  // using combo_pass (latest)
			  int num_added = 0;
			  int num_added = 0;
			  if (clust_radius < max_expand_radius) {
			  if (clust_radius < max_expand_radius) {
@@ -8734,8 +8752,10 @@ public class QuadCLTCPU {
			  System.out.println("Added "+num_added+" tiles before cluster radius "+clust_radius);
			  System.out.println("Added "+num_added+" tiles before cluster radius "+clust_radius);
			  boolean [] has_lma = combo_pass.getLMA();
			  boolean [] has_lma = combo_pass.getLMA();
			  double [] disparity = combo_pass.getDisparity(1); // calc_disparity (skip NaN!)
			  double [] disparity = combo_pass.getDisparity(1); // calc_disparity (skip NaN!)
			  for (int nnn = 0; nnn < num_macro_refine; nnn ++){ //
			  for (int nnn = 0; nnn < clt_parameters.gr_num_refines; nnn ++){ //
		    	  if ((nnn == (clt_parameters.gr_num_refines - 1)) && clt_parameters.gr_all_last) {
		    		  clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
		    	  }
				  refine_pass = tp.clt_3d_passes.size();
				  refine_pass = tp.clt_3d_passes.size();
				  CLTPass3d refined_multi = tp.refinePassSetupMulti( // prepare tile tasks for the second pass based on the previous one(s)
				  CLTPass3d refined_multi = tp.refinePassSetupMulti( // prepare tile tasks for the second pass based on the previous one(s)
						  combo_pass, // CLTPass3d         combo_pass,
						  combo_pass, // CLTPass3d         combo_pass,
@@ -8776,8 +8796,8 @@ public class QuadCLTCPU {
//				  double [] saved_target_disparity = tp.clt_3d_passes.get(refine_pass).getDA(); // TODO: remove when done 
//				  double [] saved_target_disparity = tp.clt_3d_passes.get(refine_pass).getDA(); // TODO: remove when done 
//				  for (int ii = 0; ii < rpt; ii++) {                                            // TODO: remove when done
//				  for (int ii = 0; ii < rpt; ii++) {                                            // TODO: remove when done
//					  tp.clt_3d_passes.get(refine_pass).setDA(saved_target_disparity);          // TODO: remove when done
//					  tp.clt_3d_passes.get(refine_pass).setDA(saved_target_disparity);          // TODO: remove when done
				  boolean alt_clt = true;
///				  boolean alt_clt = true;
				  if (alt_clt) {
///				  if (alt_clt) {
					  CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
					  CLTMeasCorr( // perform single pass according to prepared tiles operations and disparity
							  clt_parameters,
							  clt_parameters,
							  refine_pass,
							  refine_pass,
@@ -8786,16 +8806,16 @@ public class QuadCLTCPU {
							  threadsMax,
							  threadsMax,
							  updateStatus,
							  updateStatus,
							  debugLevel);
							  debugLevel);
				  } else {
///				  } else {
					  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
///					  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity
							  clt_parameters,
///							  clt_parameters,
							  refine_pass,
///							  refine_pass,
							  false,          // true,           // final boolean     save_textures,
///							  false,          // true,           // final boolean     save_textures,
							  clust_radius,   // final int         clust_radius,
///							  clust_radius,   // final int         clust_radius,
							  threadsMax,
///							  threadsMax,
							  updateStatus,
///							  updateStatus,
							  debugLevel);
///							  debugLevel);
				  }
///				  }
				  if (show_init_refine) tp.showScan(
				  if (show_init_refine) tp.showScan(
@@ -8839,6 +8859,18 @@ public class QuadCLTCPU {
			  }
			  }
		  }
		  }
			  // Restore pairs selection
		  clt_parameters.img_dtt.setMcorr(getNumSensors(), save_pairs_selection); // restore
		  if (clt_parameters.gr_nan_bg) {
			  if (debugLevel > -3) {
				  tp.showScan(
						  tp.clt_3d_passes.get(bg_pass), // CLTPass3d   scan,
						  "bg_passs-"+tp.clt_3d_passes.size());
			  }
		  }
		  
		  
		  if (clt_parameters.gr_exp_certain) {
			  int num_added = tp.expandCertainMulti ( 
			  int num_added = tp.expandCertainMulti ( 
					  combo_pass, // CLTPass3d             combo_pass, // modify
					  combo_pass, // CLTPass3d             combo_pass, // modify
					  tp.clt_3d_passes, //ArrayList <CLTPass3d> passes,
					  tp.clt_3d_passes, //ArrayList <CLTPass3d> passes,
@@ -8856,7 +8888,7 @@ public class QuadCLTCPU {
			  if (debugLevel > -2) tp.showScan(
			  if (debugLevel > -2) tp.showScan(
					  combo_pass, // CLTPass3d   scan,
					  combo_pass, // CLTPass3d   scan,
					  "after_multi-tile_disparity_extension");
					  "after_multi-tile_disparity_extension");
		  
		  }
 ///// Refining after all added   - end
 ///// Refining after all added   - end
		  Runtime.getRuntime().gc();
		  Runtime.getRuntime().gc();
@@ -12175,6 +12207,7 @@ public class QuadCLTCPU {
		  }
		  }
		  
		  
	  }
	  }
	  @Deprecated
	  public CLTPass3d  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
	  public CLTPass3d  CLTMeasureCorr( // perform single pass according to prepared tiles operations and disparity // not used in lwir
			  CLTParameters    clt_parameters,
			  CLTParameters    clt_parameters,
			  final int         scanIndex,
			  final int         scanIndex,