Commit 825895a1 authored by Andrey Filippov's avatar Andrey Filippov

Added option to "Calculate grids" to skip re-calculation of existing

grid files
parent 95e22adf
......@@ -2027,7 +2027,7 @@ if (MORE_BUTTONS) {
COMPONENTS.equalizeGreens,
imp_sel, //distortions, // image to process
THREADS_MAX);
ImagePlus imp_calibrated0=matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,numAbsolutePoints);
ImagePlus imp_calibrated0=matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,"grid-",numAbsolutePoints);
imp_calibrated0.show();
// }
// } else {
......@@ -2683,12 +2683,14 @@ if (MORE_BUTTONS) {
}
long startTime=System.nanoTime();
boolean noMessageBoxes=true;
String prefix="grid-";
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
DISTORTION_PROCESS_CONFIGURATION.debugLevel=MASTER_DEBUG_LEVEL;
if (matchSimulatedPattern==null) matchSimulatedPattern= new MatchSimulatedPattern(DISTORTION.FFTSize);
matchSimulatedPattern.debugLevel=MASTER_DEBUG_LEVEL;
String [] sourceFilesList=DISTORTION_PROCESS_CONFIGURATION.selectSourceFiles(); // select files - with/without dialog
boolean saveGrids=DISTORTION_PROCESS_CONFIGURATION.saveGridImages;
boolean overwriteGrids=DISTORTION_PROCESS_CONFIGURATION.overwriteResultFiles;
if (sourceFilesList==null) return;
showPatternMinMaxPeriodDialog(PATTERN_DETECT);
for (int numFile=0;numFile<sourceFilesList.length;numFile++){
......@@ -2696,6 +2698,23 @@ if (MORE_BUTTONS) {
if (DEBUG_LEVEL>0){
System.out.println(IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+"s: Processing file # "+(numFile+1)+ " (of "+ sourceFilesList.length+"): "+sourceFilesList[numFile]);
}
if (saveGrids && !overwriteGrids){ // check if result already exists
int i = sourceFilesList[numFile].lastIndexOf('/');
if (i>0){
String path=prefix+sourceFilesList[numFile].substring(i+1);
String srcDir=DISTORTION_PROCESS_CONFIGURATION.selectGridFileDirectory(true,DISTORTION_PROCESS_CONFIGURATION.gridDirectory,true);
if (srcDir==null){
saveGrids=false; // do not ask about the next ones too
} else {
path=DISTORTION_PROCESS_CONFIGURATION.gridDirectory+Prefs.getFileSeparator()+path;
File rsltFile=new File(path);
if ((new File(path)).exists()){
if (DEBUG_LEVEL>0) System.out.println("-->>> Skipping existing "+path+" (as requested in \"Configure Process Distortions\")");
continue;
}
}
}
}
imp_sel=new ImagePlus(sourceFilesList[numFile]); // read source file
JP4_INSTANCE.decodeProperiesFromInfo(imp_sel);
matchSimulatedPattern= new MatchSimulatedPattern(DISTORTION.FFTSize); // TODO: is it needed each time?
......@@ -2743,7 +2762,7 @@ if (MORE_BUTTONS) {
COMPONENTS.equalizeGreens,
imp_sel, // image to process
THREADS_MAX);
ImagePlus imp_calibrated=matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,numAbsolutePoints);
ImagePlus imp_calibrated=matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,prefix, numAbsolutePoints);
if (DISTORTION_PROCESS_CONFIGURATION.showGridImages) imp_calibrated.show();
if (saveGrids){
FileSaver fs=new FileSaver(imp_calibrated);
......@@ -3695,7 +3714,7 @@ if (MORE_BUTTONS) {
return;
}
if (DEBUG_LEVEL>0) System.out.println("Matched "+numAbsolutePoints+" laser pointers, grid generated at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
ImagePlus [] imp_calibrated={matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,numAbsolutePoints)};
ImagePlus [] imp_calibrated={matchSimulatedPattern.getCalibratedPatternAsImage(imp_sel,"grid-",numAbsolutePoints)};
if (FOCUS_MEASUREMENT_PARAMETERS.showAcquiredImages) imp_calibrated[0].show(); // DISTORTION_PROCESS_CONFIGURATION.showGridImages
if (findCenter){
// Read required calibration files
......
......@@ -20272,6 +20272,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
public boolean removeOutOfGridPointers=true;
public boolean showGridImages=false;
public boolean saveGridImages=true;
public boolean overwriteResultFiles=false;
public int debugLevel=1;
public String selectSourceDirectory(boolean smart, String defaultPath, boolean newAllowed) {
......@@ -20308,6 +20309,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
properties.setProperty(prefix+"removeOutOfGridPointers",this.removeOutOfGridPointers+"");
properties.setProperty(prefix+"showGridImages", this.showGridImages+"");
properties.setProperty(prefix+"saveGridImages", this.saveGridImages+"");
properties.setProperty(prefix+"overwriteResultFiles", this.overwriteResultFiles+"");
properties.setProperty(prefix+"debugLevel", this.debugLevel+"");
}
public void getProperties(String prefix,Properties properties){
......@@ -20331,6 +20333,8 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
this.showGridImages=Boolean.parseBoolean(properties.getProperty(prefix+"showGridImages"));
if (properties.getProperty(prefix+"saveGridImages")!=null)
this.saveGridImages=Boolean.parseBoolean(properties.getProperty(prefix+"saveGridImages"));
if (properties.getProperty(prefix+"overwriteResultFiles")!=null)
this.overwriteResultFiles=Boolean.parseBoolean(properties.getProperty(prefix+"overwriteResultFiles"));
if (properties.getProperty(prefix+"debugLevel")!=null)
this.debugLevel=Integer.parseInt(properties.getProperty(prefix+"debugLevel"));
}
......@@ -20346,6 +20350,10 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
gd.addCheckbox ("Remove detected laser pointers if they are outside of the grid", this.removeOutOfGridPointers);
gd.addCheckbox ("Show grid files as images", this.showGridImages);
gd.addCheckbox ("Save grid files", this.saveGridImages);
gd.addCheckbox ("Overwrite existing result files", this.overwriteResultFiles);
gd.addNumericField("Debug level", this.debugLevel,0);
WindowTools.addScrollBars(gd);
gd.showDialog();
......@@ -20360,6 +20368,7 @@ I* - special case when the subcamera is being adjusted/replaced. How to deal wit
this.removeOutOfGridPointers=gd.getNextBoolean();
this.showGridImages= gd.getNextBoolean();
this.saveGridImages= gd.getNextBoolean();
this.overwriteResultFiles= gd.getNextBoolean();
this.debugLevel= (int) gd.getNextNumber();
System.out.println("1.newSourceDirectory = "+newSourceDirectory);
System.out.println("1.newGridDirectory = "+ newGridDirectory);
......@@ -848,7 +848,7 @@ horizontal axis:
// TODO - here - multiple images possible, not just one!
// First - create sparse, then remove nulls
imp_calibrated[numSensor] = this.matchSimulatedPatterns[numSensor].getCalibratedPatternAsImage(images[numSensor],numAbsolutePoints);
imp_calibrated[numSensor] = this.matchSimulatedPatterns[numSensor].getCalibratedPatternAsImage(images[numSensor],"grid-",numAbsolutePoints);
if (this.goniometerParameters.showAcquiredImages)
imp_calibrated[numSensor].show(); // DISTORTION_PROCESS_CONFIGURATION.showGridImages
} // for (int numSensor=0;numSensor<images.length;numSensor++) if
......
......@@ -7168,8 +7168,11 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
ImagePlus imp = new ImagePlus(title, stack);
return imp;
}
public ImagePlus getCalibratedPatternAsImage(ImagePlus imp_src, int numUsedPointers){
ImagePlus imp_result=getCalibratedPatternAsImage("grid-"+imp_src.getTitle(), numUsedPointers);
public ImagePlus getCalibratedPatternAsImage(
ImagePlus imp_src,
String prefix, int numUsedPointers){
// ImagePlus imp_result=getCalibratedPatternAsImage("grid-"+imp_src.getTitle(), numUsedPointers);
ImagePlus imp_result=getCalibratedPatternAsImage(prefix+imp_src.getTitle(), numUsedPointers);
// copy all the properties to the new image
JP46_Reader_camera jp4_instance= new JP46_Reader_camera(false);
jp4_instance.copyProperties (imp_src,imp_result);
......
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