Commit 0c001dd2 authored by Andrey Filippov's avatar Andrey Filippov

more grids filtering

parent 9c63f90b
...@@ -10352,6 +10352,7 @@ if (MORE_BUTTONS) { ...@@ -10352,6 +10352,7 @@ if (MORE_BUTTONS) {
String [][] sourceFilesList=LWIR_PARAMETERS.getSourceFiles(sourceSetList, sel_chn); String [][] sourceFilesList=LWIR_PARAMETERS.getSourceFiles(sourceSetList, sel_chn);
boolean saveGrids=DISTORTION_PROCESS_CONFIGURATION.saveGridImages; boolean saveGrids=DISTORTION_PROCESS_CONFIGURATION.saveGridImages;
boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles; boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles;
int minGridFileSize = PATTERN_DETECT.minGridFileSize;
if (sourceSetList==null) return; if (sourceSetList==null) return;
showPatternMinMaxPeriodDialog(PATTERN_DETECT, true); showPatternMinMaxPeriodDialog(PATTERN_DETECT, true);
int saved_file = 0; int saved_file = 0;
...@@ -10372,7 +10373,8 @@ if (MORE_BUTTONS) { ...@@ -10372,7 +10373,8 @@ if (MORE_BUTTONS) {
if (!set_dir.exists()) { if (!set_dir.exists()) {
set_dir.mkdirs(); // including parent set_dir.mkdirs(); // including parent
} }
} }
for (int nfile = 0; nfile < sourceFilesList[nset].length; nfile++) if (sourceFilesList[nset][nfile] != null){ for (int nfile = 0; nfile < sourceFilesList[nset].length; nfile++) if (sourceFilesList[nset][nfile] != null){
in_file++; in_file++;
...@@ -10384,7 +10386,7 @@ if (MORE_BUTTONS) { ...@@ -10384,7 +10386,7 @@ if (MORE_BUTTONS) {
} }
String grid_path = null; String grid_path = null;
/* /*
if (saveGrids && !overwriteGrids){ // check if result already exists if (saveGrids && !ovminGridFileSizeerwriteGrids){ // check if result already exists
i = sourceFilesList[nset][nfile].lastIndexOf('/'); i = sourceFilesList[nset][nfile].lastIndexOf('/');
if (i>0){ if (i>0){
String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1); String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1);
...@@ -10395,6 +10397,7 @@ if (MORE_BUTTONS) { ...@@ -10395,6 +10397,7 @@ if (MORE_BUTTONS) {
} }
} }
} }
patternDetectParameters.minGridFileSize
*/ */
if (saveGrids){ // check if result already exists if (saveGrids){ // check if result already exists
...@@ -10402,10 +10405,23 @@ if (MORE_BUTTONS) { ...@@ -10402,10 +10405,23 @@ if (MORE_BUTTONS) {
if (i>0){ if (i>0){
String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1); String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1);
grid_path = gridSetPath + Prefs.getFileSeparator() + grid_name; grid_path = gridSetPath + Prefs.getFileSeparator() + grid_name;
if (!overwriteGrids && ((new File(grid_path)).exists())){ // check if result already exists File grid_file = new File(grid_path);
if (DEBUG_LEVEL>0) System.out.println("-->>> Skipping existing "+grid_path+" (as requested in \"Configure Process Distortions\")"); if (!overwriteGrids && (grid_file.exists())){ // check if result already exists
continue; if (grid_file.length() >= minGridFileSize) {
} if (DEBUG_LEVEL>0) {
System.out.println("-->>> Skipping existing large enough ("+(grid_file.length())+
" bytes >= "+minGridFileSize+" bytes)"+grid_path+" (as requested in \"Configure Process Distortions\")");
}
continue;
} else {
if (DEBUG_LEVEL>0) {
System.out.println("-->>> Deleting small ("+(grid_file.length())+
" bytes < "+minGridFileSize+" bytes)"+grid_path+" (as requested in \"Configure Process Distortions\")");
grid_file.delete();
}
}
}
} }
} }
imp_sel=new ImagePlus(sourceFilesList[nset][nfile]); // read source file imp_sel=new ImagePlus(sourceFilesList[nset][nfile]); // read source file
...@@ -10436,7 +10452,10 @@ if (MORE_BUTTONS) { ...@@ -10436,7 +10452,10 @@ if (MORE_BUTTONS) {
noMessageBoxes); noMessageBoxes);
if (DEBUG_LEVEL>1) System.out.println("numAbsolutePoints="+numAbsolutePoints); if (DEBUG_LEVEL>1) System.out.println("numAbsolutePoints="+numAbsolutePoints);
if ((numAbsolutePoints==DISTORTION.errPatternNotFound) || (numAbsolutePoints==DISTORTION.errTooFewCells)) { if ((numAbsolutePoints==DISTORTION.errPatternNotFound) ||
(numAbsolutePoints==DISTORTION.errTooFewCells) ||
(numAbsolutePoints==DISTORTION.errRefineFailed)
) {
if (DEBUG_LEVEL>0) System.out.println("Grid "+(in_file)+" not found or too small ("+numAbsolutePoints+"), wasted "+ if (DEBUG_LEVEL>0) System.out.println("Grid "+(in_file)+" not found or too small ("+numAbsolutePoints+"), wasted "+
IJ.d2s(0.000000001*(System.nanoTime()-startFileTime),3)+" seconds )\n"); IJ.d2s(0.000000001*(System.nanoTime()-startFileTime),3)+" seconds )\n");
if (this.SYNC_COMMAND.stopRequested.get()>0) { if (this.SYNC_COMMAND.stopRequested.get()>0) {
...@@ -20990,6 +21009,9 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica ...@@ -20990,6 +21009,9 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica
gd.addNumericField("Minimal pattern grid period for LWIR sensors (<=0.0 - do not check)" , patternDetectParameters.minGridPeriodLwir, 2,5,"pix"); gd.addNumericField("Minimal pattern grid period for LWIR sensors (<=0.0 - do not check)" , patternDetectParameters.minGridPeriodLwir, 2,5,"pix");
gd.addNumericField("Maximal pattern grid period for LWIR sensors (<=0.0 - do not check)" , patternDetectParameters.maxGridPeriodLwir, 2,5,"pix"); gd.addNumericField("Maximal pattern grid period for LWIR sensors (<=0.0 - do not check)" , patternDetectParameters.maxGridPeriodLwir, 2,5,"pix");
} }
gd.addNumericField("Minimal grid file size to overwrite" , patternDetectParameters.minGridFileSize, 0, 8, "bytes");
// public double minGridFileSize = 25000; // Minimal file size (to overwirite)
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return false; if (gd.wasCanceled()) return false;
patternDetectParameters.minGridPeriod= gd.getNextNumber(); patternDetectParameters.minGridPeriod= gd.getNextNumber();
...@@ -20998,6 +21020,7 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica ...@@ -20998,6 +21020,7 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica
patternDetectParameters.minGridPeriodLwir= gd.getNextNumber(); patternDetectParameters.minGridPeriodLwir= gd.getNextNumber();
patternDetectParameters.maxGridPeriodLwir= gd.getNextNumber(); patternDetectParameters.maxGridPeriodLwir= gd.getNextNumber();
} }
patternDetectParameters.minGridFileSize = (int) gd.getNextNumber();
return true; return true;
} }
...@@ -4372,11 +4372,13 @@ public class MatchSimulatedPattern { ...@@ -4372,11 +4372,13 @@ public class MatchSimulatedPattern {
continue; continue;
} else if ((refCell[0] != null) && (refCell[0].length > 3)) { } else if ((refCell[0] != null) && (refCell[0].length > 3)) {
double dbg_contrast = (refCell[0].length > 2) ? refCell[0][2] : Double.NaN; double dbg_contrast = (refCell[0].length > 2) ? refCell[0][2] : Double.NaN;
System.out.println("**** refCell was deleted **** u=" + iUVRef[0] + " v=" if (debugLevel > debugThreshold) {
+ iUVRef[1] + " current=" + iUVdir[0] + "/" + iUVdir[1] + " ncell=" + ncell System.out.println("**** refCell was deleted **** u=" + iUVRef[0] + " v="
+ " waveFrontList.size()=" + waveFrontList.size() + " ref_x=" + iUVRef[1] + " current=" + iUVdir[0] + "/" + iUVdir[1] + " ncell=" + ncell
+ IJ.d2s(refCell[0][0], 3) + " ref_y=" + IJ.d2s(refCell[0][1], 3) + " waveFrontList.size()=" + waveFrontList.size() + " ref_x="
+ " contrast=" + IJ.d2s(dbg_contrast, 3)); + IJ.d2s(refCell[0][0], 3) + " ref_y=" + IJ.d2s(refCell[0][1], 3)
+ " contrast=" + IJ.d2s(dbg_contrast, 3));
}
} }
// found reference cell, calculate x/y, make sure it is inside the selection w/o // found reference cell, calculate x/y, make sure it is inside the selection w/o
// borders // borders
...@@ -6855,7 +6857,7 @@ public class MatchSimulatedPattern { ...@@ -6855,7 +6857,7 @@ public class MatchSimulatedPattern {
IJ.showMessage("Error", "Pattern not found"); IJ.showMessage("Error", "Pattern not found");
return distortionParameters.errPatternNotFound; return distortionParameters.errPatternNotFound;
} else { } else {
if (global_debug_level > (debugThreshold + 1)) if (global_debug_level > 0) // (debugThreshold + 1))
System.out.println("Initial pattern cluster has " + patternCells + " cells"); System.out.println("Initial pattern cluster has " + patternCells + " cells");
} }
if (global_debug_level > (debugThreshold + 1)) if (global_debug_level > (debugThreshold + 1))
...@@ -6878,7 +6880,7 @@ public class MatchSimulatedPattern { ...@@ -6878,7 +6880,7 @@ public class MatchSimulatedPattern {
imp_eq = imp; imp_eq = imp;
if (distortionParameters.refineCorrelations) { if (distortionParameters.refineCorrelations) {
refineDistortionCorrelation( double maxActualCorr = refineDistortionCorrelation(
lwirReaderParameters, // LwirReaderParameters lwirReaderParameters, // null is OK lwirReaderParameters, // LwirReaderParameters lwirReaderParameters, // null is OK
distortionParameters, // distortionParameters, //
patternDetectParameters, patternDetectParameters,
...@@ -6889,7 +6891,10 @@ public class MatchSimulatedPattern { ...@@ -6889,7 +6891,10 @@ public class MatchSimulatedPattern {
threadsMax, threadsMax,
updateStatus, updateStatus,
debug_level); // debug level debug_level); // debug level
System.out.println(".... maxActualCorr="+maxActualCorr);
if (maxActualCorr <= 0.0) {
return distortionParameters.errRefineFailed; // 2021
}
recalculateWaveVectors( recalculateWaveVectors(
updateStatus, updateStatus,
debug_level);// debug level used inside loops debug_level);// debug level used inside loops
...@@ -10560,6 +10565,7 @@ public class MatchSimulatedPattern { ...@@ -10560,6 +10565,7 @@ public class MatchSimulatedPattern {
} }
contrast = contrasts[0]; contrast = contrasts[0];
result[2] = contrast; result[2] = contrast;
// System.out.println("cobntrasts = "+contrasts[0]+", "+contrasts[1]);
if (Double.isNaN(contrasts[0]) || ((distortionParameters.correlationMinContrast > 0) if (Double.isNaN(contrasts[0]) || ((distortionParameters.correlationMinContrast > 0)
&& (contrasts[0] < distortionParameters.correlationMinContrast))) { && (contrasts[0] < distortionParameters.correlationMinContrast))) {
if ((debug_level > (debug_threshold - 1))) if ((debug_level > (debug_threshold - 1)))
...@@ -12400,6 +12406,7 @@ public class MatchSimulatedPattern { ...@@ -12400,6 +12406,7 @@ public class MatchSimulatedPattern {
public double minGridPeriod; public double minGridPeriod;
public double maxGridPeriod; public double maxGridPeriod;
public double minGridPeriodLwir; public double minGridPeriodLwir;
public int minGridFileSize = 15000; // Minimal file size (to overwrite)
public double maxGridPeriodLwir; public double maxGridPeriodLwir;
public double debugX; public double debugX;
public double debugY; public double debugY;
...@@ -12623,8 +12630,10 @@ public class MatchSimulatedPattern { ...@@ -12623,8 +12630,10 @@ public class MatchSimulatedPattern {
// the grig brightness // the grig brightness
// match pointers errors // match pointers errors
public int errTooFewCells = -10; public int errTooFewCells = -10;
public int errPatternNotFound = -11; public int errPatternNotFound = -11;
public int errRefineFailed = -12;
public boolean legacyMode = false; // legacy mode public boolean legacyMode = false; // legacy mode
......
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