Commit 96854335 authored by Andrey Filippov's avatar Andrey Filippov

Fixed very old bug that caused midding grids, especially on 48-thread Xeon

parent eaf09d11
...@@ -1070,8 +1070,8 @@ if (MORE_BUTTONS) { ...@@ -1070,8 +1070,8 @@ if (MORE_BUTTONS) {
panelIllustrations= new Panel(); panelIllustrations= new Panel();
panelIllustrations.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap panelIllustrations.setLayout(new GridLayout(1, 0, 5, 5)); // rows, columns, vgap, hgap
addButton("Illustrations Configure", panelIllustrations,color_configure); addButton("Illustrations Configure", panelIllustrations,color_configure);
addButton("Remove bad grids", panelIllustrations,color_stop);
addButton("Illustrations", panelIllustrations,color_bundle); addButton("Illustrations", panelIllustrations,color_bundle);
addButton("Remove Bad grids", panelIllustrations,color_stop);
add(panelIllustrations); add(panelIllustrations);
...@@ -9442,7 +9442,7 @@ if (MORE_BUTTONS) { ...@@ -9442,7 +9442,7 @@ if (MORE_BUTTONS) {
return; return;
} }
/* ======================================================================== */ /* ======================================================================== */
if (label.equals("Remove Bad grids")) { if (label.equals("Remove bad grids")) {
if (LENS_DISTORTIONS==null) { if (LENS_DISTORTIONS==null) {
IJ.showMessage("LENS_DISTORTION is not set"); // to use all grids imported IJ.showMessage("LENS_DISTORTION is not set"); // to use all grids imported
return; return;
...@@ -9457,6 +9457,13 @@ if (MORE_BUTTONS) { ...@@ -9457,6 +9457,13 @@ if (MORE_BUTTONS) {
SYNC_COMMAND.stopRequested, // AtomicInteger stopRequested, SYNC_COMMAND.stopRequested, // AtomicInteger stopRequested,
MASTER_DEBUG_LEVEL); // int debug_level); MASTER_DEBUG_LEVEL); // int debug_level);
} }
// TODO: add channel selection and illustration selection, stop at any
if (!CALIBRATION_ILLUSTRATION_PARAMETERS.showJDialog()) {
return;
}
if (!ABERRATIONS_PARAMETERS.selectChannelsToProcess("Select channels to process",LENS_DISTORTIONS)) {
return;
}
CALIBRATION_ILLUSTRATION.removeBadGrids(); CALIBRATION_ILLUSTRATION.removeBadGrids();
return; return;
} }
...@@ -10542,7 +10549,9 @@ if (MORE_BUTTONS) { ...@@ -10542,7 +10549,9 @@ if (MORE_BUTTONS) {
matchSimulatedPattern.debugLevel=MASTER_DEBUG_LEVEL; matchSimulatedPattern.debugLevel=MASTER_DEBUG_LEVEL;
*/ */
String [] sourceSetList = DISTORTION_PROCESS_CONFIGURATION.selectSourceSets(); String [] sourceSetList = DISTORTION_PROCESS_CONFIGURATION.selectSourceSets();
LWIR_PARAMETERS.selectSourceChannels(); if (LWIR_PARAMETERS.selectSourceChannels() == null) {
return; // canceled dialog
}
boolean [] sel_chn = LWIR_PARAMETERS.getSelected(); boolean [] sel_chn = LWIR_PARAMETERS.getSelected();
int numFiles = LWIR_PARAMETERS.getSourceFilesFlat(sourceSetList, sel_chn).length; // just the number int numFiles = LWIR_PARAMETERS.getSourceFilesFlat(sourceSetList, sel_chn).length; // just the number
String [][] sourceFilesList=LWIR_PARAMETERS.getSourceFiles(sourceSetList, sel_chn); String [][] sourceFilesList=LWIR_PARAMETERS.getSourceFiles(sourceSetList, sel_chn);
...@@ -10550,7 +10559,9 @@ if (MORE_BUTTONS) { ...@@ -10550,7 +10559,9 @@ if (MORE_BUTTONS) {
boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles; boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles;
int minGridFileSize = PATTERN_DETECT.minGridFileSize; int minGridFileSize = PATTERN_DETECT.minGridFileSize;
if (sourceSetList==null) return; if (sourceSetList==null) return;
showPatternMinMaxPeriodDialog(PATTERN_DETECT, true); if (!showPatternMinMaxPeriodDialog(PATTERN_DETECT, true)) {
return;
}
int saved_file = 0; int saved_file = 0;
int in_file = 0; int in_file = 0;
String gridDir=DISTORTION_PROCESS_CONFIGURATION.selectGridFileDirectory( String gridDir=DISTORTION_PROCESS_CONFIGURATION.selectGridFileDirectory(
...@@ -414,7 +414,7 @@ public class CalibrationIllustration { ...@@ -414,7 +414,7 @@ public class CalibrationIllustration {
} }
startAndJoin(threads); startAndJoin(threads);
} }
System.out.println("Remoded "+(numRemoved.get())+" bad grid files in "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec."); System.out.println("Removed "+(numRemoved.get())+" bad grid files in "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+" sec.");
return true; return true;
} }
......
...@@ -4092,11 +4092,12 @@ public class MatchSimulatedPattern { ...@@ -4092,11 +4092,12 @@ public class MatchSimulatedPattern {
); );
debugLevel = was_debug_level; debugLevel = was_debug_level;
if ((node != null) && (node[0] != null)) { if ((node != null) && (node[0] != null)) {
nodeQueue.add(new GridNode(node)); nodeQueue.add(new GridNode(startScanIndex,node));
break; break;
} }
} else {
triedIndices[startScanIndex] = true; // only mark failed here, good ones will be marked when used
} }
triedIndices[startScanIndex] = true;
} }
} else { // new multithreaded mode } else { // new multithreaded mode
int startScanIndex = 3; int startScanIndex = 3;
...@@ -4205,11 +4206,18 @@ public class MatchSimulatedPattern { ...@@ -4205,11 +4206,18 @@ public class MatchSimulatedPattern {
} }
} }
double[][] node = { null }; double[][] node = { null };
nodeQueue.add(new GridNode(node)); // will not be used, any element nodeQueue.add(new GridNode(-1,node)); // will not be used, any element
} }
int numDefinedCells = 0; int numDefinedCells = 0;
int debug_left = nodeQueue.size(); int debug_left = nodeQueue.size();
for (GridNode gn : nodeQueue) { // trying candidates as grid seeds - until found or nothing left for (GridNode gn : nodeQueue) { // trying candidates as grid seeds - until found or nothing left
// Only here mark triedIndices !!
if (gn.triedIndex >= 0) {
triedIndices[gn.triedIndex] = true; // mark the used seed
} else {
System.out.println("Was updating, gn.triedIndex(not used)="+gn.triedIndex);
}
debug_left--; debug_left--;
if (global_debug_level > (debugThreshold + 1)) { if (global_debug_level > (debugThreshold + 1)) {
System.out.println( System.out.println(
...@@ -4684,6 +4692,9 @@ public class MatchSimulatedPattern { ...@@ -4684,6 +4692,9 @@ public class MatchSimulatedPattern {
} }
} // while (waveFrontList.size()>0) } // while (waveFrontList.size()>0)
debugLevel = was_debug_level; debugLevel = was_debug_level;
/* /*
* if (updating){ return PATTERN_GRID; // no need to crop the array, it should * if (updating){ return PATTERN_GRID; // no need to crop the array, it should
* not change } * not change }
...@@ -4805,6 +4816,7 @@ public class MatchSimulatedPattern { ...@@ -4805,6 +4816,7 @@ public class MatchSimulatedPattern {
} }
// return numDefinedCells; // return numDefinedCells;
} }
if ((roi != null) && !(roi instanceof PointRoi)) { // don't use this feature with ROI as it can be small if ((roi != null) && !(roi instanceof PointRoi)) { // don't use this feature with ROI as it can be small
if (global_debug_level > 0) if (global_debug_level > 0)
...@@ -4814,6 +4826,8 @@ public class MatchSimulatedPattern { ...@@ -4814,6 +4826,8 @@ public class MatchSimulatedPattern {
return numDefinedCells; return numDefinedCells;
} }
} }
} // next node in queue } // next node in queue
return 0; // none return 0; // none
} }
...@@ -4938,9 +4952,12 @@ public class MatchSimulatedPattern { ...@@ -4938,9 +4952,12 @@ public class MatchSimulatedPattern {
} }
class GridNode { class GridNode {
int triedIndex; // index in the list of tried points
double[][] node; double[][] node;
public GridNode(
public GridNode(double[][] node) { int triedIndex,
double[][] node) {
this.triedIndex = triedIndex;
this.node = node; this.node = node;
} }
...@@ -5061,18 +5078,20 @@ public class MatchSimulatedPattern { ...@@ -5061,18 +5078,20 @@ public class MatchSimulatedPattern {
+ nb + " " + point[0] + "/" + point[1]) + nb + " " + point[0] + "/" + point[1])
: null); : null);
if ((node != null) && (node[0] != null)) { if ((node != null) && (node[0] != null)) {
nodeQueue.add(new GridNode(node)); nodeQueue.add(new GridNode(n, node)); // save tried index for later, will be marked only when used (fixing a very old bug)
if (debugLevel > debugThreshold - 1) if (debugLevel > debugThreshold - 1)
System.out.println("adding candidate " + n + " x0=" + point[0] + " y0=" System.out.println("adding candidate " + n + " x0=" + point[0] + " y0="
+ point[1] + " -> " + node[0][0] + "/" + node[0][1] + point[1] + " -> " + node[0][0] + "/" + node[0][1]
+ " seqNumber.get()=" + seqNumber.get() + " n=" + n); + " seqNumber.get()=" + seqNumber.get() + " n=" + n);
continue; // so triedIndices[n] will not be set true
} }
} else { } else {
if (debugLevel > debugThreshold) if (debugLevel > debugThreshold)
System.out System.out
.println("-----" + debugNumThread + ":" + n + ", nv=" + nv + ", nh=" + nh); .println("-----" + debugNumThread + ":" + n + ", nv=" + nv + ", nh=" + nh);
} }
triedIndices[n] = true; // regardless - good or bad // triedIndices[n] = true; // regardless - good or bad - that was wrong, and led to skipping retries of good (but not first) nodes
triedIndices[n] = true; // will come here only for failed nodes.
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment