Commit ba6fb0e3 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

working on large cluster in low-contarst (clouds in the sky)

parent 08bccd0d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public class CLTParameters {
	public double     shift_x =           0.0;
	public double     shift_y =           0.0;
	public int        tileStep =            4;  // process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters
	public int        super_radius =        2;  // Consolidate multiple clusterts for low-contrast infinity (clouds in the sky) 0 - none, 1 - 3x3, 2 - 5x5,
	public int        iclt_mask =          15;  // which transforms to combine
	public int        tileX =            -258;  // number of kernel tile (0..163)
	public int        tileY =             133;  // number of kernel tile (0..122)
@@ -899,6 +900,7 @@ public class CLTParameters {
		properties.setProperty(prefix+"shift_x",                    this.shift_x+"");
		properties.setProperty(prefix+"shift_y",                    this.shift_y+"");
		properties.setProperty(prefix+"tileStep",                   this.tileStep+"");
		properties.setProperty(prefix+"tileSizeBg",                 this.super_radius+"");
		properties.setProperty(prefix+"iclt_mask",                  this.iclt_mask+"");
		properties.setProperty(prefix+"tileX",                      this.tileX+"");
		properties.setProperty(prefix+"tileY",                      this.tileY+"");
@@ -1668,6 +1670,7 @@ public class CLTParameters {
		if (properties.getProperty(prefix+"shift_y")!=null)                       this.shift_y=Double.parseDouble(properties.getProperty(prefix+"shift_y"));

		if (properties.getProperty(prefix+"tileStep")!=null)                      this.tileStep=Integer.parseInt(properties.getProperty(prefix+"tileStep"));
		if (properties.getProperty(prefix+"tileSizeBg")!=null)                    this.super_radius=Integer.parseInt(properties.getProperty(prefix+"tileSizeBg"));
		if (properties.getProperty(prefix+"iclt_mask")!=null)                     this.iclt_mask=Integer.parseInt(properties.getProperty(prefix+"iclt_mask"));
		if (properties.getProperty(prefix+"tileX")!=null)                         this.tileX=Integer.parseInt(properties.getProperty(prefix+"tileX"));
		if (properties.getProperty(prefix+"tileY")!=null)                         this.tileY=Integer.parseInt(properties.getProperty(prefix+"tileY"));
@@ -2456,6 +2459,8 @@ public class CLTParameters {

		gd.addNumericField("Lazy eye cluster size",                                                             this.tileStep,                  0, 6, "tiles",
				"Process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters");
		gd.addNumericField("Consolidate multiple clusterts around given for low-contrast infinity",             this.super_radius,              0, 6, "clusters",
				"e.g. for clouds in tghe sky  0 - none, 1 - 3x3, 2 - 5x5");
		gd.addNumericField("Bit mask - which of 4 transforms to combine after iclt",                            this.iclt_mask,                 0);
		gd.addNumericField("Tile X to extract (0..163)",                                                        this.tileX,                     0);
		gd.addNumericField("Tile Y to extract (0..122)",                                                        this.tileY,                     0);
@@ -3392,6 +3397,7 @@ public class CLTParameters {
		this.shift_y =              gd.getNextNumber();

		this.tileStep=        (int) gd.getNextNumber();
		this.super_radius=    (int) gd.getNextNumber();
		this.iclt_mask=       (int) gd.getNextNumber();
		this.tileX=           (int) gd.getNextNumber();
		this.tileY=           (int) gd.getNextNumber();
+17 −0
Original line number Diff line number Diff line
@@ -631,6 +631,7 @@ private Panel panel1,
			addButton("CLT disparity scan",        panelClt2, color_conf_process);
			addButton("CLT reset fine corr",       panelClt2, color_stop);
			addButton("CLT reset extrinsic corr",  panelClt2, color_stop);
			addButton("ERS reset",      panelClt2, color_stop);
			addButton("CLT show geometry",         panelClt2, color_configure);
			addButton("CLT show fine corr",        panelClt2, color_report);
			addButton("CLT apply fine corr",       panelClt2, color_process);
@@ -711,6 +712,7 @@ private Panel panel1,

			addButton("LWIR_TEST",                  panelClt_GPU, color_conf_process);
			addButton("LWIR_ACQUIRE",               panelClt_GPU, color_conf_process);
			addButton("ERS reset",      panelClt2, color_stop);
			addButton("IMU main",                   panelClt_GPU, color_conf_process);
			addButton("ERS main",                   panelClt_GPU, color_process);
			addButton("IMU aux",                    panelClt_GPU, color_conf_process_aux);
@@ -4559,6 +4561,21 @@ private Panel panel1,
        }
        QUAD_CLT.resetExtrinsicCorr(CLT_PARAMETERS);
        return;
    } else if (label.equals("ERS reset")) {
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
        			QuadCLT.PREFIX,
        			PROPERTIES,
        			EYESIS_CORRECTIONS,
        			CORRECTION_PARAMETERS);
        	if (DEBUG_LEVEL > 0){
        		System.out.println("Created new QuadCLT instance, will need to read CLT kernels");
        	}
        }
        QUAD_CLT.resetExtrinsicCorr(CLT_PARAMETERS);
        return;
        
        
    } else if (label.equals("CLT show geometry")) {
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
+2 −9
Original line number Diff line number Diff line
@@ -1647,14 +1647,7 @@ public class GPUTileProcessor {
                IJ.showMessage("Error", "No GPU kernel: GPU_CALCULATE_TILES_OFFSETS_kernel");
                return;
            }
    		if (gpu_debug_level > -1) {
    			System.out.println("num_task_tiles="+num_task_tiles);
    		}

            // kernel parameters: pointer to pointers
//            int [] GridFullWarps =    {(num_task_tiles + 2 * TILES_PER_BLOCK_GEOM - 1)/TILES_PER_BLOCK_GEOM, 1, 1}; // round up
//            int [] ThreadsFullWarps = {num_cams, TILES_PER_BLOCK_GEOM, 1}; // 4,8,1
            int [] GridFullWarps =    {1, 1, 1}; // round up
            int [] GridFullWarps =    {1, 1, 1}; 
            int [] ThreadsFullWarps = {1, 1, 1}; // 4,8,1
            Pointer kernelParameters = Pointer.to(
            		Pointer.to(gpu_tasks),                   // struct tp_task     * gpu_tasks,
@@ -1671,7 +1664,7 @@ public class GPUTileProcessor {
        			kernelParameters, null);   // Kernel- and extra parameters
        	cuCtxSynchronize(); // remove later
    		if (gpu_debug_level > -1) {
    			System.out.println("======execSetTilesOffsets()");
    			System.out.println("======execSetTilesOffsets(), num_task_tiles="+num_task_tiles);
    		}
        }

+176 −1
Original line number Diff line number Diff line
@@ -1460,10 +1460,12 @@ public class Corr2dLMA {
		return rslt;
	}

	public double [][] lmaDisparityStrength(
	
	public double [][] lmaDisparityStrength( // restored from git
			double  lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
			double  lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
			double  lma_min_ac,       // minimal of A and C coefficients maximum (measures sharpest point/line)
			double  lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
			double  lma_max_area,     // maximal half-area (if > 0.0)
			double  lma_str_scale,    // convert lma-generated strength to match previous ones - scale
			double  lma_str_offset    // convert lma-generated strength to match previous ones - add to result
@@ -1506,6 +1508,179 @@ public class Corr2dLMA {
		return ds;
	}


	
	public double [][] lmaDisparityStrength0(
			double  lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
			double  lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
			double  lma_min_max_ac,   // minimal of A and C coefficients maximum (measures sharpest point/line)
			double  lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
			double  lma_max_area,     // maximal half-area (if > 0.0)
			double  lma_str_scale,    // convert lma-generated strength to match previous ones - scale
			double  lma_str_offset    // convert lma-generated strength to match previous ones - add to result
			){
		double [][] ds =         new double[numTiles][2];
		double []   rms =        getRmsTile();
		double [][] maxmin_amp = getMaxMinAmpTile();
		double [][] abc =        getABCTile();
		for (int tile = 0; tile < numTiles; tile++) {
			ds[tile][0] = Double.NaN;
			if (Double.isNaN(maxmin_amp[tile][0])) {
				continue;
			}
			double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
			double rrms = rms[tile]/avg;
			if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
					(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac)
//					|| (Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)
					) {
				continue;
			}
			if (lma_max_area > 0) {
				if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
//					double area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
					double area =  1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
					if (area > lma_max_area) {
						continue; // too wide maximum
					}
				} else {
					continue; // not a maximum
				}


			}
			double strength = Math.sqrt(avg/rrms);
			double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
			if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
				continue;
			}
//			strength = Math.sqrt(strength * Math.sqrt(abc[tile][0] * abc[tile][2])); // / area ); // new strength
			ds[tile][0] = disparity;
			ds[tile][1] = (strength * lma_str_scale) + lma_str_offset;
		}
		return ds;
	}
	
	public double [][] lmaDisparityStrengthLY(
			double  lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
			double  lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
			double  lma_min_max_ac,   // minimal of A and C coefficients maximum (measures sharpest point/line)
			double  lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
			double  lma_max_area,     // maximal half-area (if > 0.0)
			double  lma_str_scale,    // convert lma-generated strength to match previous ones - scale
			double  lma_str_offset    // convert lma-generated strength to match previous ones - add to result
			){
		double [][] ds =         new double[numTiles][2];
		double []   rms =        getRmsTile();
		double [][] maxmin_amp = getMaxMinAmpTile();
		double [][] abc =        getABCTile();
		for (int tile = 0; tile < numTiles; tile++) {
			ds[tile][0] = Double.NaN;
			if (Double.isNaN(maxmin_amp[tile][0])) {
				continue;
			}
			double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
			double rrms = rms[tile]/avg;
			if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
					(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac) ||
					(Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)) {
				continue;
			}
			if (lma_max_area > 0) {
				if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
//					double area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
					double area =  1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
					if (area > lma_max_area) {
						continue; // too wide maximum
					}
				} else {
					continue; // not a maximum
				}


			}
			double strength = Math.sqrt(avg/rrms);
			double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
			if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
				continue;
			}
			strength = Math.sqrt(strength * Math.sqrt(abc[tile][0] * abc[tile][2])); // / area ); // new strength
			ds[tile][0] = disparity;
			ds[tile][1] = (strength * lma_str_scale) + lma_str_offset;
		}
		return ds;
	}
	
	
	
	public double [][] lmaGetExtendedStats(
			double  lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
			double  lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
			double  lma_min_max_ac,   // minimal of A and C coefficients maximum (measures sharpest point/line)
			double  lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
			double  lma_max_area,     // maximal half-area (if > 0.0)
			double  lma_str_scale,    // convert lma-generated strength to match previous ones - scale
			double  lma_str_offset    // convert lma-generated strength to match previous ones - add to result
			){
//		double [][] ds =         new double[numTiles][2];
		double [][] ext_stats =  new double[numTiles][11];
		double []   rms =        getRmsTile();
		double [][] maxmin_amp = getMaxMinAmpTile();
		double [][] abc =        getABCTile();
		for (int tile = 0; tile < numTiles; tile++) {
			if (Double.isNaN(maxmin_amp[tile][0])) {
				if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 1;
			}
			ext_stats[tile][0] = maxmin_amp[tile][0];

			double avg = 0.5*(maxmin_amp[tile][0]+maxmin_amp[tile][1]);
			double rrms = rms[tile]/avg;
			ext_stats[tile][1] = avg;
			ext_stats[tile][2] = rrms; // -lma_max_rel_rms;
//			ext_stats[tile][3] = Math.max(abc[tile][0], abc[tile][2])-lma_min_ac;
			
			if (((lma_max_rel_rms > 0.0) && (rrms > lma_max_rel_rms)) ||
					(Math.max(abc[tile][0], abc[tile][2]) < lma_min_max_ac) ||
					(Math.min(abc[tile][0], abc[tile][2]) < lma_min_min_ac)) {
				if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 2;
//				continue;
			}
			double area =  Double.NaN;
			double area_old = Double.NaN;
			if (lma_max_area > 0) {
				ext_stats[tile][5] = abc[tile][0];
				ext_stats[tile][6] = abc[tile][2];

				if ((abc[tile][0] > 0.0) && (abc[tile][2] > 0.0)) {
					area_old = 1.0/abc[tile][0] + 1.0/abc[tile][2]; // area of a maximum
					area =  1.0/Math.sqrt(abc[tile][0] * abc[tile][2]);
					if (area > lma_max_area) {
						if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 3;
//						continue; // too wide maximum
					}
				} else {
					if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 4;
//					continue; // not a maximum
				}
				ext_stats[tile][7] = 1.0/area; // area-lma_max_area;
				ext_stats[tile][4] = 1.0/area_old;
			}
			double strength = Math.sqrt(avg/rrms);
			ext_stats[tile][9] = (strength * lma_str_scale) + lma_str_offset;
			ext_stats[tile][3] = Math.sqrt(strength / area ); // new strength
			double disparity = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
			if ((strength < lma_min_strength) || Double.isNaN(disparity)) {
				if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 5;
				continue;
			}
			
			ext_stats[tile][8] = -all_pars[DISP_INDEX + tile*TILE_PARAMS];
			if (ext_stats[tile][10] == 0) ext_stats[tile][10] = 6;
		}
		return ext_stats;
	}
//			ext_stats[tile][3] = Math.max(abc[tile][0], abc[tile][2])-lma_min_ac;

	public double [][] getDdNd(){ // this.all_pars should be current
		double [][] ddnd = new double [NUM_CAMS][2];
		for (int nc = 0; nc < NUM_CAMS; nc++) {
+4 −1
Original line number Diff line number Diff line
@@ -2449,6 +2449,7 @@ public class Correlation2d {
    				imgdtt_params.lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
    				imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
    				imgdtt_params.lma_min_ac,       // minimal of A and C coefficients maximum (measures sharpest point/line)
    				imgdtt_params.lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
    				imgdtt_params.lma_max_area,     //double  lma_max_area,     // maximal half-area (if > 0.0)
    				imgdtt_params.lma_str_scale,    // convert lma-generated strength to match previous ones - scale
    				imgdtt_params.lma_str_offset    // convert lma-generated strength to match previous ones - add to result
@@ -2547,6 +2548,7 @@ public class Correlation2d {
    						imgdtt_params.lma_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
    						imgdtt_params.lma_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
    						imgdtt_params.lma_min_ac,       // minimal of A and C coefficients maximum (measures sharpest point/line)
    	    				imgdtt_params.lma_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
    	    				imgdtt_params.lma_max_area,      //double  lma_max_area,     // maximal half-area (if > 0.0)
    						imgdtt_params.lma_str_scale,    // convert lma-generated strength to match previous ones - scale
    						imgdtt_params.lma_str_offset    // convert lma-generated strength to match previous ones - add to result
@@ -2842,6 +2844,7 @@ public class Correlation2d {
    				imgdtt_params.lmas_max_rel_rms,  // maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
    				imgdtt_params.lmas_min_strength, // minimal composite strength (sqrt(average amp squared over absolute RMS)
    				imgdtt_params.lmas_min_ac,       // minimal of A and C coefficients maximum (measures sharpest point/line)
    				imgdtt_params.lmas_min_min_ac,   // minimal of A and C coefficients minimum (measures sharpest point)
    				imgdtt_params.lmas_max_area,     //double  lma_max_area,     // maximal half-area (if > 0.0)
    				imgdtt_params.lma_str_scale,     // convert lma-generated strength to match previous ones - scale
    				imgdtt_params.lma_str_offset     // convert lma-generated strength to match previous ones - add to result
Loading