Commit 270fcbc6 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Before adding BLUE_SKY to DSI_MAIN

parent 8ee61ae6
Loading
Loading
Loading
Loading
+290 −218
Original line number Original line Diff line number Diff line
@@ -3775,24 +3775,22 @@ public class OpticalFlow {
		quadCLTs[ref_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
		quadCLTs[ref_index].saveQuadClt(); // to re-load new set of Bayer images to the GPU (do nothing for CPU) and Geometry
	 */
	 */
//	public static QuadCLT buildRefDSI(
//	public static QuadCLT buildRefDSI(
	public static void buildRefDSI(
	public static void photoEach(
			CLTParameters                                 clt_parameters,
			CLTParameters                                 clt_parameters,
			EyesisCorrectionParameters.DebayerParameters  debayerParameters,
			ColorProcParameters                           colorProcParameters,
			ColorProcParameters                           colorProcParameters,
			EyesisCorrectionParameters.RGBParameters      rgbParameters,
    		boolean                                       batch_mode,
    		String                                        set_name,
			QuadCLT                                       quadCLT_main, // tiles should be set
			QuadCLT                                       quadCLT_main, // tiles should be set
			QuadCLT                                       quadCLT_ref, // tiles should be set
			QuadCLT                                       quadCLT_ref, // tiles should be set
			final int                                     threadsMax,  // maximal number of threads to launch
			final double [][]                             dsi,
			final int                                     photo_num_full, // 
			final boolean                                 batch_mode,
			final int                                     threadsMax,  // int               threadsMax,
			final boolean                                 updateStatus,
			final boolean                                 updateStatus,
			final int                                     debugLevel) {
			final int                                     debugLevel) {
		final int        debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ
		boolean [] blue_sky = quadCLT_ref.getBlueSky();
//    	boolean  photo_en =                  clt_parameters.photo_en; //          false; // perform photogrammetric calibration to equalize pixel values
		if (debugLevel > -3) {
    	boolean  photo_each =                clt_parameters.photo_each; //        true;  // perform photogrammetric calibration to equalize pixel values
			System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
//		boolean  photo_to_main=              clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence
					", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
		}
    	int      photo_num_full =            clt_parameters.photo_num_full; //     1;    // Number of full recalibrations with re-processing of the images  
    	int      photo_num_refines =         clt_parameters.photo_num_refines; //  3;    // Calibrate, remove outliers, recalibrate, ... 
    	int      photo_num_refines =         clt_parameters.photo_num_refines; //  3;    // Calibrate, remove outliers, recalibrate, ... 
    	int      photo_min_good =            clt_parameters.photo_min_good;    //  1000;    // Minimal number of good pixels for photometric calibration 
    	int      photo_min_good =            clt_parameters.photo_min_good;    //  1000;    // Minimal number of good pixels for photometric calibration 
    	double   photo_min_strength =        clt_parameters.photo_min_strength; // 0.0;  // maybe add to filter out weak tiles
    	double   photo_min_strength =        clt_parameters.photo_min_strength; // 0.0;  // maybe add to filter out weak tiles
@@ -3802,77 +3800,6 @@ public class OpticalFlow {
    	double   photo_std_2 =               clt_parameters.photo_std_2; // 200.0;   // Minimal standard deviation of the filtered values for poly order 2
    	double   photo_std_2 =               clt_parameters.photo_std_2; // 200.0;   // Minimal standard deviation of the filtered values for poly order 2
    	int      photo_offs_set =            clt_parameters.photo_offs_set; //  0;    // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
    	int      photo_offs_set =            clt_parameters.photo_offs_set; //  0;    // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
    	double   photo_offs =                clt_parameters.photo_offs;     // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
    	double   photo_offs =                clt_parameters.photo_offs;     // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
//    	boolean  photo_debug =               clt_parameters.photo_debug; //       false; // Generate images and text
 		double sky_highest_min =     clt_parameters.imp.sky_highest_min;
 		double cold_frac =           clt_parameters.imp.cold_frac;
 		double hot_frac =            clt_parameters.imp.hot_frac;
 		double cold_scale =          clt_parameters.imp.cold_scale;
 		double sky_seed =            clt_parameters.imp.sky_seed;
 		double lma_seed =            clt_parameters.imp.lma_seed;
 		int    sky_shrink =          clt_parameters.imp.sky_shrink;
 		int    sky_bottleneck =      clt_parameters.imp.sky_bottleneck;
 		int    seed_rows =           clt_parameters.imp.seed_rows;
 		double sky_lim =             clt_parameters.imp.sky_lim;
 		int    sky_expand_extra =    clt_parameters.imp.sky_expand_extra;
 		double min_strength =        clt_parameters.imp.min_strength;
 		int    lowest_sky_row =      clt_parameters.imp.lowest_sky_row;
 		double sky_bottom_override = clt_parameters.imp.sky_bottom_override;
 		int    sky_override_shrink = clt_parameters.imp.sky_override_shrink;
		double disp_boost_min =      clt_parameters.imp.disp_boost_min; //  0.5;
		double disp_boost_diff  =    clt_parameters.imp.disp_boost_diff; // 0.35;
		int    disp_boost_neibs  =   clt_parameters.imp.disp_boost_neibs; // 2;
		double disp_boost_amount  =  clt_parameters.imp.disp_boost_amount; // 2.0;
		boolean [] ref_blue_sky = null; // turn off "lma" in the ML output  
		quadCLT_ref.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
				clt_parameters,
				debayerParameters,
				colorProcParameters,
				rgbParameters,
				threadsMax,  // maximal number of threads to launch
				updateStatus,
				debugLevelInner);
		double [][] aux_last_scan = TileProcessor.getDSLMA(
				quadCLT_ref.tp.clt_3d_passes.get( quadCLT_ref.tp.clt_3d_passes.size() -1),
				false); // boolean force_final);
		double [][] dsi = new double [TwoQuadCLT.DSI_SLICES.length][];
		dsi[TwoQuadCLT.DSI_DISPARITY_AUX] =     aux_last_scan[0];
		dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      aux_last_scan[1];
		dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA] = aux_last_scan[2];
		dsi[TwoQuadCLT.DSI_SPREAD_AUX] =        aux_last_scan[3];
		dsi[TwoQuadCLT.DSI_AVGVAL_AUX] =        aux_last_scan[4];
		if (quadCLT_main.correctionsParameters.clt_batch_dsi_cm_strength) {
			CLTPass3d scan = new CLTPass3d(quadCLT_ref.tp);
			scan.setTileOpDisparity(aux_last_scan[0]); // measure w/o LMA, use just strength
			quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
					clt_parameters, // EyesisCorrectionParameters.CLTParameters           clt_parameters,
					scan,           // final CLTPass3d   scan,
					false,          // final boolean     save_textures,
					false,          // final boolean       need_diffs,     // calculate diffs even if textures are not needed 
					0,              // final int         clust_radius,
					true,           // final boolean     save_corr,
					false,          // final boolean     run_lma, // =    true;
					0.0,            // final double        max_chn_diff, // filter correlation results by maximum difference between channels
					-1.0,           // final double        mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
					threadsMax,     // final int         threadsMax,  // maximal number of threads to launch
					updateStatus,   // final boolean     updateStatus,
					debugLevel-2);  // final int         debugLevel);
			dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      scan.getStrength();
			if (debugLevel > 1) {
				quadCLT_ref.tp.showScan(
						scan, // CLTPass3d   scan,
						"test-strength");
			}
		} else {
			dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      aux_last_scan[1];
		}
		// perform photometric here, after first DSI
		if (photo_each && (!quadCLT_ref.isPhotometricThis() || !batch_mode)) {
			if (debugLevel > -3) {
				System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
						", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
			}
	
	
		// preparing same format as after combo, filling in only needed data
		// preparing same format as after combo, filling in only needed data
		double [][] ds_photo = new double[TwoQuadCLT.DSI_LENGTH][];
		double [][] ds_photo = new double[TwoQuadCLT.DSI_LENGTH][];
@@ -3901,6 +3828,7 @@ public class OpticalFlow {
					photo_num_refines,        // final int         num_refines, // 2
					photo_num_refines,        // final int         num_refines, // 2
				    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
				    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
					ds_photo,       // combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
					ds_photo,       // combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
					blue_sky,       // final boolean[]   blue_sky,					
					threadsMax,               // int               threadsMax,
					threadsMax,               // int               threadsMax,
					photo_each_debug);        //final boolean     debug)
					photo_each_debug);        //final boolean     debug)
			if (!ok) {
			if (!ok) {
@@ -3923,6 +3851,7 @@ public class OpticalFlow {
						photo_num_refines,        // final int         num_refines, // 2
						photo_num_refines,        // final int         num_refines, // 2
					    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
					    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
						ds_photo,                 // combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,			
						ds_photo,                 // combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,			
						blue_sky,       // final boolean[]   blue_sky,					
						threadsMax,               // int               threadsMax,
						threadsMax,               // int               threadsMax,
						photo_each_debug);        //final boolean     debug)
						photo_each_debug);        //final boolean     debug)
				if (!ok) {
				if (!ok) {
@@ -3939,14 +3868,6 @@ public class OpticalFlow {
			// Re-read reference and other scenes using new offsets	
			// Re-read reference and other scenes using new offsets	
			quadCLT_ref.setQuadClt(); // should work even when the data is new for the same scene
			quadCLT_ref.setQuadClt(); // should work even when the data is new for the same scene
				/*
				quadCLT_ref = (QuadCLT) quadCLT_main.spawnQuadCLT( // restores dsi from "DSI-MAIN"
						set_name,
						clt_parameters,
						colorProcParameters, //
						threadsMax,
						debugLevel);
				*/
			quadCLT_ref.restoreFromModel(
			quadCLT_ref.restoreFromModel(
					clt_parameters,
					clt_parameters,
					colorProcParameters,
					colorProcParameters,
@@ -4005,23 +3926,118 @@ public class OpticalFlow {
			dsi[TwoQuadCLT.DSI_AVGVAL_AUX] = bgscan.getAvgVal(); //aux_bg_scan[4];
			dsi[TwoQuadCLT.DSI_AVGVAL_AUX] = bgscan.getAvgVal(); //aux_bg_scan[4];
			
			
			quadCLT_ref.setDSI(dsi); // Restore known dsi
			quadCLT_ref.setDSI(dsi); // Restore known dsi
				quadCLT_ref.setBlueSky(ref_blue_sky);
//			quadCLT_ref.setBlueSky(null); //ref_blue_sky); it is null here
			quadCLT_ref.setDSRBG(
			quadCLT_ref.setDSRBG(
					clt_parameters, // CLTParameters  clt_parameters,
					clt_parameters, // CLTParameters  clt_parameters,
					threadsMax,     // int            threadsMax,  // maximal number of threads to launch
					threadsMax,     // int            threadsMax,  // maximal number of threads to launch
					updateStatus,   // boolean        updateStatus,
					updateStatus,   // boolean        updateStatus,
					debugLevel);    // int            debugLevel)
					debugLevel);    // int            debugLevel)
		}
		}
	}
	
	
	public static void buildRefDSI(
			CLTParameters                                 clt_parameters,
			EyesisCorrectionParameters.DebayerParameters  debayerParameters,
			ColorProcParameters                           colorProcParameters,
			EyesisCorrectionParameters.RGBParameters      rgbParameters,
    		boolean                                       batch_mode,
    		String                                        set_name,
			QuadCLT                                       quadCLT_main, // tiles should be set
			QuadCLT                                       quadCLT_ref, // tiles should be set
			final int                                     threadsMax,  // maximal number of threads to launch
			final boolean                                 updateStatus,
			final int                                     debugLevel) {
		final int        debugLevelInner=clt_parameters.batch_run? -2: debugLevel; // copied from TQ
    	boolean  photo_each =                clt_parameters.photo_each; //        true;  // perform photogrammetric calibration to equalize pixel values
 		double sky_highest_min =     clt_parameters.imp.sky_highest_min;
 		double cold_frac =           clt_parameters.imp.cold_frac;
 		double hot_frac =            clt_parameters.imp.hot_frac;
 		double cold_scale =          clt_parameters.imp.cold_scale;
 		double sky_seed =            clt_parameters.imp.sky_seed;
 		double lma_seed =            clt_parameters.imp.lma_seed;
 		int    sky_shrink =          clt_parameters.imp.sky_shrink;
 		int    sky_bottleneck =      clt_parameters.imp.sky_bottleneck;
 		int    seed_rows =           clt_parameters.imp.seed_rows;
 		double sky_lim =             clt_parameters.imp.sky_lim;
 		int    sky_expand_extra =    clt_parameters.imp.sky_expand_extra;
 		double min_strength =        clt_parameters.imp.min_strength;
 		int    lowest_sky_row =      clt_parameters.imp.lowest_sky_row;
 		double sky_bottom_override = clt_parameters.imp.sky_bottom_override;
 		int    sky_override_shrink = clt_parameters.imp.sky_override_shrink;
		double disp_boost_min =      clt_parameters.imp.disp_boost_min; //  0.5;
		double disp_boost_diff  =    clt_parameters.imp.disp_boost_diff; // 0.35;
		int    disp_boost_neibs  =   clt_parameters.imp.disp_boost_neibs; // 2;
		double disp_boost_amount  =  clt_parameters.imp.disp_boost_amount; // 2.0;
		boolean [] ref_blue_sky = null; // turn off "lma" in the ML output  
		quadCLT_ref.preExpandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
				clt_parameters,
				debayerParameters,
				colorProcParameters,
				rgbParameters,
				threadsMax,  // maximal number of threads to launch
				updateStatus,
				debugLevelInner);
		double [][] aux_last_scan = TileProcessor.getDSLMA(
				quadCLT_ref.tp.clt_3d_passes.get( quadCLT_ref.tp.clt_3d_passes.size() -1),
				false); // boolean force_final);
		double [][] dsi = new double [TwoQuadCLT.DSI_SLICES.length][];
		dsi[TwoQuadCLT.DSI_DISPARITY_AUX] =     aux_last_scan[0];
		dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      aux_last_scan[1];
		dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA] = aux_last_scan[2];
		dsi[TwoQuadCLT.DSI_SPREAD_AUX] =        aux_last_scan[3];
		dsi[TwoQuadCLT.DSI_AVGVAL_AUX] =        aux_last_scan[4];
		if (quadCLT_main.correctionsParameters.clt_batch_dsi_cm_strength) {
			CLTPass3d scan = new CLTPass3d(quadCLT_ref.tp);
			scan.setTileOpDisparity(aux_last_scan[0]); // measure w/o LMA, use just strength
			quadCLT_ref.CLTMeas( // perform single pass according to prepared tiles operations and disparity
					clt_parameters, // EyesisCorrectionParameters.CLTParameters           clt_parameters,
					scan,           // final CLTPass3d   scan,
					false,          // final boolean     save_textures,
					false,          // final boolean       need_diffs,     // calculate diffs even if textures are not needed 
					0,              // final int         clust_radius,
					true,           // final boolean     save_corr,
					false,          // final boolean     run_lma, // =    true;
					0.0,            // final double        max_chn_diff, // filter correlation results by maximum difference between channels
					-1.0,           // final double        mismatch_override, // keep tile with large mismatch if there is LMA with really strong correlation
					threadsMax,     // final int         threadsMax,  // maximal number of threads to launch
					updateStatus,   // final boolean     updateStatus,
					debugLevel-2);  // final int         debugLevel);
			dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      scan.getStrength();
			if (debugLevel > 1) {
				quadCLT_ref.tp.showScan(
						scan, // CLTPass3d   scan,
						"test-strength");
			}
		} else {
			dsi[TwoQuadCLT.DSI_STRENGTH_AUX] =      aux_last_scan[1];
		}
		boolean ran_photo_each = false;
		// perform photometric here, after first DSI
		if (photo_each && (!quadCLT_ref.isPhotometricThis() || !batch_mode)) {
//			if (debugLevel > -3) {
//				System.out.println("**** Running photometric equalization for "+quadCLT_ref.getImageName()+
//						", current was from scene "+quadCLT_ref.getPhotometricScene()+" ****");
//			}
			photoEach(
					clt_parameters,      // CLTParameters                                 clt_parameters,
					colorProcParameters, // ColorProcParameters                           colorProcParameters,
					quadCLT_main,        // QuadCLT                                       quadCLT_main, // tiles should be set
					quadCLT_ref,         // QuadCLT                                       quadCLT_ref, // tiles should be set
					dsi,                 // final double [][]                             dsi,
			    	clt_parameters.photo_num_full, // int      photo_num_full =              
					batch_mode,          // final boolean                                 batch_mode,
					threadsMax,          // final int                                     threadsMax,  // int               threadsMax,
					updateStatus,        // final boolean                                 updateStatus,
					debugLevel);         // final int                                     debugLevel)			
			ran_photo_each = true; // will need to re-run after blue sky detection
			
			
		} else {
		} else {
			System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLT_ref.getPhotometricScene());
			System.out.println("(Re)using photometric calibration from this sequence reference "+quadCLT_ref.getPhotometricScene());
			quadCLT_ref.setQuadClt(); // just in case ?
			quadCLT_ref.setQuadClt(); // just in case ?
		}
		}
		boolean retry=false;
		while (true) {
		quadCLT_ref.setBlueSky  (
		quadCLT_ref.setBlueSky  (
				sky_seed,           // double sky_seed, //  =       7.0;  // start with product of strength by diff_second below this
				sky_seed,           // double sky_seed, //  =       7.0;  // start with product of strength by diff_second below this
				lma_seed,
				lma_seed,
@@ -4047,10 +4063,36 @@ public class OpticalFlow {
				dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread,
				dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], // double [] spread,
				dsi[TwoQuadCLT.DSI_AVGVAL_AUX],//	double [] avg_val,
				dsi[TwoQuadCLT.DSI_AVGVAL_AUX],//	double [] avg_val,
				batch_mode? -1: 1); /// debugLevel);        // int debugLevel)
				batch_mode? -1: 1); /// debugLevel);        // int debugLevel)
			if (!retry) {
		if (ran_photo_each) {
//			quadCLT_ref.setBlueSky(null); // Reset blue sky - is it needed?
			// see if blue sky was detected - rerun photoEach
			boolean [] blue_sky = quadCLT_ref.getBlueSky();
			boolean has_blue_sky = false;
			for (int i = 0; i < blue_sky.length; i++) if (blue_sky[i]) {
				has_blue_sky = true;
				break;
				break;
			}
			}
			if (has_blue_sky) {
				if (debugLevel > -3) {
					System.out.println("Detected non-empty Blue Sky after initial DSI in "+quadCLT_ref.getImageName()+
							", re-running photoEach()");
				}
				}
				photoEach(
						clt_parameters,      // CLTParameters                                 clt_parameters,
						colorProcParameters, // ColorProcParameters                           colorProcParameters,
						quadCLT_main,        // QuadCLT                                       quadCLT_main, // tiles should be set
						quadCLT_ref,         // QuadCLT                                       quadCLT_ref, // tiles should be set
						dsi,                 // final double [][]                             dsi,
						// just once?
				    	clt_parameters.photo_num_full, // int      photo_num_full =              
						batch_mode,          // final boolean                                 batch_mode,
						threadsMax,          // final int                                     threadsMax,  // int               threadsMax,
						updateStatus,        // final boolean                                 updateStatus,
						debugLevel);         // final int                                     debugLevel)			
			}
		}
		
		quadCLT_ref.saveDSIAll (
		quadCLT_ref.saveDSIAll (
				"-DSI_MAIN", // String suffix, // "-DSI_MAIN"
				"-DSI_MAIN", // String suffix, // "-DSI_MAIN"
				dsi);
				dsi);
@@ -4081,8 +4123,12 @@ public class OpticalFlow {
	
	
	public static void reuseRefDSI(
	public static void reuseRefDSI(
			CLTParameters       clt_parameters,
			CLTParameters       clt_parameters,
			ColorProcParameters colorProcParameters,
			QuadCLT             quadCLT_main, // tiles should be set
			QuadCLT             quadCLT_main, // tiles should be set
			QuadCLT             quadCLT_ref, // tiles should be set
			QuadCLT             quadCLT_ref, // tiles should be set
			final boolean       batch_mode,
			final int           threadsMax,  // int               threadsMax,
			final boolean       updateStatus,
			final int           debugLevel) {
			final int           debugLevel) {
		boolean  photo_each =        clt_parameters.photo_each; //        true;  // perform photogrammetric calibration to equalize pixel values
		boolean  photo_each =        clt_parameters.photo_each; //        true;  // perform photogrammetric calibration to equalize pixel values
		boolean  photo_to_main=      clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence
		boolean  photo_to_main=      clt_parameters.photo_to_main; // maybe it will not be needed, it will apply this calibration to the next scene sequence
@@ -4129,6 +4175,8 @@ public class OpticalFlow {
		if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) {
		if (dsi[TwoQuadCLT.DSI_SPREAD_AUX] == null) {
			System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate.");
			System.out.println("DSI_MAIN file has old format and does not have spread data, will recalculate.");
		} else {
		} else {
			boolean [] ref_blue_sky = quadCLT_ref.getBlueSky();
			if (ref_blue_sky == null) {
				quadCLT_ref.setBlueSky  (
				quadCLT_ref.setBlueSky  (
						sky_seed,                              // double sky_seed, //  =       7.0;  // start with product of strength by diff_second below this
						sky_seed,                              // double sky_seed, //  =       7.0;  // start with product of strength by diff_second below this
						lma_seed,                              //          2.0;  // seed - disparity_lma limit
						lma_seed,                              //          2.0;  // seed - disparity_lma limit
@@ -4154,6 +4202,24 @@ public class OpticalFlow {
						dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], //double [] disp_lma,
						dsi[TwoQuadCLT.DSI_DISPARITY_AUX_LMA], //double [] disp_lma,
						dsi[TwoQuadCLT.DSI_AVGVAL_AUX],//	double [] avg_val,
						dsi[TwoQuadCLT.DSI_AVGVAL_AUX],//	double [] avg_val,
						debugLevel);        // int debugLevel)
						debugLevel);        // int debugLevel)
						if (debugLevel > -3) {
							System.out.println("Calculated missing Blue Sky in "+quadCLT_ref.getImageName()+
									", re-running photoEach()");
						}
						photoEach(
								clt_parameters,      // CLTParameters                                 clt_parameters,
								colorProcParameters, // ColorProcParameters                           colorProcParameters,
								quadCLT_main,        // QuadCLT                                       quadCLT_main, // tiles should be set
								quadCLT_ref,         // QuadCLT                                       quadCLT_ref, // tiles should be set
								dsi,                 // final double [][]                             dsi,
								// just once?
						    	clt_parameters.photo_num_full, // int      photo_num_full =              
								batch_mode,          // final boolean                                 batch_mode,
								threadsMax,          // final int                                     threadsMax,  // int               threadsMax,
								updateStatus,        // final boolean                                 updateStatus,
								debugLevel);         // final int                                     debugLevel)			
				}
		}
		}
	}
	}
@@ -4179,7 +4245,8 @@ public class OpticalFlow {
    	int      photo_offs_set =            clt_parameters.photo_offs_set; //  0;    // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
    	int      photo_offs_set =            clt_parameters.photo_offs_set; //  0;    // 0 - keep weighted offset average, 1 - balance result image, 2 - set weighted average to specific value
    	double   photo_offs =                clt_parameters.photo_offs;     // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
    	double   photo_offs =                clt_parameters.photo_offs;     // 21946; // weighted average offset target value, if photo_offs_set (and not photo_offs_balance)
    	boolean  photo_debug =               clt_parameters.photo_debug; //       false; // Generate images and text
    	boolean  photo_debug =               clt_parameters.photo_debug; //       false; // Generate images and text
    	boolean [] ref_blue_sky = null; // turn off "lma" in the ML output  
    	boolean [] ref_blue_sky = quadCLTs[ref_index].getBlueSky(); // null; // turn off "lma" in the ML output
		for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) {
		for (int nrecalib = 0; nrecalib < photo_num_full; nrecalib++) {
			int poly_order = photo_order;
			int poly_order = photo_order;
			if ((poly_order > 1) && (nrecalib == 0)) {
			if ((poly_order > 1) && (nrecalib == 0)) {
@@ -4198,6 +4265,7 @@ public class OpticalFlow {
					photo_num_refines,        // final int         num_refines, // 2
					photo_num_refines,        // final int         num_refines, // 2
				    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
				    photo_min_good, // final int         min_good,     // minimal number of "good" pixels
					combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
					combo_dsn_final_filtered, // final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
					ref_blue_sky, // final boolean[]   blue_sky,
					threadsMax,               // int               threadsMax,
					threadsMax,               // int               threadsMax,
					photo_debug);             //final boolean     debug)
					photo_debug);             //final boolean     debug)
			// copy offsets to the current to be saved with other properties. Is it correct/needed?
			// copy offsets to the current to be saved with other properties. Is it correct/needed?
@@ -4475,8 +4543,12 @@ public class OpticalFlow {
				// need to read photometric from reference scene -INTERFRAME.corr-xml, and if it exists - set and propagate to main?
				// need to read photometric from reference scene -INTERFRAME.corr-xml, and if it exists - set and propagate to main?
				reuseRefDSI(
				reuseRefDSI(
						clt_parameters,      // CLTParameters  clt_parameters,
						clt_parameters,      // CLTParameters  clt_parameters,
						colorProcParameters, // ColorProcParameters colorProcParameters,
						quadCLT_main,        // QuadCLT        quadCLT_main, // tiles should be set
						quadCLT_main,        // QuadCLT        quadCLT_main, // tiles should be set
						quadCLTs[ref_index], // QuadCLT        quadCLT_ref, // tiles should be set
						quadCLTs[ref_index], // QuadCLT        quadCLT_ref, // tiles should be set
						batch_mode,			 // final boolean       batch_mode,
						threadsMax, 		 // final int           threadsMax,
						updateStatus,		 // final boolean       updateStatus,
						debugLevel);         // int            debugLevel)
						debugLevel);         // int            debugLevel)
			}
			}
			
			
+7 −1
Original line number Original line Diff line number Diff line
@@ -847,6 +847,7 @@ public class QuadCLT extends QuadCLTCPU {
			final int         num_refines, // 2
			final int         num_refines, // 2
			final int         min_good,     // minimal number of "good" pixels
			final int         min_good,     // minimal number of "good" pixels
			final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
			final double [][] combo_dsn_final,     // double [][]    combo_dsn_final, // dls,
			final boolean[]   blue_sky,
			int               threadsMax,
			int               threadsMax,
			final boolean     debug)
			final boolean     debug)
	{
	{
@@ -861,6 +862,11 @@ public class QuadCLT extends QuadCLTCPU {
					disparity_ref[i] = Double.NaN;
					disparity_ref[i] = Double.NaN;
				}
				}
			}
			}
			if (blue_sky != null) {
				for (int i = 0; i < blue_sky.length; i++) if (blue_sky[i]) {
						disparity_ref[i] = 0.0;
				}
			}
			
			
			ImagePlus img_ref = renderGPUFromDSI(
			ImagePlus img_ref = renderGPUFromDSI(
					-1,                 // final int         sensor_mask,
					-1,                 // final int         sensor_mask,