Commit 8991226b authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Tweaking software to handle more precise disparity measurements

parent 957badd3
Loading
Loading
Loading
Loading
+133 −91
Original line number Diff line number Diff line
@@ -539,6 +539,7 @@ public class CLTPass3d{
			final AtomicInteger ai = new AtomicInteger(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
							if (((strength[nTile] < weakStrength) ||
@@ -597,6 +598,7 @@ public class CLTPass3d{
			ai.set(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
							if (nTile == dbg_nTile){
@@ -656,6 +658,7 @@ public class CLTPass3d{
			final AtomicInteger ai = new AtomicInteger(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
							if (known[nTile]){
@@ -688,6 +691,7 @@ public class CLTPass3d{
			final AtomicInteger ai = new AtomicInteger(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
								int tX = nTile % tilesX;
@@ -790,6 +794,7 @@ public class CLTPass3d{
			final AtomicInteger ai = new AtomicInteger(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
							int imax1 = 0;
@@ -813,6 +818,7 @@ public class CLTPass3d{
			ai.set(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) if (measured[nTile]) {
							double sw = 0.0;
@@ -851,6 +857,7 @@ public class CLTPass3d{
			final AtomicInteger ai = new AtomicInteger(0);
			for (int ithread = 0; ithread < threads.length; ithread++) {
				threads[ithread] = new Thread() {
					@Override
					public void run() {
						for (int nTile = ai.getAndIncrement(); nTile < num_tiles; nTile = ai.getAndIncrement()) {
							if (known[nTile]){
@@ -897,6 +904,15 @@ public class CLTPass3d{
				int        smplNum, //         = 3;      // Number after removing worst
				double     smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
				boolean    smplWnd,  // use window functions for the samples

				double     max_abs_tilt,  //  2.0;   // pix per tile
				double     max_rel_tilt,  //  0.2;   // (pix / disparity) per tile
				double     damp_tilt,     //  0.001; // Damp tilt to handle insufficient  (co-linear)data
				double     min_tilt_disp, //  4.0;   // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
				double     transition,    //  1.0;   // Mode transition range (between tilted and maximal disparity)
				int        far_mode,      //  1;     // Far objects filtering mode (0 - off, 1 - power of disparity)
				double     far_power,     //  3.0;   // Raise disparity to this power before averaging for far objects

				int        measSel)
		{
			this.superTiles = new SuperTiles(
@@ -914,6 +930,14 @@ public class CLTPass3d{
					smplNum, //         = 3;      // Number after removing worst
					smplRms, //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
					smplWnd,           // final boolean    smplWnd,  // use window functions for the samples
					max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
					max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
					damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
					min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
					transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
					far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
					far_power,     //    1.0; // Raise disparity to this power before averaging for far objects
//					true,          // boolean    null_if_none,
					measSel);
			return this.superTiles;
		}
@@ -926,6 +950,15 @@ public class CLTPass3d{
				int        smplNum,  //         = 3;      // Number after removing worst
				double     smplRms,  //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
				boolean    smplWnd,  // use window functions for the samples

	  			double     max_abs_tilt,  //  2.0;   // pix per tile
				double     max_rel_tilt,  //  0.2;   // (pix / disparity) per tile
				double     damp_tilt,     //  0.001; // Damp tilt to handle insufficient  (co-linear)data
				double     min_tilt_disp, //  4.0;   // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
				double     transition,    //  1.0;   // Mode transition range (between tilted and maximal disparity)
				int        far_mode,      //  1;     // Far objects filtering mode (0 - off, 1 - power of disparity)
				double     far_power,     //  3.0;   // Raise disparity to this power before averaging for far objects

				int        measSel)
		{
			if (this.superTiles == null){
@@ -940,6 +973,15 @@ public class CLTPass3d{
					smplNum,  //         = 3;      // Number after removing worst
					smplRms,  //         = 0.1;    // Maximal RMS of the remaining tiles in a sample
					smplWnd,  // use window functions for the samples

					max_abs_tilt,  // 2.0; // Maximal absolute tilt in pixels/tile
					max_rel_tilt,  // 0.2; // Maximal relative tilt in pixels/tile/disparity
					damp_tilt,     //    0.001; // Damp tilt to handle insufficient  (co-linear)data
					min_tilt_disp, // 4.0; // Disparity switch between filtering modes - near objects use tilts, far - use max disparity
					transition,    // 1.0; // Mode transition range (between tilted and maximal disparity)
					far_mode,      //     1;   // Far objects filtering mode (0 - off, 1 - power of disparity)
					far_power,     //    1.0; // Raise disparity to this power before averaging for far objects

					measSel);
		}

+212 −1334

File changed.

Preview size limit exceeded, changes collapsed.

+140 −7
Original line number Diff line number Diff line
@@ -572,6 +572,7 @@ private Panel panel1,
			addButton("Infinity offset",            panelClt3, color_configure);
			addButton("Setup CLT Batch parameters", panelClt3, color_configure);
			addButton("CLT batch process",          panelClt3, color_process);
			addButton("CM Test",                    panelClt3, color_stop);
//			addButton("JTabbed",                    panelClt3, color_stop);
//			addButton("Demo",                       panelClt3, color_process);

@@ -3752,7 +3753,7 @@ private Panel panel1,

/* ======================================================================== */
    } else if (label.equals("Setup CLT parameters")) {
    	CLT_PARAMETERS.showDialog();
    	CLT_PARAMETERS.showJDialog();
        return;
/* ======================================================================== */
    } else if (label.equals("Setup CLT")) {
@@ -3769,7 +3770,7 @@ private Panel panel1,
    } else if (label.equals("Select CLT image")) {
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	//            	IJ.showMessage("DCT test 1");
    	if (!CLT_PARAMETERS.showDialog()) return;
    	if (!CLT_PARAMETERS.showJDialog()) return;
    	// process selected image stack
    	ImagePlus imp_src = WindowManager.getCurrentImage();
    	if (imp_src==null){
@@ -3802,7 +3803,7 @@ private Panel panel1,
    } else if (label.equals("Select second CLT image")) {
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	//            	IJ.showMessage("DCT test 1");
    	if (!CLT_PARAMETERS.showDialog()) return;
    	if (!CLT_PARAMETERS.showJDialog()) return;
    	// process selected image stack
    	ImagePlus imp_src = WindowManager.getCurrentImage();
    	if (imp_src==null){
@@ -3837,7 +3838,7 @@ private Panel panel1,
    } else if (label.equals("CLT stack")) {
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
//    	IJ.showMessage("DCT test 1");
        if (!CLT_PARAMETERS.showDialog()) return;
        if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack
        if (DBG_IMP == null) {
        	ImagePlus imp_src = WindowManager.getCurrentImage();
@@ -3937,7 +3938,7 @@ private Panel panel1,
		System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");

//    	IJ.showMessage("DCT test 1");
        if (!CLT_PARAMETERS.showDialog()) return;
        if (!CLT_PARAMETERS.showJDialog()) return;
// process selected image stack
        if (DBG_IMP == null) {
        	ImagePlus imp_src = WindowManager.getCurrentImage();
@@ -4191,7 +4192,7 @@ private Panel panel1,
//==============================================================================

    } else if (label.equals("Create CLT kernels")) {
        if (!CLT_PARAMETERS.showDialog()) return;
        if (!CLT_PARAMETERS.showJDialog()) return;
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
        			PROPERTIES,
@@ -4250,7 +4251,7 @@ private Panel panel1,
        }

    } else if (label.equals("Read CLT kernels")) {
        if (!CLT_PARAMETERS.showDialog()) return;
        if (!CLT_PARAMETERS.showJDialog()) return;
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
        			PROPERTIES,
@@ -5161,6 +5162,9 @@ private Panel panel1,
        			PROPERTIES);
        }
        return;
    } else if (label.equals("CM Test")) {
    	cm_test();
        return;

//JTabbedTest
// End of buttons code
@@ -5185,8 +5189,137 @@ private Panel panel1,
  			return true;
  		}

  public boolean cm_test() {
	    double hsize_x = 1.5;
	    double hsize_y = 1.5;
	    int    steps =  20;
	    double sigma =   0.0;
	    boolean separable = true; // false;
	    double pwr = 1.0;
		GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",400,300);
		gd.addNumericField("Half size X",                                              hsize_x,            6, 8, "pix",
				"Correlation maximum half width in disparity direction");
		gd.addNumericField("Half size Y",                                              hsize_y,            6, 8, "pix",
				"Correlation maximum half width in orthogonal direction");
		gd.addNumericField("Number of steps",                                          steps,              0, 6, "",
				"Number of steps to subdivide [0,1) half-interval");
		gd.addNumericField("Low pass sigma",                                           sigma,              3, 6, "pix",
				"Correlation maximum half width in orthogonal direction");
		gd.addCheckbox    ("X/Y separable",                                                                 separable);
		gd.addNumericField("Value power",                                              pwr,                6, 8, "",
				"Raise values to this power before calculating CM");

		gd.showDialog();
		if (gd.wasCanceled()) return false;
		DoubleGaussianBlur gb=new DoubleGaussianBlur();

		hsize_x =              gd.getNextNumber();
		hsize_y =              gd.getNextNumber();

		steps =          (int) gd.getNextNumber();
		sigma =                gd.getNextNumber();
		separable =            gd.getNextBoolean();
		pwr =                  gd.getNextNumber();

		int size_x = 2*((int) Math.round(hsize_x+ 2*sigma+1)) + 1;
		int size_y = 2*((int) Math.round(hsize_y+ 2*sigma+1)) + 1;

		System.out.println("size_x="+size_x+", size_y="+size_y+" sigma = "+sigma+" separable "+separable+" pwr=" + pwr);
		String [] titles = new String[steps];
		double [][] data = new double [steps][size_x*size_y];
		for (int i = 0;i<steps; i++) {
			double dx = 1.0*i/steps;
			titles[i] = IJ.d2s(dx,3);
			for (int iy = 0; iy < size_y; iy++) {
				double y =  (iy - (size_y - 1)/2)/hsize_y;
				if ((y >= -1.0) && (y <= 1.0)) {
					double ay = separable ? (0.5*(Math.cos(y * Math.PI) + 1.0)):1.0;
					for (int ix = 0; ix < size_x; ix++) {

						double x = (ix - (size_x - 1)/2 - dx)/hsize_x;
						double r = separable? Math.abs(x) : Math.sqrt(x*x+y*y);
//						if ((r >= -hsize_x) && (x <= hsize_x)) {
						if (r <= 1.0) {
							double ax = 0.5*(Math.cos(r  * Math.PI) + 1.0);
							data[i][iy*size_x+ix] = ax*ay;
						}
					}
				}
			}
		}
		(new showDoubleFloatArrays()) .showArrays(data,  size_x, size_y, true, "pre-gauss", titles);
		if (sigma > 0.0) {
			for (int i = 0; i < steps; i++) {
				gb.blurDouble(
						data[i],
						size_x,
						size_y,
						sigma,
						sigma,
						0.01);
			}
			(new showDoubleFloatArrays()) .showArrays(data,  size_x, size_y, true, "blured", titles);
		}

		double [] cm_x = new double [steps];
		for (int i = 0;i<steps; i++) {
			double s0=0,sx=0;
			for (int iy = 0; iy < size_y; iy++ ) {
				for (int ix = 0; ix < size_x; ix++ ) {
					double d = Math.pow(data[i][iy*size_y+ix], pwr);
					s0+=d;
					sx+=ix*d;
				}
			}
			cm_x[i] = sx/s0 - (size_x - 1)/2;
		}
		for (int i = 0;i <= steps/2; i++) {
			double dx = 1.0*i/steps;
			System.out.println(String.format("%3d %8.5f %8.5f %8.5f %8.5f %8.5f", i, dx, cm_x[i],cm_x[i]-dx, cm_x[i]/(dx+0.00000001), dx/(cm_x[i]+0.00000001)));
		}



		return true;
/*
		double s0 = 0, sx=0,sy = 0;
		for (int y = - iradius ; y <= iradius; y++){
			int dataY = icenter[1] +y;
			if ((dataY >= 0) && (dataY < data_size)){
				int y2 = y*y;
				for (int x = - iradius ; x <= iradius; x++){
					int dataX = icenter[0] +x;
					double r2 = y2 + x * x;
//					if ((dataX >= 0) && (dataX < data_size) && (square || ((y2 + x * x) <= ir2))){
					if ((dataX >= 0) && (dataX < data_size) && (square || (r2 <= ir2))){
//						double w = max_corr_double? (1.0 - r2/ir2):1.0;
//						double d =  w* data[dataY * data_size + dataX];
						double d =  data[dataY * data_size + dataX];
						s0 += d;
						sx += d * dataX;
						sy += d * dataY;
					}
				}
			}
		}
		double [] rslt = {sx / s0, sy / s0};
 *
 * 		  showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?

			  sdfa_instance.showArrays(double_stack,  imp_src.getWidth(), imp_src.getHeight(), true, "BEFORE_CLT_PROC", rbg_titles);
 *
			        	   gb.blurDouble(
			        			   results[indexVar],
			        			   size,
			        			   size,
			        			   blurVarianceSigma,
			        			   blurVarianceSigma,
			        			   0.01);

 */

  }

  private boolean loadCorrelations(){
    	String []patterns={".corr-tiff",".tiff",".tif"};
		String path= selectFile(
+9 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
@@ -109,7 +110,13 @@ public class GenericJTabbedDialog implements ActionListener {
   		}
		if (tooltip != null) {
			label.setToolTipText(tooltip);
			if (component != null) component.setToolTipText(tooltip);
			if (component != null) {
				component.setToolTipText(tooltip);
				Component [] comps = component.getComponents();
				if ((comps != null) && (comps.length >0)) {
					((JComponent) comps[0]).setToolTipText(tooltip);
				}
			}
		}
		labels.get(labels.size()-1).add(label);
		components.get(components.size()-1).add(component);
@@ -148,6 +155,7 @@ public class GenericJTabbedDialog implements ActionListener {
		inp_units.putClientProperty("type",  "String");
		inp_units.setLayout(new FlowLayout(FlowLayout.LEFT));
		addLine(label, inp_units, tooltip);

	}

	public void addNumericField(String label, double defaultValue, int digits) { // as in IJ
+81 −9
Original line number Diff line number Diff line
@@ -67,12 +67,18 @@ public class ImageDtt {
	  static int  DISPARITY_VARIATIONS_INDEX =    11; // index of strength data in disparity map ==6
	  static int  IMG_DIFF0_INDEX =               12; // index of noise- normalized image difference for port 0 in disparity map
	  static int  OVEREXPOSED =                   16; // index of overexposed fraction of all pixels
// remove when not needed
	  static int  DBG0_INDEX =                    17; // index of dbg0 data (copy of CM)
	  static int  DBG1_INDEX =                    18; // index of dbg1 data (poly 1)
	  static int  DBG2_INDEX =                    19; // index of dbg2 data (poly 2)
	  static int  DBG3_INDEX =                    20; // index of dbg3 data (poly 3)
	  static String [] DISPARITY_TITLES = {
			  "int_disp","int_y_disp","cm_disp","cm_y_disp","hor_disp","hor_strength","vert_disp","vert_strength",
			  "poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp"};
			  "poly_disp", "poly_y_disp", "strength_disp", "vary_disp","diff0","diff1","diff2","diff3","overexp",
			  "dbg0","dbg1","dbg2","dbg3"};

	  static int  TCORR_COMBO_RSLT =  0; // normal combined correlation from all   selected pairs (mult/sum)
	  static int  TCORR_COMBO_SUM =   1; // sum of channle correlations from all   selected pairs
	  static int  TCORR_COMBO_SUM =   1; // sum of channel correlations from all   selected pairs
	  static int  TCORR_COMBO_HOR =   2; // combined correlation from 2 horizontal pairs (0,1). Used to detect vertical features
	  static int  TCORR_COMBO_VERT =  3; // combined correlation from 2 vertical   pairs (0,1). Used to detect horizontal features
	  static String [] TCORR_TITLES = {"combo","sum","hor","vert"};
@@ -1365,6 +1371,7 @@ public class ImageDtt {


	public double [][][][][][] clt_aberrations_quad_corr(
			final ImageDttParameters  imgdtt_params,   // Now just extra correlation parameters, later will include, most others
			final int                 macro_scale,     // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
			final int [][]            tile_op,         // [tilesY][tilesX] - what to do - 0 - nothing for this tile
			final double [][]         disparity_array, // [tilesY][tilesX] - individual per-tile expected disparity
@@ -1539,6 +1546,7 @@ public class ImageDtt {


		}
		// add optional initialization of debug layers here
		if (disparity_map != null){
			for (int i = 0; i<disparity_map.length;i++){
				if ((i != OVEREXPOSED) || (saturation_imp!= null)){
@@ -2138,6 +2146,11 @@ public class ImageDtt {
												clt_mismatch[3*pair + 2 ][tIndex] = Double.NaN;
											}
										}
										if (disparity_map[DBG0_INDEX] != null) disparity_map[DBG0_INDEX][tIndex] = Double.NaN;
										if (disparity_map[DBG1_INDEX] != null) disparity_map[DBG1_INDEX][tIndex] = Double.NaN;
										if (disparity_map[DBG2_INDEX] != null) disparity_map[DBG2_INDEX][tIndex] = Double.NaN;
										if (disparity_map[DBG3_INDEX] != null) disparity_map[DBG3_INDEX][tIndex] = Double.NaN;

									} else {
										double [] corr_max_XYi = {icorr_max[0],icorr_max[1]};
										disparity_map[DISPARITY_INDEX_INT][tIndex] =  transform_size - 1 -corr_max_XYi[0];
@@ -2149,7 +2162,7 @@ public class ImageDtt {
//										disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (rms[1]*tcorr_combo[1][max_index])/(rms[0]*tcorr_combo[0][max_index]); // correlation combo value at the integer maximum
										disparity_map[DISPARITY_VARIATIONS_INDEX][tIndex] = (tcorr_combo[TCORR_COMBO_SUM][max_index])/(tcorr_combo[TCORR_COMBO_RSLT][max_index]); // correlation combo value at the integer maximum
										//									Calculate "center of mass" coordinates
										double [] corr_max_XYm = getMaxXYCm( // get fractiona center as a "center of mass" inside circle/square from the integer max
										double [] corr_max_XYm = getMaxXYCm( // get fractional center as a "center of mass" inside circle/square from the integer max
												tcorr_combo[TCORR_COMBO_RSLT],      // [data_size * data_size]
												corr_size,
												icorr_max, // integer center coordinates (relative to top left)
@@ -2159,7 +2172,7 @@ public class ImageDtt {
										disparity_map[DISPARITY_INDEX_CM][tIndex] = transform_size - 1 -corr_max_XYm[0];
										disparity_map[DISPARITY_INDEX_CM+1][tIndex] = transform_size - 1 -corr_max_XYm[1];
										// returns x and strength, not x,y
										double [] corr_max_XS_hor = getMaxXSOrtho( // get fractiona center as a "center of mass" inside circle/square from the integer max
										double [] corr_max_XS_hor = getMaxXSOrtho( // get fractional center as a "center of mass" inside circle/square from the integer max
												tcorr_combo[TCORR_COMBO_HOR],      // [data_size * data_size]
												enh_ortho_scale, // [data_size]
												corr_size,
@@ -2168,7 +2181,7 @@ public class ImageDtt {
												(globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)); // debugMax);
										disparity_map[DISPARITY_INDEX_HOR][tIndex] = transform_size - 1 - corr_max_XS_hor[0];
										disparity_map[DISPARITY_INDEX_HOR_STRENGTH][tIndex] = corr_max_XS_hor[1];
										double [] corr_max_XS_vert = getMaxXSOrtho( // get fractiona center as a "center of mass" inside circle/square from the integer max
										double [] corr_max_XS_vert = getMaxXSOrtho( // get fractional center as a "center of mass" inside circle/square from the integer max
												tcorr_combo[TCORR_COMBO_VERT],      // [data_size * data_size]
												enh_ortho_scale, // [data_size]
												corr_size,
@@ -2185,7 +2198,20 @@ public class ImageDtt {
												icorr_max,                          // integer center coordinates (relative to top left)
												corr_max_weights_poly,              // [(radius+1) * (radius+1)]
												max_search_radius_poly,             // max_search_radius, for polynomial - always use 1
												imgdtt_params.poly_pwr,             // double    value_pwr, // raise value to this power (trying to compensate sticking to integer values)
												imgdtt_params.poly_value_to_weight, //boolean   poly_value_to_weight, // multiply weight by value

												debugMax);
										//double
										if (corr_max_XY != null){
											corr_max_XY[0] = transform_size - 1 -corr_max_XY[0];
											corr_max_XY[1] = transform_size - 1 -corr_max_XY[1];
										} else {
											corr_max_XY = new double[2];
											corr_max_XY[0] = Double.NaN;
											corr_max_XY[1] = Double.NaN;
										}
/*
										if (corr_max_XY != null){
											disparity_map[DISPARITY_INDEX_POLY][tIndex] = transform_size - 1 -corr_max_XY[0];
											disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = transform_size - 1 -corr_max_XY[1];
@@ -2193,6 +2219,42 @@ public class ImageDtt {
											disparity_map[DISPARITY_INDEX_POLY][tIndex] = Double.NaN;
											disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = Double.NaN;
										}
*/
										disparity_map[DISPARITY_INDEX_POLY][tIndex] =   corr_max_XY[0];
										disparity_map[DISPARITY_INDEX_POLY+1][tIndex] = corr_max_XY[1];

										// just debug (up to 4 layers)
										if (disparity_map[DBG0_INDEX] != null) {
											disparity_map[DBG0_INDEX][tIndex] = transform_size - 1 -corr_max_XYm[0];
										}
										if (disparity_map[DBG2_INDEX] != null) {
												disparity_map[DBG2_INDEX][tIndex] = corr_max_XY[0];
										}
										if (disparity_map[DBG1_INDEX] != null) {
											disparity_map[DBG1_INDEX][tIndex] = disparity_map[DBG0_INDEX][tIndex];
											if (!Double.isNaN(corr_max_XY[0]) &&
													(Math.abs(disparity_map[DISPARITY_INDEX_CM][tIndex] - corr_max_XY[0]) < imgdtt_params.max_poly_diff) &&
													(disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] > imgdtt_params.min_poly_strength)) { // debug threshold
												disparity_map[DBG1_INDEX][tIndex] = corr_max_XY[0];
												disparity_map[DBG3_INDEX][tIndex] = Double.NaN;
											} else { // show only "bad" and strong poly
												if (disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] > imgdtt_params.min_poly_strength) {
													disparity_map[DBG3_INDEX][tIndex] = disparity_map[DBG2_INDEX][tIndex];
												} else {
													disparity_map[DBG3_INDEX][tIndex] = Double.NaN;
												}
											}
//											if (disparity_map[DBG3_INDEX] != null) {
//												disparity_map[DBG3_INDEX][tIndex] = disparity_map[DBG2_INDEX][tIndex] - disparity_map[DBG0_INDEX][tIndex];
//											}
										}
										if (imgdtt_params.mix_corr_poly) {
											// apply
											disparity_map[DISPARITY_INDEX_CM][tIndex] = disparity_map[DBG1_INDEX][tIndex];
											// TODO: add Y for correction !!!!
										}

										//
										if      (corr_mode == 0) extra_disparity = disparity_map[DISPARITY_INDEX_INT][tIndex];
										else if (corr_mode == 1) extra_disparity = disparity_map[DISPARITY_INDEX_CM][tIndex];
										else if (corr_mode == 2) extra_disparity = disparity_map[DISPARITY_INDEX_POLY][tIndex];
@@ -2912,6 +2974,8 @@ public class ImageDtt {
			int []    icenter, // integer center coordinates (relative to top left)
			double [] weights,   // [(radius+1) * (radius+1)]
			int       radius,
			double    value_pwr, // raise value to this power (trying to compensate sticking to integer values)
			boolean   poly_value_to_weight, // multiply weight by value
			boolean   debug)
	{
		// TODO: make sure it is within 1pxx1px square from the integer maximum? If not - return null and use center of mass instead?
@@ -2935,8 +2999,16 @@ public class ImageDtt {
						mdata[indx][0][1] =  dataY;
						mdata[indx][1] = new double [1];
						mdata[indx][1][0] =  data[dataY * data_size + dataX];
						if (value_pwr != 1.0) {
							if (mdata[indx][1][0] > 0) {
								mdata[indx][1][0] = Math.pow(mdata[indx][1][0], value_pwr);
							} else {
								mdata[indx][1][0] = 0.0;
							}
						}
						mdata[indx][2] = new double [1];
						mdata[indx][2][0] =  weights[ay * (radius + 1) + ax];
						if (poly_value_to_weight) mdata[indx][2][0] *= mdata[indx][1][0];
						indx++;
					}
				}
Loading