Commit 24b642b0 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Updating batch mode of the 3d scene processing

parent 91409a1a
Loading
Loading
Loading
Loading
+31 −31
Original line number Original line Diff line number Diff line
@@ -25,12 +25,12 @@
**
**
*/
*/


import ij.ImageStack;
import ij.gui.GenericDialog;

import java.util.Properties;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicInteger;


import ij.ImageStack;
import ij.gui.GenericDialog;



public class CorrectionColorProc {
public class CorrectionColorProc {
	showDoubleFloatArrays SDFA_INSTANCE=   new showDoubleFloatArrays();
	showDoubleFloatArrays SDFA_INSTANCE=   new showDoubleFloatArrays();
@@ -241,7 +241,7 @@ public class CorrectionColorProc {
    		//TODO: null DENOISE_MASK if it is not calculated
    		//TODO: null DENOISE_MASK if it is not calculated
    		if (colorProcParameters.combineWithSharpnessMask) {
    		if (colorProcParameters.combineWithSharpnessMask) {
    			if (denoiseMask==null) {
    			if (denoiseMask==null) {
    				System.out.println ( "Can not combine masks as denoiseMask is null (i.e. no denoise was performed)");
    				System.out.println ( "Can not combine masks as denoiseMask is null (i.e. no denoise was performed)"); // here
    			} else if (denoiseMask.length!=dmask.length) {
    			} else if (denoiseMask.length!=dmask.length) {
    				System.out.println ( "Can not combine masks as denoiseMask length is different from that of dmask");
    				System.out.println ( "Can not combine masks as denoiseMask length is different from that of dmask");
    			} else {
    			} else {
+3 −0
Original line number Original line Diff line number Diff line
@@ -3004,6 +3004,9 @@ public class EyesisCorrectionParameters {
  		public HashMap<String,Double> z_corr_map = new HashMap<String,Double>();
  		public HashMap<String,Double> z_corr_map = new HashMap<String,Double>();
  		public static String Z_CORR_PREFIX = "z_corr.";
  		public static String Z_CORR_PREFIX = "z_corr.";


  		public boolean   batch_run =               false; // turned on only while running in batch mode




  		public CLTParameters(){}
  		public CLTParameters(){}
  		public void setProperties(String prefix,Properties properties){
  		public void setProperties(String prefix,Properties properties){
+111 −107
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@
import java.util.Properties;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicInteger;



import ij.CompositeImage;
import ij.CompositeImage;
import ij.IJ;
import ij.IJ;
import ij.ImagePlus;
import ij.ImagePlus;
@@ -150,6 +149,7 @@ public class EyesisDCT {
		  System.out.println("calculateDCTKernel():numberOfKernels="+numberOfKernels);
		  System.out.println("calculateDCTKernel():numberOfKernels="+numberOfKernels);
		  for (int ithread = 0; ithread < threads.length; ithread++) {
		  for (int ithread = 0; ithread < threads.length; ithread++) {
			  threads[ithread] = new Thread() {
			  threads[ithread] = new Thread() {
				  @Override
				public void run() {
				public void run() {
					  DoubleGaussianBlur gb=null;
					  DoubleGaussianBlur gb=null;
					  if (dct_parameters.decimateSigma > 0)	 gb=new DoubleGaussianBlur();
					  if (dct_parameters.decimateSigma > 0)	 gb=new DoubleGaussianBlur();
@@ -1439,7 +1439,9 @@ public class EyesisDCT {
		  }
		  }


		  if (toRGB) {
		  if (toRGB) {
			  if (debugLevel > 0){
				  System.out.println("correctionColorProc.YPrPbToRGB");
				  System.out.println("correctionColorProc.YPrPbToRGB");
			  }
			  stack =  YPrPbToRGB(yPrPb,
			  stack =  YPrPbToRGB(yPrPb,
					  colorProcParameters.kr,        // 0.299;
					  colorProcParameters.kr,        // 0.299;
					  colorProcParameters.kb,        // 0.114;
					  colorProcParameters.kb,        // 0.114;
@@ -1636,6 +1638,7 @@ public class EyesisDCT {


		  for (int ithread = 0; ithread < threads.length; ithread++) {
		  for (int ithread = 0; ithread < threads.length; ithread++) {
			  threads[ithread] = new Thread() {
			  threads[ithread] = new Thread() {
				  @Override
				public void run() {
				public void run() {
					  int tileY,tileX;
					  int tileY,tileX;
					  double [] neibs =   new double[9]; // pixels around current, first Y, then each color diff
					  double [] neibs =   new double[9]; // pixels around current, first Y, then each color diff
@@ -1749,6 +1752,7 @@ public class EyesisDCT {


		  for (int ithread = 0; ithread < threads.length; ithread++) {
		  for (int ithread = 0; ithread < threads.length; ithread++) {
			  threads[ithread] = new Thread() {
			  threads[ithread] = new Thread() {
				  @Override
				public void run() {
				public void run() {
					  int tileY,tileX;
					  int tileY,tileX;
					  double [] neibs =   new double[9]; // pixels around current, first Y, then each color diff
					  double [] neibs =   new double[9]; // pixels around current, first Y, then each color diff
+2 −12
Original line number Original line Diff line number Diff line
@@ -776,7 +776,7 @@ private Panel panel1,
	Runtime runtime = Runtime.getRuntime();
	Runtime runtime = Runtime.getRuntime();
    runtime.gc();
    runtime.gc();
	if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
	if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");

	CLT_PARAMETERS.batch_run = false;
    if (label==null) return;
    if (label==null) return;
/* ======================================================================== */
/* ======================================================================== */
    if (label.equals("Configure spilt")) {
    if (label.equals("Configure spilt")) {
@@ -5051,7 +5051,6 @@ private Panel panel1,
        		RGB_PARAMETERS,  // EyesisCorrectionParameters.RGBParameters             rgbParameters,
        		RGB_PARAMETERS,  // EyesisCorrectionParameters.RGBParameters             rgbParameters,
        		THREADS_MAX,     // final int          threadsMax,  // maximal number of threads to launch
        		THREADS_MAX,     // final int          threadsMax,  // maximal number of threads to launch
        		UPDATE_STATUS,   // final boolean    updateStatus,
        		UPDATE_STATUS,   // final boolean    updateStatus,
        		false,           // final boolean    batch_mode,
        		DEBUG_LEVEL); //final int        debugLevel);
        		DEBUG_LEVEL); //final int        debugLevel);
        if (!OK) {
        if (!OK) {
        	String msg="Image data not initialized, run 'CLT 3D' command first";
        	String msg="Image data not initialized, run 'CLT 3D' command first";
@@ -5059,18 +5058,9 @@ private Panel panel1,
        	IJ.showMessage("Error",msg);
        	IJ.showMessage("Error",msg);
        }
        }


/*
        if (configPath!=null) {
        	saveTimestampedProperties( // save config again
        			configPath,      // full path or null
        			null, // use as default directory if path==null
        			true,
        			PROPERTIES);
        }

*/
    } else if (label.equals("CLT batch process")) {
    } else if (label.equals("CLT batch process")) {
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
    	DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
        CLT_PARAMETERS.batch_run = true;
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
    	EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
        if (QUAD_CLT == null){
        if (QUAD_CLT == null){
        	QUAD_CLT = new  QuadCLT (
        	QUAD_CLT = new  QuadCLT (
+464 −429
Original line number Original line Diff line number Diff line
@@ -188,7 +188,7 @@ public class LinkPlanes {
  		plPrecision =       clt_parameters.plPrecision;
  		plPrecision =       clt_parameters.plPrecision;
  		plNormPow =         clt_parameters.plNormPow;
  		plNormPow =         clt_parameters.plNormPow;


		dbg_tileX =         clt_parameters.tileX;
		dbg_tileX =         clt_parameters.batch_run?-1:clt_parameters.tileX;
		dbg_tileY =         clt_parameters.tileY;
		dbg_tileY =         clt_parameters.tileY;
		this.st =           st;
		this.st =           st;
	}
	}
@@ -862,6 +862,7 @@ public class LinkPlanes {
		// Select best symmetrical match, consider only N, NE, E, SE - later opposite ones will be copied
		// Select best symmetrical match, consider only N, NE, E, SE - later opposite ones will be copied
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
//					TilePlanes.PlaneData [] dbg_planes = null;
//					TilePlanes.PlaneData [] dbg_planes = null;
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
@@ -960,6 +961,7 @@ public class LinkPlanes {
		ai.set(0);
		ai.set(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
//					TilePlanes.PlaneData [][] dbg_planes = planes;
//					TilePlanes.PlaneData [][] dbg_planes = planes;
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
@@ -1056,6 +1058,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
//						int dl = ((debugLevel > -1) && (nsTile0 == debug_stile)) ? 1:0;
//						int dl = ((debugLevel > -1) && (nsTile0 == debug_stile)) ? 1:0;
@@ -1159,6 +1162,7 @@ public class LinkPlanes {
		// Reset neighbors
		// Reset neighbors
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
						if ( planes[nsTile0] != null) {
						if ( planes[nsTile0] != null) {
@@ -1187,6 +1191,7 @@ public class LinkPlanes {
			boolean hasConflict(LinkPair lp){
			boolean hasConflict(LinkPair lp){
				return (src == lp.src) || (dst == lp.dst);
				return (src == lp.src) || (dst == lp.dst);
			}
			}
			@Override
			public String toString(){
			public String toString(){
				return String.format("%d-(%6.3f)->%d", src,cost,dst);
				return String.format("%d-(%6.3f)->%d", src,cost,dst);
			}
			}
@@ -1194,6 +1199,7 @@ public class LinkPlanes {
		}
		}
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
//						int dl = ((debugLevel > -1) && (nsTile0 == debug_stile)) ? 1:0;
//						int dl = ((debugLevel > -1) && (nsTile0 == debug_stile)) ? 1:0;
@@ -1298,6 +1304,7 @@ public class LinkPlanes {


		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
//					TilePlanes.PlaneData [][] dbg_planes = planes;
//					TilePlanes.PlaneData [][] dbg_planes = planes;
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
@@ -1412,6 +1419,7 @@ public class LinkPlanes {


		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
//					TilePlanes.PlaneData [][] dbg_planes = planes;
//					TilePlanes.PlaneData [][] dbg_planes = planes;
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
@@ -1666,6 +1674,7 @@ public class LinkPlanes {


		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) {
						if ( planes[nsTile0] != null) {
						if ( planes[nsTile0] != null) {
@@ -1684,6 +1693,7 @@ public class LinkPlanes {
		ai.set(0);
		ai.set(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
					int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
					double [][] quality_stats = all_quality_stats[numThread];
					double [][] quality_stats = all_quality_stats[numThread];
@@ -1911,6 +1921,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( planes[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( planes[nsTile] != null) {
						ArrayList<LayersLinks> links_list = new ArrayList<LayersLinks>();
						ArrayList<LayersLinks> links_list = new ArrayList<LayersLinks>();
@@ -2002,6 +2013,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
//						merge_pairs[nsTile] = new boolean [merge_candidates[nsTile].length];
//						merge_pairs[nsTile] = new boolean [merge_candidates[nsTile].length];
@@ -2130,6 +2142,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
						int dl = ((debugLevel > 0) && (nsTile == debug_stile)) ? 2: ((debugLevel > 1) ? 1:0);
						int dl = ((debugLevel > 0) && (nsTile == debug_stile)) ? 2: ((debugLevel > 1) ? 1:0);
@@ -2305,6 +2318,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
						int sty0 = nsTile0 / stilesX;
						int sty0 = nsTile0 / stilesX;
@@ -2461,6 +2475,7 @@ public class LinkPlanes {
		final boolean [][] weak_fgnd = new boolean [valid_candidates.length][];
		final boolean [][] weak_fgnd = new boolean [valid_candidates.length][];
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
                        int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
                        int dl = ((debugLevel > 1) && (nsTile == debug_stile)) ? 3: debugLevel;
@@ -2528,6 +2543,9 @@ public class LinkPlanes {
			final int                       dbg_X,
			final int                       dbg_X,
			final int                       dbg_Y)
			final int                       dbg_Y)
	{
	{
		if (debugLevel > 0) {
			System.out.println("Debug debugLevel");
		}
		final int tilesX =        st.tileProcessor.getTilesX();
		final int tilesX =        st.tileProcessor.getTilesX();
		final int tilesY =        st.tileProcessor.getTilesY();
		final int tilesY =        st.tileProcessor.getTilesY();
		final int superTileSize = st.tileProcessor.getSuperTileSize();
		final int superTileSize = st.tileProcessor.getSuperTileSize();
@@ -2541,6 +2559,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
//						int dl = ((debugLevel > 0) && (nsTile0 == debug_stile)) ? 3: ((debugLevel > 1) ? 2:0);
//						int dl = ((debugLevel > 0) && (nsTile0 == debug_stile)) ? 3: ((debugLevel > 1) ? 2:0);
@@ -2731,6 +2750,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) {
						if ((merge_candidates[nsTile] != null) && (conflicts[nsTile] != null)) {
						if ((merge_candidates[nsTile] != null) && (conflicts[nsTile] != null)) {
@@ -2829,6 +2849,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
//						int dl = ((debugLevel > 0) && (nsTile0 == debug_stile)) ? 3: ((debugLevel > 1) ? 2:0);
//						int dl = ((debugLevel > 0) && (nsTile0 == debug_stile)) ? 3: ((debugLevel > 1) ? 2:0);
@@ -3055,6 +3076,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
					for (int nsTile0 = ai.getAndIncrement(); nsTile0 < nStiles; nsTile0 = ai.getAndIncrement()) if ( merge_candidates[nsTile0] != null) {
						int sty0 = nsTile0 / stilesX;
						int sty0 = nsTile0 / stilesX;
@@ -3271,6 +3293,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
						merge_pairs[nsTile] = new boolean [merge_candidates[nsTile].length];
						merge_pairs[nsTile] = new boolean [merge_candidates[nsTile].length];
@@ -3350,6 +3373,7 @@ public class LinkPlanes {
// TODO Make nooverlaps be overriden if ne of the planes is very weak and they are close by disparity
// TODO Make nooverlaps be overriden if ne of the planes is very weak and they are close by disparity
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
					for (int nsTile = ai.getAndIncrement(); nsTile < nStiles; nsTile = ai.getAndIncrement()) if ( merge_candidates[nsTile] != null) {
						if (planes[nsTile] == null){
						if (planes[nsTile] == null){
@@ -3680,6 +3704,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					ConnectionCosts connectionCosts = new ConnectionCosts(
					ConnectionCosts connectionCosts = new ConnectionCosts(
							orthoWeight,    // double         orthoWeight,
							orthoWeight,    // double         orthoWeight,
@@ -3738,6 +3763,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					ConnectionCosts connectionCosts = new ConnectionCosts(
					ConnectionCosts connectionCosts = new ConnectionCosts(
							orthoWeight,    // double         orthoWeight,
							orthoWeight,    // double         orthoWeight,
@@ -3970,6 +3996,7 @@ public class LinkPlanes {
		final AtomicInteger ai = new AtomicInteger(0);
		final AtomicInteger ai = new AtomicInteger(0);
		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					for (int nsTile = ai.getAndIncrement(); nsTile < src_planes.length; nsTile = ai.getAndIncrement()) {
					for (int nsTile = ai.getAndIncrement(); nsTile < src_planes.length; nsTile = ai.getAndIncrement()) {
						if (src_planes[nsTile] != null){
						if (src_planes[nsTile] != null){
@@ -4059,6 +4086,7 @@ public class LinkPlanes {


		for (int ithread = 0; ithread < threads.length; ithread++) {
		for (int ithread = 0; ithread < threads.length; ithread++) {
			threads[ithread] = new Thread() {
			threads[ithread] = new Thread() {
				@Override
				public void run() {
				public void run() {
					double [][] dbg_img=null;
					double [][] dbg_img=null;
					int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
					int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
@@ -4660,6 +4688,9 @@ public class LinkPlanes {
		final TileNeibs tnSurface = new TileNeibs(stilesX, stilesY);
		final TileNeibs tnSurface = new TileNeibs(stilesX, stilesY);
		final int debug_stile = dbg_Y * stilesX + dbg_X;
		final int debug_stile = dbg_Y * stilesX + dbg_X;
//		final int nStiles =       stilesX * stilesY;
//		final int nStiles =       stilesX * stilesY;
		if (debugLevel >-1) {
			System.out.println("fillSquares(): Debug debugLevel");
		}
		int num_added = 0;
		int num_added = 0;
		for (int stY = 0; stY < (stilesY - 1); stY++ ) {
		for (int stY = 0; stY < (stilesY - 1); stY++ ) {
			for (int stX = 0; stX < (stilesX - 1); stX++ ) {
			for (int stX = 0; stX < (stilesX - 1); stX++ ) {
@@ -4732,6 +4763,10 @@ public class LinkPlanes {
		final int stilesY =       (tilesY + superTileSize -1)/superTileSize;
		final int stilesY =       (tilesY + superTileSize -1)/superTileSize;
		final TileNeibs tnSurface = new TileNeibs(stilesX, stilesY);
		final TileNeibs tnSurface = new TileNeibs(stilesX, stilesY);
		final int debug_stile = dbg_Y * stilesX + dbg_X;
		final int debug_stile = dbg_Y * stilesX + dbg_X;
		if (debugLevel >-1) {
			System.out.println("fillHypotenuse(): Debug debugLevel");
		}

//		final int nStiles =       stilesX * stilesY;
//		final int nStiles =       stilesX * stilesY;
		int num_added = 0;
		int num_added = 0;
		for (int stY = 0; stY < (stilesY - 1); stY++ ) {
		for (int stY = 0; stY < (stilesY - 1); stY++ ) {
Loading