for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>1) System.out.println("Raw PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with raw PSF kernels");
continue;
}
stack= interpolateKernelStack(imp_psf.getStack(), // Image stack, each slice consists of square kernels of one channel
INTERPOLATE,
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>1) System.out.println("Saving interpolation result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
if (PROCESS_PARAMETERS.invertKernels) {
tmpTime=System.nanoTime();
if ((PROCESS_PARAMETERS.partialKernelsSuperDirectory==null) || (PROCESS_PARAMETERS.partialKernelsSuperDirectory.length()==0)) {
for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>0) System.out.println("Interpolated PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with interpolated PSF kernels");
continue;
}
stack= reversePSFKernelStack(imp_psf.getStack(), // stack of 3 32-bit (float) images, made of square kernels
INVERSE,
THREADS_MAX, // size (side of square) of reverse PSF kernel
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>0) System.out.println("Saving PSF inversion result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
if (PROCESS_PARAMETERS.gaussianKernels) {
tmpTime=System.nanoTime();
if ((PROCESS_PARAMETERS.partialKernelsSuperDirectory==null) || (PROCESS_PARAMETERS.partialKernelsSuperDirectory.length()==0)) {
for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>0) System.out.println("Interpolated PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with interpolated PSF kernels");
continue;
}
stack= generateGaussianStackFromDirect(imp_psf.getStack(), // stack of 3 32-bit (float) images, made of square kernels
INVERSE,
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>0) System.out.println("Saving Gaussian kernels result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
System.out.println("Processing done in "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+ " seconds");
if (PROCESS_PARAMETERS.saveSettings) saveProperties(PROCESS_PARAMETERS.kernelsDirectory+Prefs.getFileSeparator()+"calibration_settings",null,PROCESS_PARAMETERS.useXML, PROPERTIES);
for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>1) System.out.println("Raw PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with raw PSF kernels");
continue;
}
stack= interpolateKernelStack(imp_psf.getStack(), // Image stack, each slice consists of square kernels of one channel
INTERPOLATE,
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>1) System.out.println("Saving interpolation result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
if (PROCESS_PARAMETERS.invertKernels) {
tmpTime=System.nanoTime();
if ((PROCESS_PARAMETERS.partialKernelsSuperDirectory==null) || (PROCESS_PARAMETERS.partialKernelsSuperDirectory.length()==0)) {
for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>0) System.out.println("Interpolated PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with interpolated PSF kernels");
continue;
}
stack= reversePSFKernelStack(imp_psf.getStack(), // stack of 3 32-bit (float) images, made of square kernels
INVERSE,
THREADS_MAX, // size (side of square) of reverse PSF kernel
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>0) System.out.println("Saving PSF inversion result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
if (PROCESS_PARAMETERS.gaussianKernels) {
tmpTime=System.nanoTime();
if ((PROCESS_PARAMETERS.partialKernelsSuperDirectory==null) || (PROCESS_PARAMETERS.partialKernelsSuperDirectory.length()==0)) {
for (fileNum=0;fileNum<filePaths.length;fileNum++) if ((filePaths[fileNum]!=null) && (filePaths[fileNum].length>0)) {
file=new File(filePaths[fileNum][0][0]);
if (!file.exists()) {
if (DEBUG_LEVEL>0) System.out.println("Interpolated PSF kernel stack file "+filePaths[fileNum][0][0]+" does not exist");
continue;
}
imp_psf=new ImagePlus(filePaths[fileNum][0][0]);
if (imp_psf.getStackSize()<3) {
System.out.println("Need a 3-layer stack with interpolated PSF kernels");
continue;
}
stack= generateGaussianStackFromDirect(imp_psf.getStack(), // stack of 3 32-bit (float) images, made of square kernels
INVERSE,
UPDATE_STATUS); // update status info
imp_psf = new ImagePlus(filePaths[fileNum][0][1], stack);
if (DEBUG_LEVEL>2) {
imp_psf.getProcessor().resetMinAndMax(); // imp_psf will be reused
imp_psf.show();
}
if (DEBUG_LEVEL>0) System.out.println("Saving Gaussian kernels result to"+filePaths[fileNum][0][1]+ " at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
FileSaver fs=new FileSaver(imp_psf);
fs.saveAsTiffStack(filePaths[fileNum][0][1]);
}
}
System.out.println("Processing done in "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3)+ " seconds");
if (PROCESS_PARAMETERS.saveSettings) saveProperties(PROCESS_PARAMETERS.kernelsDirectory+Prefs.getFileSeparator()+"calibration_settings",null,PROCESS_PARAMETERS.useXML, PROPERTIES);
return;
}
public void restore(boolean noAuto)
{
// boolean noAuto=label.equals("Restore no autoload");
Stringmsg="Could not set motor "+(tiltMotor+1)+" to move to "+tiltMotorPosition+" - may be out of limit";
...
...
@@ -432,11 +447,20 @@ horizontal axis:
returnfalse;
}
// update motor positions in the image properties, acquire and save images.
// TODO: Make acquisition/decoding/laser identification multi-threaded
this.cameras.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions());// Used target, not current to prevent minor variations
this.cameras.reportTiming=debugTiming;
// TODO: Make acquisition/decoding/laser identification multi-threaded
if(cameras!=null){
this.cameras.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions());// Used target, not current to prevent minor variations
this.cameras.reportTiming=debugTiming;
this.cameras.acquire(this.distortionProcessConfiguration.sourceDirectory,true,updateStatus);// true - use lasers, updateStatus - make false?
}elseif(lwirReader!=null){
this.lwirReader.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions());// Used target, not current to prevent minor variations
this.lwirReader.reportTiming=debugTiming;
this.lwirReader.acquire(this.distortionProcessConfiguration.sourceDirectory);// true - use lasers, updateStatus - make false?
}else{
System.out.println("Neignter traditional camera/rig, no LWIR rig are initialized, dry run");
}
this.cameras.acquire(this.distortionProcessConfiguration.sourceDirectory,true,updateStatus);// true - use lasers, updateStatus - make false?
if(debug_level>1)System.out.println("Initial Heading and Elevation are set to heading="+IJ.d2s(-initialHeadEl[0],2)+", elvation="+IJ.d2s(-initialHeadEl[1],2));
if(debug_level>1)System.out.println("Initial Heading and Elevation are set to heading="+IJ.d2s(-initialHeadEl[0],2)+", elvation="+IJ.d2s(-initialHeadEl[1],2));
lensDistortions.copySensorConstants(eyesisCameraParameters);// copy from the first channel
// lensDistortions.fittingStrategy will be defined later, no need to
// update it with a reference to distortionCalibrationData now
...
...
@@ -932,19 +956,19 @@ horizontal axis:
IJ.showMessage("Error","Failed to open fitting strategy file: "+this.goniometerParameters.strategyFile);
publicdoublepsf_cutoffLevel=0.2;// disregard pixels below this fraction of the maximal value
publicintpsf_minArea=10;// continue increasing the selected area, even if beyound psf_cutoffEnergy and psf_cutoffLevel,
publicdoublepsf_blurSigma=0.0;// optionally blur the calculated mask
// the following overwrite SimulParameters members
//TODO: Make initial pattern search more robust - if it first gets false positive, and number of detected cells is too low - increase threshold and re-try
//TODO: Make initial pattern search more robust - if it first gets false positive, and number of detected cells is too low - increase threshold and re-try
publicdoublecorrelationMinInitialContrast=3.0;// minimal contrast for the pattern of the center (initial point)
gd.addNumericField("Allowed overexposed pixels (fraction of the area) ",this.overexposedMaxFraction,3);// 0.005; // allowed fraction of the overexposed pixels in the PSF kernel measurement area
gd.addNumericField("Allowed overexposed pixels (fraction of the area) ",this.overexposedMaxFraction,3);// 0.005; // allowed fraction of the overexposed pixels in the PSF kernel measurement area
gd.addNumericField("Min fraction of the FFT square (weighted) to have defined pattern",this.minDefinedArea,3);