Commit 91f2ace8 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Adding arbitrary reference frame (not just the last), debugging 'Super

batch'
parent dc3b8518
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2705,7 +2705,7 @@ public class EyesisCorrections {
				png,
				png,
				show,
				show,
				jpegQuality,//  <0 - keep current, 0 - force Tiff, >0 use for JPEG
				jpegQuality,//  <0 - keep current, 0 - force Tiff, >0 use for JPEG
				this.debugLevel);
				this.debugLevel+3);
	}
	}




+3 −1
Original line number Original line Diff line number Diff line
@@ -7141,7 +7141,9 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		QuadCLT quadCLT = use_aux ? QUAD_CLT_AUX : QUAD_CLT;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		ColorProcParameters colorProcParameters = use_aux ? COLOR_PROC_PARAMETERS_AUX : COLOR_PROC_PARAMETERS;
		try {
		try {
			TWO_QUAD_CLT.interIntraExportML(quadCLT, // QuadCLT quadCLT_main,
			TWO_QUAD_CLT.interIntraExportML(
					quadCLT, // QuadCLT quadCLT_main,
					-1, // use last // int  indx_ref,     // = num_scenes - 1; 
					CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
					CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
					DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
					DEBAYER_PARAMETERS, // EyesisCorrectionParameters.DebayerParameters debayerParameters,
					colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
					colorProcParameters, // EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
+35 −30
Original line number Original line Diff line number Diff line
@@ -1526,7 +1526,8 @@ public class OpticalFlow {
							}
							}
							int iwidth =  imax_tX - imin_tX + 1;
							int iwidth =  imax_tX - imin_tX + 1;
							int iheight = imax_tY - imin_tY + 1;
							int iheight = imax_tY - imin_tY + 1;
							if ((iwidth <= 0) || (iheight <= 0)) {
////							if ((iwidth <= 0) || (iheight <= 0)) {
							if ((iwidth <= 1) || (iheight <= 1)) {
								System.out.println ("prepareSceneTiles(): iwidth ="+iwidth+", iheight ="+iheight+", min_tX="+min_tX+", imin_tY="+imin_tY+", max_tX="+max_tX+", imax_tY="+imax_tY);
								System.out.println ("prepareSceneTiles(): iwidth ="+iwidth+", iheight ="+iheight+", min_tX="+min_tX+", imin_tY="+imin_tY+", max_tX="+max_tX+", imax_tY="+imax_tY);
								continue;
								continue;
							}
							}
@@ -3480,8 +3481,8 @@ public class OpticalFlow {
		}		
		}		
		double [][] disparity_map = null;
		double [][] disparity_map = null;
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
			Runtime.getRuntime().gc();
	///		Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
	///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
			int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
			int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
			disparity_map = correlateInterscene(
			disparity_map = correlateInterscene(
					clt_parameters, // final CLTParameters  clt_parameters,
					clt_parameters, // final CLTParameters  clt_parameters,
@@ -3496,8 +3497,8 @@ public class OpticalFlow {
					false,          // final boolean        no_map, // do not generate disparity_map (time-consuming LMA)
					false,          // final boolean        no_map, // do not generate disparity_map (time-consuming LMA)
					debug_level-5);   // final int            debug_level)
					debug_level-5);   // final int            debug_level)


			Runtime.getRuntime().gc();
	///		Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
	///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");


			(new ShowDoubleFloatArrays()).showArrays(
			(new ShowDoubleFloatArrays()).showArrays(
					disparity_map,
					disparity_map,
@@ -3699,8 +3700,8 @@ public class OpticalFlow {
			}
			}
		}
		}
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
			Runtime.getRuntime().gc();
///			Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");


			double [][] disparity_map = 
			double [][] disparity_map = 
					//		double [][][][][] clt_corr_partial =
					//		double [][][][][] clt_corr_partial =
@@ -3713,8 +3714,8 @@ public class OpticalFlow {
							nrefine,        // final int            nrefine, // just for debug title
							nrefine,        // final int            nrefine, // just for debug title
							debug_level-5);   // final int            debug_level)
							debug_level-5);   // final int            debug_level)


			Runtime.getRuntime().gc();
///			Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
			if (debug_level > 0) {
			if (debug_level > 0) {
				(new ShowDoubleFloatArrays()).showArrays(
				(new ShowDoubleFloatArrays()).showArrays(
						disparity_map,
						disparity_map,
@@ -3972,8 +3973,8 @@ public class OpticalFlow {
		}
		}
		
		
        ImagePlus imp_stack = new ImagePlus("scene_outlines", stack);
        ImagePlus imp_stack = new ImagePlus("scene_outlines", stack);
        imp_stack.getProcessor().resetMinAndMax();
//        imp_stack.getProcessor().resetMinAndMax();
        imp_stack.show();
//       imp_stack.show();
		return imp_stack;
		return imp_stack;
	}
	}
	
	
@@ -3987,6 +3988,7 @@ public class OpticalFlow {
			int                  debug_level
			int                  debug_level
			)
			)
	{
	{
		boolean generate_outlines = true; // TODO: move to configs
		System.out.println("intersceneExport(), scene timestamp="+ref_scene.getImageName());
		System.out.println("intersceneExport(), scene timestamp="+ref_scene.getImageName());
		int num_scenes = scenes.length;
		int num_scenes = scenes.length;
		String [] combo_dsn_titles = {"disp", "strength","disp_lma","num_valid","change"};
		String [] combo_dsn_titles = {"disp", "strength","disp_lma","num_valid","change"};
@@ -4023,7 +4025,7 @@ public class OpticalFlow {
		final int tilesX = ref_scene.getTileProcessor().getTilesX();
		final int tilesX = ref_scene.getTileProcessor().getTilesX();
		final int tilesY = ref_scene.getTileProcessor().getTilesY();
		final int tilesY = ref_scene.getTileProcessor().getTilesY();
		final int tiles = tilesX * tilesY;
		final int tiles = tilesX * tilesY;
		if (debug_level > 100) { // add parameter?
		if (generate_outlines) { // debug_level > 100) { // add parameter?
			int        extra = 10; // pixels around largest outline
			int        extra = 10; // pixels around largest outline
			int        scale = 4;
			int        scale = 4;


@@ -4043,7 +4045,10 @@ public class OpticalFlow {
					line_color_outline, // Color      line_color_outline,
					line_color_outline, // Color      line_color_outline,
					line_color_corners  // Color      line_color_corners
					line_color_corners  // Color      line_color_corners
					);
					);
			imp_outlines.show();
			ref_scene.saveImagePlusInModelDirectory(
					"scene_outlines", // String      suffix,
					imp_outlines); // ImagePlus   imp)
//			imp_outlines.show();
		}
		}
		final double [][] combo_dsn_change = new double [combo_dsn_titles.length] [tiles];
		final double [][] combo_dsn_change = new double [combo_dsn_titles.length] [tiles];
		for (int i = 0; i < combo_dsn.length; i++) { // 4 elements: "disp", "strength","disp_lma","num_valid"
		for (int i = 0; i < combo_dsn.length; i++) { // 4 elements: "disp", "strength","disp_lma","num_valid"
@@ -4792,8 +4797,8 @@ public class OpticalFlow {
			}
			}
		}		
		}		
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
		for (int nrefine = 0; nrefine < max_refines; nrefine++) {
			Runtime.getRuntime().gc();
///			Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
			int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
			int mcorr_sel = Correlation2d.corrSelEncode(clt_parameters.img_dtt,scenes[indx_ref].getNumSensors());
			double [][] disparity_map = 
			double [][] disparity_map = 
					correlateInterscene(
					correlateInterscene(
@@ -4809,8 +4814,8 @@ public class OpticalFlow {
							false,          // final boolean        no_map, // do not generate disparity_map (time-consuming LMA)
							false,          // final boolean        no_map, // do not generate disparity_map (time-consuming LMA)
							debug_level-5);   // final int            debug_level)
							debug_level-5);   // final int            debug_level)


			Runtime.getRuntime().gc();
///			Runtime.getRuntime().gc();
			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///			System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
			
			
			if (debug_level > 0) {
			if (debug_level > 0) {
				(new ShowDoubleFloatArrays()).showArrays(
				(new ShowDoubleFloatArrays()).showArrays(
@@ -5228,8 +5233,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
						wis_wh,                   // final int []         wh,
						wis_wh,                   // final int []         wh,
						image_dtt.transform_size, // final int            transform_size,
						image_dtt.transform_size, // final int            transform_size,
						threadsMax);              // final int            threadsMax)     // maximal number of threads to launch
						threadsMax);              // final int            threadsMax)     // maximal number of threads to launch
				Runtime.getRuntime().gc();
///				Runtime.getRuntime().gc();
				System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///				System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
			}
			}
			if ((vis_corr_pd != null) || (fclt_corrs != null)) { // calculate and extract correlation
			if ((vis_corr_pd != null) || (fclt_corrs != null)) { // calculate and extract correlation
				image_dtt.clt_process_tl_correlations_GPU(	// convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
				image_dtt.clt_process_tl_correlations_GPU(	// convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
@@ -5276,8 +5281,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
							threadsMax); // final int          threadsMax)     // maximal number of threads to launch
							threadsMax); // final int          threadsMax)     // maximal number of threads to launch
							
							
				}
				}
				Runtime.getRuntime().gc();
///				Runtime.getRuntime().gc();
				System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///				System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
				//nscene
				//nscene
				if (debug_dhv != null) {
				if (debug_dhv != null) {
					debug_dhv[3 * nscene + 0] = disparity_map[ImageDtt.DISPARITY_INDEX_CM];
					debug_dhv[3 * nscene + 0] = disparity_map[ImageDtt.DISPARITY_INDEX_CM];
@@ -5450,8 +5455,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
					dbg_titles);
					dbg_titles);
		}
		}
		
		
		Runtime.getRuntime().gc();
///		Runtime.getRuntime().gc();
		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
		final float  [][][]       fclt_corr = new float [tilesX * tilesY][][];
		final float  [][][]       fclt_corr = new float [tilesX * tilesY][][];
		image_dtt.clt_process_tl_correlations_GPU(	// convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
		image_dtt.clt_process_tl_correlations_GPU(	// convert to pixel domain and process correlations already prepared in fcorr_td and/or fcorr_combo_td
				clt_parameters.img_dtt,				// final ImageDttParameters  imgdtt_params,   // Now just extra correlation parameters, later will include, most others
				clt_parameters.img_dtt,				// final ImageDttParameters  imgdtt_params,   // Now just extra correlation parameters, later will include, most others
@@ -5914,8 +5919,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
		}		
		}		
		
		
		
		
		Runtime.getRuntime().gc();
///		Runtime.getRuntime().gc();
		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");


		if (vis_corr_td != null) { // add combined data as the last slice
		if (vis_corr_td != null) { // add combined data as the last slice
			vis_corr_td[num_scenes] = ImageDtt.corr_td_wnd(
			vis_corr_td[num_scenes] = ImageDtt.corr_td_wnd(
@@ -6281,8 +6286,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad




		}
		}
		Runtime.getRuntime().gc();
///		Runtime.getRuntime().gc();
		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
		// Normalize accumulated corelations
		// Normalize accumulated corelations
		if (ref_scene.hasGPU()) {
		if (ref_scene.hasGPU()) {
			 accumulateCorrelationsAcOnly(
			 accumulateCorrelationsAcOnly(
@@ -6385,8 +6390,8 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
			
			
		}
		}


		Runtime.getRuntime().gc();
///		Runtime.getRuntime().gc();
		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
///		System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
		if (show_accumulated_correlations || (accum_2d_corr != null)){ // -1
		if (show_accumulated_correlations || (accum_2d_corr != null)){ // -1
			float [][] accum_2d_img = ImageDtt.corr_partial_dbg( // not used in lwir
			float [][] accum_2d_img = ImageDtt.corr_partial_dbg( // not used in lwir
					fclt_corr, // final float  [][][]     fcorr_data,       // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
					fclt_corr, // final float  [][][]     fcorr_data,       // [tile][pair][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
+5 −0
Original line number Original line Diff line number Diff line
@@ -109,6 +109,11 @@ public class QuadCLT extends QuadCLTCPU {
		}
		}
	}
	}


	void setQuadClt() {
		if (gpuQuad != null) {
			gpuQuad.updateQuadCLT(this); // to re-load new set of Bayer images to the GPU
		}
	}
	
	
	public QuadCLT(QuadCLTCPU pq, String name) {
	public QuadCLT(QuadCLTCPU pq, String name) {
		super (pq, name);
		super (pq, name);
+18 −5
Original line number Original line Diff line number Diff line
@@ -222,7 +222,10 @@ public class QuadCLTCPU {
		return null;
		return null;
	}
	}
	
	
	void restoreQuadClt(QuadCLT savedQuadClt) {
	void restoreQuadClt(QuadCLT savedQuadClt) { // do nothing
	}
	void setQuadClt() { // do nothing
	}
	}
	
	
	double [][][][][][]  getCltKernels() {                            
	double [][][][][][]  getCltKernels() {                            
@@ -937,10 +940,6 @@ public class QuadCLTCPU {
	}	
	}	
	
	
	
	
	
	
	
	
	public ImagePlus saveDoubleArrayInModelDirectory(
	public ImagePlus saveDoubleArrayInModelDirectory(
			String      suffix,
			String      suffix,
			String []   labels, // or null
			String []   labels, // or null
@@ -959,6 +958,20 @@ public class QuadCLTCPU {
		return imp;
		return imp;
	}
	}
	
	
	public void saveImagePlusInModelDirectory(
			String      suffix,
			ImagePlus   imp)
	{
		String x3d_path = getX3dDirectory();
		String file_name = image_name + suffix;
		String file_path = x3d_path + Prefs.getFileSeparator() + file_name + ".tiff";
		FileSaver fs=new FileSaver(imp);
		fs.saveAsTiff(file_path);
		System.out.println("saveDoubleArrayInModelDirectory(): saved "+file_path);
	}
	
	
	
	public double [][] readDoubleArrayFromModelDirectory(
	public double [][] readDoubleArrayFromModelDirectory(
			String      suffix,
			String      suffix,
			int         num_slices, // (0 - all)
			int         num_slices, // (0 - all)
Loading