Commit 65338490 authored by Andrey Filippov's avatar Andrey Filippov

Merge branch 'lwir-distort' of git.elphel.com:Elphel/imagej-elphel into lwir-distort

parents 3fd21c81 0c001dd2
......@@ -10465,6 +10465,7 @@ if (MORE_BUTTONS) {
String [][] sourceFilesList=LWIR_PARAMETERS.getSourceFiles(sourceSetList, sel_chn);
boolean saveGrids=DISTORTION_PROCESS_CONFIGURATION.saveGridImages;
boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles;
int minGridFileSize = PATTERN_DETECT.minGridFileSize;
if (sourceSetList==null) return;
showPatternMinMaxPeriodDialog(PATTERN_DETECT, true);
int saved_file = 0;
......@@ -10487,6 +10488,7 @@ if (MORE_BUTTONS) {
}
}
for (int nfile = 0; nfile < sourceFilesList[nset].length; nfile++) if (sourceFilesList[nset][nfile] != null){
in_file++;
long startFileTime=System.nanoTime();
......@@ -10497,7 +10499,7 @@ if (MORE_BUTTONS) {
}
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('/');
if (i>0){
String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1);
......@@ -10508,6 +10510,7 @@ if (MORE_BUTTONS) {
}
}
}
patternDetectParameters.minGridFileSize
*/
if (saveGrids){ // check if result already exists
......@@ -10515,9 +10518,22 @@ if (MORE_BUTTONS) {
if (i>0){
String grid_name = prefix+sourceFilesList[nset][nfile].substring(i+1);
grid_path = gridSetPath + Prefs.getFileSeparator() + grid_name;
if (!overwriteGrids && ((new File(grid_path)).exists())){ // check if result already exists
if (DEBUG_LEVEL>0) System.out.println("-->>> Skipping existing "+grid_path+" (as requested in \"Configure Process Distortions\")");
File grid_file = new File(grid_path);
if (!overwriteGrids && (grid_file.exists())){ // check if result already exists
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();
}
}
}
}
}
......@@ -10549,7 +10565,10 @@ if (MORE_BUTTONS) {
noMessageBoxes);
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 "+
IJ.d2s(0.000000001*(System.nanoTime()-startFileTime),3)+" seconds )\n");
if (this.SYNC_COMMAND.stopRequested.get()>0) {
......@@ -21107,6 +21126,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("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();
if (gd.wasCanceled()) return false;
patternDetectParameters.minGridPeriod= gd.getNextNumber();
......@@ -21115,6 +21137,7 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica
patternDetectParameters.minGridPeriodLwir= gd.getNextNumber();
patternDetectParameters.maxGridPeriodLwir= gd.getNextNumber();
}
patternDetectParameters.minGridFileSize = (int) gd.getNextNumber();
return true;
}
......@@ -4372,12 +4372,14 @@ public class MatchSimulatedPattern {
continue;
} else if ((refCell[0] != null) && (refCell[0].length > 3)) {
double dbg_contrast = (refCell[0].length > 2) ? refCell[0][2] : Double.NaN;
if (debugLevel > debugThreshold) {
System.out.println("**** refCell was deleted **** u=" + iUVRef[0] + " v="
+ iUVRef[1] + " current=" + iUVdir[0] + "/" + iUVdir[1] + " ncell=" + ncell
+ " waveFrontList.size()=" + waveFrontList.size() + " ref_x="
+ 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
// borders
double[][] wv = new double[2][];
......@@ -6855,7 +6857,7 @@ public class MatchSimulatedPattern {
IJ.showMessage("Error", "Pattern not found");
return distortionParameters.errPatternNotFound;
} else {
if (global_debug_level > (debugThreshold + 1))
if (global_debug_level > 0) // (debugThreshold + 1))
System.out.println("Initial pattern cluster has " + patternCells + " cells");
}
if (global_debug_level > (debugThreshold + 1))
......@@ -6878,7 +6880,7 @@ public class MatchSimulatedPattern {
imp_eq = imp;
if (distortionParameters.refineCorrelations) {
refineDistortionCorrelation(
double maxActualCorr = refineDistortionCorrelation(
lwirReaderParameters, // LwirReaderParameters lwirReaderParameters, // null is OK
distortionParameters, //
patternDetectParameters,
......@@ -6889,7 +6891,10 @@ public class MatchSimulatedPattern {
threadsMax,
updateStatus,
debug_level); // debug level
System.out.println(".... maxActualCorr="+maxActualCorr);
if (maxActualCorr <= 0.0) {
return distortionParameters.errRefineFailed; // 2021
}
recalculateWaveVectors(
updateStatus,
debug_level);// debug level used inside loops
......@@ -10560,6 +10565,7 @@ public class MatchSimulatedPattern {
}
contrast = contrasts[0];
result[2] = contrast;
// System.out.println("cobntrasts = "+contrasts[0]+", "+contrasts[1]);
if (Double.isNaN(contrasts[0]) || ((distortionParameters.correlationMinContrast > 0)
&& (contrasts[0] < distortionParameters.correlationMinContrast))) {
if ((debug_level > (debug_threshold - 1)))
......@@ -12400,6 +12406,7 @@ public class MatchSimulatedPattern {
public double minGridPeriod;
public double maxGridPeriod;
public double minGridPeriodLwir;
public int minGridFileSize = 15000; // Minimal file size (to overwrite)
public double maxGridPeriodLwir;
public double debugX;
public double debugY;
......@@ -12625,6 +12632,8 @@ public class MatchSimulatedPattern {
// match pointers errors
public int errTooFewCells = -10;
public int errPatternNotFound = -11;
public int errRefineFailed = -12;
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