Commit 71ac4a10 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Debugging preExpandCLTQuad3d() with 16-sensor LWIR setup

parent 7135cb85
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -126,14 +126,14 @@ public class CLTParameters {

	public double     diff_sigma =        5.0;   // RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
	public double     diff_threshold =    1.5;   // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
	public boolean    diff_gauss =        true;  // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
	public boolean    diff_gauss =        true;  // when averaging images, use Gaussian around average as weight (false - sharp all/nothing)
	public double     min_agree =         3.0;   // minimal number of channels to agree on a point (real number to work with fuzzy averages)
	public boolean    dust_remove =       true;  // Do not reduce average weight when only one image differes much from the average

	public boolean    black_back =        true;  // use Black for backdrop outside of the FOV
	public boolean    keep_weights =      true;  // add port weights to RGBA stack (debug feature)
	public boolean    sharp_alpha =       false; // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
	public double     alpha0 = 	          0.6; // > .525 Alpha channel 0.0 thereshold (lower - transparent) (watch for far objects)
	public double     alpha0 = 	          0.6; // > .525 Alpha channel 0.0 threshold (lower - transparent) (watch for far objects)
	public double     alpha1 = 	          0.8; // Alpha channel 1.0 threshold (higher - opaque) (watch for window dust)

	public boolean    gen_chn_stacks =    false; // generate shifted channel rgb stacks
@@ -345,7 +345,7 @@ public class CLTParameters {
	public int        min_clstr_seed   = 4; //2;     // number of tiles in a cluster to seed (just background?)
	public int        min_clstr_lone   = 4;     // number of tiles in a cluster not close to other clusters (more than 2 tiles apart)
	public double     min_clstr_weight = 0.0;   // Minimal total strength of the cluster
	public double     min_clstr_max    = 0.25;  // Minimal maximal strength of the cluster
	public double     min_clstr_max    = 0.18;  // Minimal maximal strength of the cluster

	public int        fill_gaps        = 4;     // same as in grow - 1:  4 directions by 1 step, 2: 8 directions by 1 step. +2*n - alternating hor/vert
	public int        fill_final       = 50;    // same as fill_gaps, on the final pass
+2 −2
Original line number Diff line number Diff line
@@ -57,8 +57,8 @@ public class CLTPass3d{
		                                                     // exceeds minBgFract, otherwise proceed to the next one (and accumulate strength)
		private double []       bgTileDisparity =      null;
		private double []       bgTileStrength =       null;
		public  boolean []      border_tiles =         null; // these are border tiles, zero out alpha
		public  boolean []      selected =             null; // which tiles are selected for this layer
		private  boolean []     border_tiles =         null; // these are border tiles, zero out alpha
		private  boolean []     selected =             null; // which tiles are selected for this layer
		public  double [][][][] texture_tiles;
		// texture_selection is only used for the GPU and if not null means it is for the GPU
		public boolean []       texture_selection =    null; // use by the GPU to set texture to generate
+20 −20
Original line number Diff line number Diff line
@@ -455,10 +455,10 @@ public class Correlation2d {
					HashSet<Integer> contrib_set = new HashSet<Integer>();
					Iterator<Integer> contrib_itr;
					for (int num_pair = ai.getAndIncrement(); num_pair < corr_pairs.length; num_pair = ai.getAndIncrement()) {
						if (num_pair == 62) {
							System.out.println("num_pair="+num_pair);
							System.out.println("num_pair="+num_pair);
						}
//						if (num_pair == 62) {
//							System.out.println("num_pair="+num_pair);
//							System.out.println("num_pair="+num_pair);
//						}
						if (corr_pairs[num_pair]) {
							resample_indices[num_pair] = new int    [mcorr_comb_width * mcorr_comb_height][];
							resample_weights[num_pair] = new double [mcorr_comb_width * mcorr_comb_height][];
@@ -485,10 +485,10 @@ public class Correlation2d {
									int ix = j - mcorr_comb_width/2;
									Arrays.fill(contrib, 0.0);
									contrib_set.clear();
									if ((num_pair == 62) && (i==7) && (j==7)) {
										System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
										System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
									}
//									if ((num_pair == 62) && (i==7) && (j==7)) {
//										System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
//										System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
//									}
									
									for (int idy = 0; idy < weights_size; idy++) {
										mxy.set(1, 0,  iy+ (idy - SUB_SAMPLE + 1) * ksub); //idy == (SUB_SAMPLE -1) - no fractional pixel
@@ -564,10 +564,10 @@ public class Correlation2d {
 					ArrayList<Integer> contrib_list = new ArrayList<Integer>();
 					ArrayList<Double>  contrib_weights_list = new ArrayList<Double>();
 					for (int num_pair = ai.getAndIncrement(); num_pair < corr_pairs.length; num_pair = ai.getAndIncrement()) {
 						if (num_pair == 62) {
 							System.out.println("num_pair="+num_pair);
 							System.out.println("num_pair="+num_pair);
 						}
// 						if (num_pair == 62) {
// 							System.out.println("num_pair="+num_pair);
// 							System.out.println("num_pair="+num_pair);
// 						}
 						if (corr_pairs[num_pair]) {
 							resample_indices[num_pair] = new int    [mcorr_comb_width * mcorr_comb_height][];
 							resample_weights[num_pair] = new double [mcorr_comb_width * mcorr_comb_height][];
@@ -596,10 +596,10 @@ public class Correlation2d {
 									int iy = i + mcorr_comb_offset - mcorr_comb_height/2;
 									for (int j = 0; j < mcorr_comb_width; j++) {
 										int ix = j - mcorr_comb_width/2;
 										if ((num_pair == 62) && (i==7) && (j==7)) {
 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
 										}
// 										if ((num_pair == 62) && (i==7) && (j==7)) {
// 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
// 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
// 										}
 		 								// convert +/- 1 pixel to pair
 										double minXPair = Double.NaN,minYPair = Double.NaN, maxXPair = Double.NaN, maxYPair = Double.NaN;
 										for (int d = 0; d < four_corners.length; d++) {
@@ -676,10 +676,10 @@ public class Correlation2d {
 										mxy.set(0, 0,  ix);
 										mxy.set(1, 0,  iy);
 										double [] xy_pair = toPair.times(mxy).getColumnPackedCopy();
 										if ((num_pair == 62) && (i==7) && (j==7)) {
 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
 										}
// 										if ((num_pair == 62) && (i==7) && (j==7)) {
// 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
// 											System.out.println("num_pair="+num_pair+", i="+i+", j="+j);
// 										}
 										// find 4 corners in the pair array
 										if (    (xy_pair[0] >= (1 - transform_size)) &&
 												(xy_pair[0] <= (transform_size - 1)) &&
+12 −8
Original line number Diff line number Diff line
@@ -114,8 +114,9 @@ public class ImageDtt extends ImageDttCPU {
//gpuQuad
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;

		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}

@@ -929,8 +930,9 @@ public class ImageDtt extends ImageDttCPU {
//gpuQuad
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;

		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}

@@ -1617,8 +1619,9 @@ public class ImageDtt extends ImageDttCPU {
//gpuQuad
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;

		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
//dbg_pair_mask
@@ -1967,8 +1970,9 @@ public class ImageDtt extends ImageDttCPU {
//gpuQuad
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;

		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
//dbg_pair_mask
+38 −16
Original line number Diff line number Diff line
@@ -1705,8 +1705,9 @@ public class ImageDttCPU {
		final boolean debug_distort= (globalDebugLevel >0); // .false; // true;
//		final double [][] debug_offsets = null;
		//lma_dbg_scale
		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
@@ -2563,8 +2564,9 @@ public class ImageDttCPU {
			final int                 globalDebugLevel)
	{
		final boolean debug_distort= (globalDebugLevel >0); // .false; // true;
		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
@@ -3205,8 +3207,10 @@ public class ImageDttCPU {
			final double [][][][]     clt_combo_dbg,  // generate sparse  partial rotated/scaled pairs
			// When clt_mismatch is non-zero, no far objects extraction will be attempted
			// clt_mismatch is used in older code, not supported in GPU - there is cltMeasureLazyEye for that purpose
			// this.correlation2d should be not null if disparity_map != null
			final double [][]         disparity_map,   // [8][tilesY][tilesX], only [6][] is needed on input or null - do not calculate
			                                           // last 2 - contrast, avg/ "geometric average)
			
			final double [][][][]     texture_tiles,   // [tilesY][tilesX]["RGBA".length()][];  null - will skip images combining
			final int                 width,
			final double              corr_fat_zero,    // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
@@ -3322,8 +3326,9 @@ public class ImageDttCPU {
		}
		final boolean [][] combo_sels = pcombo_sels; 
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;
		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
		
@@ -4112,12 +4117,16 @@ public class ImageDttCPU {
								}
							}
							// iclt here: [quad][color][256]
							if ((globalDebugLevel > 0) && debugTile) {
							if ((globalDebugLevel > 0) && debugTile0) {
								ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
								String [] titles = {"red0","blue0","green0","red1","blue1","green1","red2","blue2","green2","red3","blue3","green3"};
								String [] col_names= {"red","blue","green"};
								String [] titles = new String[numSensors * numcol];
//								String [] titles = {"red0","blue0","green0","red1","blue1","green1","red2","blue2","green2","red3","blue3","green3"};
								double [][] dbg_tile = new double [numSensors*numcol][];
								for (int i = 0; i < numSensors; i++) {
									for (int ncol = 0; ncol <numcol; ncol++) if (iclt_tile[i][ncol] != null) { // color
										String col_name = (ncol < col_names.length)?col_names[ncol]:("c<"+ncol+">");
										titles[i * numcol + ncol] = col_name + i; 
										dbg_tile[i * numcol + ncol] = iclt_tile[i][ncol];
									}
								}
@@ -4145,12 +4154,16 @@ public class ImageDttCPU {
									}
								}
							}
							if ((globalDebugLevel > 0) && debugTile) {
							if ((globalDebugLevel > 0) && debugTile0) {
								ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
								String [] titles = {"red0","blue0","green0","red1","blue1","green1","red2","blue2","green2","red3","blue3","green3"};
								String [] col_names= {"red","blue","green"};
								String [] titles = new String[numSensors * numcol];
								
								double [][] dbg_tile = new double [numSensors*numcol][];
								for (int i = 0; i < numSensors; i++) {
									for (int chn = 0; chn <numcol; chn++) { // color
										String col_name = (chn< col_names.length)?col_names[chn]:("c<"+chn+">");
										titles[i * numcol + chn] = col_name + i; 
										dbg_tile[i * numcol + chn] = tiles_debayered[i][chn];
									}
								}
@@ -4182,7 +4195,10 @@ public class ImageDttCPU {
									(globalDebugLevel > 0) && debugTile,
									false);          // boolean       debug_gpu)      // generate output fro matching with GPU processing
							if ((globalDebugLevel > 0) && debugTile0) {
								ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
								sdfa_instance.showArrays(texture_tiles[tileY][tileX], 2* transform_size, 2* transform_size, true, "tile_combine_rgba_x"+tileX+"_y"+tileY);
							}
							// mix RGB from iclt_tile, mix alpha with - what? correlation strength or 'don't care'? good correlation or all > min?
							for (int i = 0; i < iclt_tile[0][first_color].length; i++ ) {
								double sw = 0.0;
@@ -4197,6 +4213,10 @@ public class ImageDttCPU {
									}
								}
							}
							if ((globalDebugLevel > 0) && debugTile0) { // same as previous for mono
								ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
								sdfa_instance.showArrays(texture_tiles[tileY][tileX], 2* transform_size, 2* transform_size, true, "tile_mixed_rgba_x"+tileX+"_y"+tileY);
							}
							if ((disparity_map != null) && (disparity_map.length >= (IMG_DIFF0_INDEX + numSensors))){
								for (int i = 0; i < max_diff.length; i++){
									disparity_map[IMG_DIFF0_INDEX + i][tIndex] = max_diff[i];
@@ -6702,8 +6722,9 @@ public class ImageDttCPU {
		final boolean [][] saturation_imp = quadCLT.saturation_imp;               // boolean [][] saturation_imp, // (near) saturated pixels or null
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;
		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[quadCLT.getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
		final int quad = 4;   // number of subcameras
@@ -12682,8 +12703,9 @@ public class ImageDttCPU {
		
		final boolean debug_distort= globalDebugLevel > 0; ///false; // true;
		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		for (int i = 0; i < debug_offsets.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
//		final double [][] debug_offsets = new double[imgdtt_params.lma_dbg_offset.length][2];
		final double [][] debug_offsets = new double[getNumSensors()][2];  
		for (int i = 0; i < imgdtt_params.lma_dbg_offset.length; i++) for (int j = 0; j < debug_offsets[i].length; j++) {
			debug_offsets[i][j] = imgdtt_params.lma_dbg_offset[i][j]*imgdtt_params.lma_dbg_scale;
		}
		
Loading