if (DEBUG_LEVEL>0) System.out.println(((this.SYNC_COMMAND.stopRequested.get()>0)?"Partial (interrupted by user) set of grids":"All")+ " grids calculation done at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
if (DEBUG_LEVEL>0) System.out.println(((this.SYNC_COMMAND.stopRequested.get()>0)?"Partial (interrupted by user) set of grids":"All")+ " grids calculation done at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
if (DEBUG_LEVEL>0) System.out.println(((this.SYNC_COMMAND.stopRequested.get()>0)?"Partial (interrupted by user) set of grids":"All")+ " grids calculation done at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
public boolean showPatternDetectParametersDialog(MatchSimulatedPattern.PatternDetectParameters patternDetectParameters) {
public boolean showPatternDetectParametersDialog(MatchSimulatedPattern.PatternDetectParameters patternDetectParameters, boolean use_lwir) {
///gaussWidth
GenericDialog gd = new GenericDialog("Parameters");
gd.addNumericField("Gaussian width for the window function (<=0 - use Hamming):", patternDetectParameters.gaussWidth, 3);
...
...
@@ -19849,16 +20021,30 @@ use the result to create a rejectiobn mask - if the energy was high, (multiplica
gd.addNumericField("Minimal pattern correlation contrast" , patternDetectParameters.minCorrContrast, 3); //5.0; // Discrimination threshold between good and bad pattern correleation
gd.addNumericField("Minimal pattern grid period (<=0.0 - do not check)" , patternDetectParameters.minGridPeriod, 2,5,"pix");
gd.addNumericField("Maximal pattern grid period (<=0.0 - do not check)" , patternDetectParameters.maxGridPeriod, 2,5,"pix");
if (use_lwir) {
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.addMessage("----- debug -----");
gd.addNumericField("Debug grid near pixel X" , patternDetectParameters.debugX, 1,6,"pix");
gd.addNumericField("Debug grid near pixel X" , patternDetectParameters.debugY, 1,6,"pix");
gd.addNumericField("Debug grid nodes at this distance of (x,Y) - <0 - no debug", patternDetectParameters.debugRadius, 1,5,"pix");
gd.addMessage("----- New method that should work with large cells (only half-period negative correlations fit in window) -----");
@@ -139,14 +137,14 @@ public class EyesisAberrations {
if(showResult){
impInvertedPSF.getProcessor().resetMinAndMax();// imp_psf will be reused
impInvertedPSF.show();
}
}
if(saveResult){
if(globalDebugLevel>0)System.out.println((numProcessed+1)+" of "+numToProcess+": saving invered (of the file"+srcPaths[nChn]+") kernel to "+resultPaths[nChn]+" at "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
multiFilePSF,// MULTIFILE_PSF = new EyesisAberrations.MultiFilePSF(
...
...
@@ -1433,7 +1434,7 @@ public class EyesisAberrations {
thisDebugLevel,
globalDebugLevel);
if(OK&&(globalDebugLevel>0))System.out.println("Saved combined kernel for channel "+nChn+" to"+resultPaths[nChn]+" at "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
" this radius ={"+psfRadius[0][worstFile+1][index]+","+psfRadius[1][worstFile+1][index]+","+psfRadius[2][worstFile+1][index]+"}\n"+
" mean radius ={"+radiusRatio[0][0][index]+","+radiusRatio[1][0][index]+","+radiusRatio[2][0][index]+"}\n"+
" this center X={"+pxfCenterX[0][worstFile+1][index]+","+pxfCenterX[1][worstFile+1][index]+","+pxfCenterX[2][worstFile+1][index]+"}\n"+
" mean center X={"+pxfCenterX[0][0][index]+","+pxfCenterX[1][0][index]+","+pxfCenterX[2][0][index]+"}\n"+
" this center Y={"+pxfCenterY[0][worstFile+1][index]+","+pxfCenterY[1][worstFile+1][index]+","+pxfCenterY[2][worstFile+1][index]+"}\n"+
" mean center Y={"+pxfCenterY[0][0][index]+","+pxfCenterY[1][0][index]+","+pxfCenterY[2][0][index]+"}");
}
if(numSamples<1)break;// nothing left
if(numSamples<1)break;// nothing left
if(worstDiff>multiFilePSF.radiusDiffHigh){
if((numSamples==1)&&(globalDebugLevel>0)){
System.out.println("PSF size for the cell "+tileX+":"+tileY+", file# "+worstFile+" varies too much from the neighbor cells, so it is removed, creating a gap");
...
...
@@ -1733,14 +1734,14 @@ public class EyesisAberrations {
weights[0][index]+=weights[nFile+1][index];
}
}
// for each channel, each cell - compare radius calculated for neighbors (use masked weights) and the cell
// TODO: Filter out outlayers: Add bonus to cells surrounded by others?
// double [][][][] c= new double[numResults][nChn][nFiles+1][kLength];
// fht_instance.debug=(centerXY[0]-Math.round(centerXY[0]))<-0.4; // just reducing number
pixelsPSF=fht_instance.translateSubPixel(
...
...
@@ -3549,14 +3554,14 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
if(debugLevel>2)System.out.println("Centroid after second binPSF: x="+IJ.d2s(centroidXY[0],3)+" y="+IJ.d2s(centroidXY[1],3)+" center was at x="+IJ.d2s(centerXY[0],3)+" y="+IJ.d2s(centerXY[1],3));
}
/* compensate center point and/or add center-symmetrical points if enabled */
gd.addCheckbox("Autoload additional files on \"Restore\"",this.autoRestore);
gd.addCheckbox("Overwrite all (including position/orientation) SFE parameters from the sensor calibration files (at auto-load) DANGEROUS!",this.autoRestoreSensorOverwriteOrientation);
gd.addCheckbox("Overwrite SFE distortion parameters from the sensor calibration files (at auto-load) DANGEROUS!",this.autoRestoreSensorOverwriteDistortion);
gd.addCheckbox("Re-calibrate grids on autoload",this.autoReCalibrate);
gd.addCheckbox("Ignore laser pointers on recalibrate",this.autoReCalibrateIgnoreLaser);
gd.addCheckbox("Filter grids after restore",this.autoFilter);
gd.addCheckbox("Trust enabled images on input (mark as hintedGrid=2)",this.trustEnabled);
// add new nodes if the appeared after shift of the pattern
if(debug_level>0){// calculate/print number of defined nodes in the grid
System.out.println("updateFocusGrid(), number of already defined grid cells (before distortions()) = "+matchSimulatedPattern.numDefinedCells());
...
...
@@ -136,6 +135,8 @@ public class LensAdjustment {
null,// is not used in update mode
distortionParameters,//
patternDetectParameters,
patternDetectParameters.minGridPeriod/2,
patternDetectParameters.maxGridPeriod/2,
simulParameters,
equalizeGreens,
imp_eq,// image to process
...
...
@@ -158,6 +159,8 @@ public class LensAdjustment {
numAbsolutePoints=matchSimulatedPattern.calculateDistortions(// allow more of grid around pointers?
distortionParameters,//
patternDetectParameters,
patternDetectParameters.minGridPeriod/2,
patternDetectParameters.maxGridPeriod/2,
simulParameters,
equalizeGreens,
imp_eq,
...
...
@@ -201,7 +204,7 @@ public class LensAdjustment {
returnnumAbsolutePoints;
}
publicstaticclassFocusMeasurementParameters{
publicStringgridGeometryFile="";
publicStringinitialCalibrationFile="";
...
...
@@ -216,15 +219,15 @@ public class LensAdjustment {
publicStringserialNumber="";// camera serial number string
publicdoublesensorTemperature=Double.NaN;// last measured sensor temperature
//other summary results to be saved with parameters
publicdoubleresult_lastKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from last run
publicdoubleresult_lastFD20=Double.NaN;// focal distance for 20C, measured from last run
publicdoubleresult_allHistoryKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
publicdoubleresult_lastKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from last run
publicdoubleresult_lastFD20=Double.NaN;// focal distance for 20C, measured from last run
publicdoubleresult_allHistoryKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
publicdoubleresult_allHistoryFD20=Double.NaN;// focal distance for 20C, measured from all the measurement histgory
publicdoubleresult_fDistance=Double.NaN;// last measured focal distance
publicdoubleresult_tiltX=Double.NaN;// last measured tilt X
publicdoubleresult_tiltY=Double.NaN;// last measured tilt Y
publicdoubleresult_R50=Double.NaN;// last measured R50 (average PSF 50% level radius, pixels - somewhat larged than actual because of measurement settings)
publicdoubleresult_A50=Double.NaN;// last measured A50 (simailar, but R^2 are averaged)
publicdoubleresult_A50=Double.NaN;// last measured A50 (simailar, but R^2 are averaged)
publicdoubleresult_B50=Double.NaN;// last measured B50 (simailar, but R^4 are averaged)
publicdoubleresult_RC50=Double.NaN;// last measured RC50(R50 calculated only for the 2 center samples)
publicdoubleresult_PX0=Double.NaN;// lens center shift, X
...
...
@@ -237,10 +240,10 @@ public class LensAdjustment {
publicintlensSerialLength=4;
publicStringlensSerial="";// Lens serial number
publicbooleanaskLensSerial=true;// Ask lens serial on camera power cycle
publicdoublereportTemperature=50;// temperature to report focal length
publicdoublereportTemperature=50;// temperature to report focal length
publicbooleanshowLegacy=false;// Show old focusing parameters (most are not supported anyway)
publicbooleanincludeLensSerial=true;// add lens serial to config filename
publicdoublecenterDeltaX=0.0;// required X-difference between lens center and sensor center
publicdoublecenterDeltaX=0.0;// required X-difference between lens center and sensor center
publicdoublecenterDeltaY=0.0;// required Y-difference between lens center and sensor center
// with the seam in the middle - make even # of samples horizontally
// to be made private or removed
...
...
@@ -258,34 +261,34 @@ public class LensAdjustment {
publicbooleanshowAcquiredImages=false;
publicbooleanshowROI=true;
publicbooleanshowSamples=true;
publicbooleanshowFittedParameters=true;
publicbooleanuseHeadLasers=true;
// when approximating PSF with a second degree polynomial:
publicdoublepsf_cutoffEnergy=0.98;//0.5; // disregard pixels outside of this fraction of the total energy
publicdoublepsf_cutoffLevel=0.2;// disregard pixels below this fraction of the maximal value
publicintpsf_minArea=10;// continue increasing the selected area, even if beyond psf_cutoffEnergy and psf_cutoffLevel,
// if the selected area is smaller than this (so approximation would work)
publicdoublepsf_blurSigma=0.0;// optionally blur the calculated mask
publicdoubleweightRatioRedToGreen=0.7;// Use this data when combining defocusing data from different color PSF
publicdoubleweightRatioBlueToGreen=0.2;
publicdoubletargetFarNear=0.0;// OBSOLETE target logarithm of average tangential-to-radial resolution
publicbooleanuseRadialTangential=false;// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
publicbooleanuseRadialTangential=false;// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
publicdoubletargetMicrons=0.0;// target lens center distance (away from "best focus"
publicdoubletoleranceMicrons=0.5;// microns
publicdoubletoleranceTilt=0.02;//
publicdoubletoleranceTilt=0.02;//
publicdoubletoleranceThreshold=3.0;// When each error is under scaled threshold, reduce correction step twice
// public boolean parallelAdjust=true; // move 3 motors parallel after each 3-motor focus/tilt adjustment
publicdoubleparallelAdjustThreshold=4.0;// adjust 3 motors parallel if focal distance error in the center exceeds this
// public boolean parallelAdjust=true; // move 3 motors parallel after each 3-motor focus/tilt adjustment
publicdoubleparallelAdjustThreshold=4.0;// adjust 3 motors parallel if focal distance error in the center exceeds this
publicdoublemotorsSigma=896.0;// when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma 1/4 turn
publicdoublemotorsSigma3=896.0;// all 3 motors together (focusing center)
publicdoublemotorsMinSigma=200.0;// sigma will not drop below this value when fitting walk is getting smaller
publicdoublemotorsMinSigma=200.0;// sigma will not drop below this value when fitting walk is getting smaller
publicdoublemotorsVarSigmaToTravel=2.0;// when walk is getting smaller, sigma will keep going down proportionally
publicdoublemotorsFadeSigma=0.3;// after each step new sigma will have this part of the calculated from the travel
publicdoublemotorsFadeSigma=0.3;// after each step new sigma will have this part of the calculated from the travel
publicdoublemotorsOverShootToBalance=0.9;//For quadratic maximum the correction will be increased by 1+motorsOverShootToBalance if there are less samples on teh other side
publicbooleanfilterGoodDistance=true;// when measuring tilt, use those with good center with higher weight
publicdoublegoodDistanceSigma=5.0;// sigma for the weight function of tilt measurements, depending on the center distance error
...
...
@@ -295,15 +298,15 @@ public class LensAdjustment {
publicdoubleprobe_M1M2M3=448.0;// how far to move average of the 3 motors: (M1+M2+M3)/3
publicdoubleprobe_M3_M1M2=3584.0;// how far to move M3 opposite to M1 and M2: M3-(M1+M2)/2
publicdoubleprobe_M2_M1=3584.0;// how far to move M2 opposite to M1: M2-M1
publicdoublesigmaToProbe=1.0;// data from far samples decay proportionally to the probe distances
publicbooleanuseTheBest=true;// adjust from the best known position (false - from the last)
publicbooleanprobeSymmetrical=false;// if true, probe 6 measurements), if false - only 4 (tetrahedron)
publicbooleanparallelBeforeProbing=true;// move 3 motors before probing around
publicdoublesigmaToProbe=1.0;// data from far samples decay proportionally to the probe distances
publicbooleanuseTheBest=true;// adjust from the best known position (false - from the last)
publicbooleanprobeSymmetrical=false;// if true, probe 6 measurements), if false - only 4 (tetrahedron)
publicbooleanparallelBeforeProbing=true;// move 3 motors before probing around
publicdoublereProbeDistance=4000.0;// re-run probing around in orthoganal directions, if the current position move farther from the last probing one
publicdoublebelieveLast=0.0;// coefficient 0.. 1.0. When each ot the 3 parameters is linearized, add shift, so 1.0 the planes will go throug the last sample
publicbooleancompensateHysteresis=true;// move motors in the same direction to compensate for hysteresis
publicdoubleminCorr=100.0;// minimal correction movement to initiate final numFinalCorr moves
publicintnumFinalCorr=5;// exit if this number of last corrections where below minCorr
...
...
@@ -312,16 +315,16 @@ public class LensAdjustment {
publicintmaxAutoIterations=25;// exit if history grows above this
publicdoublemaxAutoDistance=10000;// Maximal allowed automatic correction, motor steps
publicbooleanconfirmFirstAuto=true;// ask confirmation after first automatic adjustment step (before moving)
publicdoublemotorsPreSigma=3584.0;// when fitting parabola for focusing sharpness in the center, far measurements decay with this sigma
publicdoublemaxLinearStep=3584.0;// If there are insufficient measurements to fit parabola - make this step
publicintscanStep=320;// 200; // motor step (all 3 motors) in scan focus mode (signed value)
publicintscanNumber=50;// number of scanStep steps to run
publicintscanNumberNegative=20;// 15; // number of scanStep steps negative from the start
publicintscanNumberNegative=20;// 15; // number of scanStep steps negative from the start
publicbooleanscanHysteresis=false;// true; // scan both ways
publicintscanHysteresisNumber=5;// number of test points for the Hysteresis measurement
publicbooleanscanTiltReverse=false;// enable scanning tilt in both directions
publicbooleanscanMeasureLast=false;// Calculate PSF after last move (to original position)
...
...
@@ -330,45 +333,45 @@ public class LensAdjustment {
publicintscanTiltRangeY=14336;// 4 periods
publicintscanTiltStepsX=24;
publicintscanTiltStepsY=24;
publicintmotorHysteresis=300;
publicdoublemeasuredHysteresis=0;// actually measured (will be saved/restored)
publicdoublemotorCalm=2;// wait (seconds) after motors reached final position (for the first time) before acquiring image
publicdoublemotorCalm=2;// wait (seconds) after motors reached final position (for the first time) before acquiring image
publicdoublelinearReductionRatio=4.0/38.0;// sensor travel to motors travel (all 3 together), By design it is 4/38~=0.105
publicintmotorDebug=0;// 1 show motor moves, 2 - show hysteresis back-ups too
// parameters for appoximating sensor center position
publicintlensDistanceNumPoints=1000;// number of points to tabulate center focus parameters vs. focal distance
publicintlensDistancePolynomialDegree=8;// polynomial degree to approximate center focus parameters vs. focal distance
publicdoublelensDistanceWeightY=0.5;// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
publicintlensDistanceNumPoints=1000;// number of points to tabulate center focus parameters vs. focal distance
publicintlensDistancePolynomialDegree=8;// polynomial degree to approximate center focus parameters vs. focal distance
publicdoublelensDistanceWeightY=0.5;// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
publicdoublelensDistanceWeightK=0.0;// 0.0 use 3 distances (to frac-R, frac-B and Y) with teh same weight when fitting, 1.0 - proportional to squared derivatives
publicbooleanlensDistanceInteractive=true;// Open dialog when calibrating focal distance
publicbooleanlensDistanceShowResults=true;// show results window from foca
publicbooleanlensDistanceMoveToGoal=true;// Move to targetMicrons
publicbooleanpowerControlEnable=true;
publicdoublepowerControlMaximalTemperature=60.0;
publicdoublepowerControlHeaterOnMinutes=10.0;
publicdoublepowerControlNeitherOnMinutes=5.0;
publicdoublepowerControlFanOnMinutes=15.0;
publicStringuvLasersIP="192.168.0.236";// IP address of the camera with UV LEDs and aiming lasers are connected
publicintuvLasersBus=0;// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
publicdouble[]uvLasersCurrents={40.0,40.0,40.0,40.0};// default LED on currents (mA)
// the following 3 overwrite SimulParameters members
publicdoublesmallestSubPix=0.3;// subdivide pixels down to that fraction when simulating
publicdoublebitmapNonuniforityThreshold=0.1;// subdivide pixels until difference between the corners is below this value
publicintsubdiv=4;
publicintsubdiv=4;
// overwrites public static class MultiFilePSF.overexposedMaxFraction
publicdoubleoverexposedMaxFraction=0.1;// allowed fraction of the overexposed pixels in the PSF kernel measurement area
publicdoubleoverexposedMaxFraction=0.1;// allowed fraction of the overexposed pixels in the PSF kernel measurement area
// overwrites public static class PSFParameters.minDefinedArea
publicdoubleminDefinedArea=0.75;// minimal (weighted) fraction of the defined patter pixels in the FFT area
publicintPSFKernelSize=32;// size of the detected PSF kernel
publicbooleanapproximateGrid=true;// approximate grid with polynomial
publicbooleanapproximateGrid=true;// approximate grid with polynomial
publicbooleancenterPSF=true;// Center PSF by modifying phase
publicdoublemask1_sigma=1.0;
publicdoublemask1_threshold=0.25;
publicdoublegaps_sigma=1.0;
...
...
@@ -384,24 +387,24 @@ public class LensAdjustment {
publicdoublecorrelationMinInitialContrast=1.5;// minimal contrast for the pattern of the center (initial point)
publicdoublecorrelationMinAbsoluteContrast=0.5;// minimal contrast for the pattern to pass, does not compensate for low ligt
publicdoublecorrelationMinAbsoluteInitialContrast=0.5;// minimal contrast for the pattern of the center (initial point)
@@ -454,21 +457,21 @@ public class LensAdjustment {
}
returnnull;// should not get here
}
publicFocusMeasurementParameters(int[]motorPos){
this.motorPos=motorPos;
}
publicvoidresetResults(){
this.result_lastKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20=Double.NaN;// focal distance for 20C, measured from last run
this.result_allHistoryKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_lastKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20=Double.NaN;// focal distance for 20C, measured from last run
this.result_allHistoryKT=Double.NaN;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_allHistoryFD20=Double.NaN;// focal distance for 20C, measured from all the measurement histgory
this.result_fDistance=Double.NaN;// last measured focal distance
this.result_tiltX=Double.NaN;// last measured tilt X
this.result_tiltY=Double.NaN;// last measured tilt Y
this.result_R50=Double.NaN;// last measured R50 (average PSF 50% level radius, pixels - somewhat larged than actual because of measurement settings)
this.result_A50=Double.NaN;// last measured A50 (simailar, but R^2 are averaged)
this.result_A50=Double.NaN;// last measured A50 (simailar, but R^2 are averaged)
this.result_B50=Double.NaN;// last measured B50 (similar, but R^4 are averaged)
this.result_RC50=Double.NaN;// last measured RC50(R50 calculated only for the 2 center samples)
this.result_PX0=Double.NaN;// lens center shift, X
...
...
@@ -490,15 +493,15 @@ public class LensAdjustment {
StringserialNumber,// camera serial number string
doublesensorTemperature,// last measured sensor temperature
// other summary results to be saved with parameters
doubleresult_lastKT,// focal distance temperature coefficient (um/C), measured from last run
doubleresult_lastFD20,// focal distance for 20C, measured from last run
doubleresult_allHistoryKT,// focal distance temperature coefficient (um/C), measured from all the measurement histgory
doubleresult_lastKT,// focal distance temperature coefficient (um/C), measured from last run
doubleresult_lastFD20,// focal distance for 20C, measured from last run
doubleresult_allHistoryKT,// focal distance temperature coefficient (um/C), measured from all the measurement histgory
doubleresult_allHistoryFD20,// focal distance for 20C, measured from all the measurement histgory
doubleresult_fDistance,// last measured focal distance
doubleresult_tiltX,// last measured tilt X
doubleresult_tiltY,// last measured tilt Y
doubleresult_R50,// last measured R50 (average PSF 50% level radius, pixels - somewhat larged than actual because of measurement settings)
doubleresult_A50,// last measured A50 (simailar, but R^2 are averaged)
doubleresult_A50,// last measured A50 (simailar, but R^2 are averaged)
doubleresult_B50,// last measured B50 (simailar, but R^4 are averaged)
doubleresult_RC50,// last measured RC50(R50 calculated only for the 2 center samples)
doubleresult_PX0,// lens center shift, X
...
...
@@ -511,7 +514,7 @@ public class LensAdjustment {
intmanufacturingState,// SFE manufacturing state
booleanaskLensSerial,
booleanincludeLensSerial,// add lens serial to config filename
doublecenterDeltaX,// required X-difference between lens center and sensor center
doublecenterDeltaX,// required X-difference between lens center and sensor center
doublecenterDeltaY,// required Y-difference between lens center and sensor center
Rectanglemargins,
int[]numSamples,
...
...
@@ -525,7 +528,7 @@ public class LensAdjustment {
booleanshowAcquiredImages,
booleanshowROI,
booleanshowSamples,
booleanshowFittedParameters,
booleanuseHeadLasers,
doublepsf_cutoffEnergy,// disregard pixels outside of this fraction of the total energy
...
...
@@ -533,21 +536,21 @@ public class LensAdjustment {
intpsf_minArea,// continue increasing the selected area, even if beyound psf_cutoffEnergy and psf_cutoffLevel,
// if the selected area is smaller than this (so approximation wpuld work)
doublepsf_blurSigma,// optionally blur the calculated mask
doubleweightRatioRedToGreen,// Use this data when combining defocusing data from different color PSF
doubleweightRatioBlueToGreen,
doubletargetFarNear,// target logariphm of average tangential-to-radial resolution
booleanuseRadialTangential,// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
booleanuseRadialTangential,// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
doubletargetMicrons,// target lens center distance (away from "best focus"
doubletoleranceMicrons,// microns
doubletoleranceTilt,//
doubletoleranceTilt,//
doubletoleranceThreshold,// When each error is under swcaled thereshold, reduce correxction step twice
doubleparallelAdjustThreshold,// adjust 3 motors parallel if focal distance error in the center exceeds this
doubleparallelAdjustThreshold,// adjust 3 motors parallel if focal distance error in the center exceeds this
doublemotorsSigma,// when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
doublemotorsSigma3,// all 3 motors together (focusing center)
doublemotorsMinSigma,// sigma will not drop below this value when fitting walk is getting smaller
doublemotorsMinSigma,// sigma will not drop below this value when fitting walk is getting smaller
doublemotorsVarSigmaToTravel,// when walk is getting smaller, sigma will keep going down proportionally
doublemotorsFadeSigma,// after each step new sigma will have this part of the calculated from the travel
doublemotorsFadeSigma,// after each step new sigma will have this part of the calculated from the travel
doublemotorsOverShootToBalance,//For quadratic maximum the correction will be increased by 1+motorsOverShootToBalance if there are less samples on teh other side
booleanfilterGoodDistance,// when measuring tilt, use those with good center with higher weight
doublegoodDistanceSigma,// sigma for the weight function of tilt measurements, depending on the center distance error
...
...
@@ -557,8 +560,8 @@ public class LensAdjustment {
doubleprobe_M1M2M3,// how far to move average of the 3 motors: (M1+M2+M3)/3
doubleprobe_M3_M1M2,// how far to move M3 opposite to M1 and M2: M3-(M1+M2)/2
doubleprobe_M2_M1,// how far to move M2 opposite to M1: M2-M1
doublesigmaToProbe,// data from far samples decay proportionally to the probe distances
booleanuseTheBest,// adjust from the best known position (false - from the last)
doublesigmaToProbe,// data from far samples decay proportionally to the probe distances
booleanuseTheBest,// adjust from the best known position (false - from the last)
booleanprobeSymmetrical,// if true, probe 6 measurements), if false - only 4 (tetrahedron)
booleanparallelBeforeProbing,// move 3 motors before probing around
doublereProbeDistance,// re-run probing around in orthoganal directions, if the current position move farther from the last probing one
...
...
@@ -578,7 +581,7 @@ public class LensAdjustment {
intscanNumberNegative,// of them negative
booleanscanHysteresis,// scan both ways
intscanHysteresisNumber,// number of test points for the Hysteresis measurement
@@ -588,15 +591,15 @@ public class LensAdjustment {
intscanTiltStepsX,//=24;
intscanTiltStepsY,//=24;
intmotorHysteresis,
doublemeasuredHysteresis,// actually measured (will be saved/restored)
doublemotorCalm,// wait (seconds) after motors reached final position (for the first time) before acquiring image
doublemotorCalm,// wait (seconds) after motors reached final position (for the first time) before acquiring image
doublelinearReductionRatio,// sensor travel to motors travel (all 3 together), By design it is 4/38~=0.105
intmotorDebug,// 1 show motor moves, 2 - show hysteresis back-ups too
intlensDistanceNumPoints,// number of points to tabulate center focus parameters vs. focal distance
intlensDistancePolynomialDegree,// polynomial degree to approximate center focus parameters vs. focal distance
doublelensDistanceWeightY,// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
intlensDistanceNumPoints,// number of points to tabulate center focus parameters vs. focal distance
intlensDistancePolynomialDegree,// polynomial degree to approximate center focus parameters vs. focal distance
doublelensDistanceWeightY,// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
doublelensDistanceWeightK,// 0.0 use 3 distances (to frac-R, frac-B and Y) with teh same weight when fitting, 1.0 - proportional to squared derivatives
booleanlensDistanceInteractive,// Open dialog when calibrating focal distance
booleanlensDistanceShowResults,// show results window from foca
...
...
@@ -612,8 +615,8 @@ public class LensAdjustment {
doublesmallestSubPix,// subdivide pixels down to that fraction when simulating
doublebitmapNonuniforityThreshold,// subdivide pixels until difference between the corners is below this value
intsubdiv,
doubleoverexposedMaxFraction,// allowed fraction of the overexposed pixels in the PSF kernel measurement area
intsubdiv,
doubleoverexposedMaxFraction,// allowed fraction of the overexposed pixels in the PSF kernel measurement area
doubleminDefinedArea,// minimal (weighted) fraction of the defined patter pixels in the FFT area
intPSFKernelSize,
booleanapproximateGrid,// approximate grid with polynomial
...
...
@@ -633,7 +636,7 @@ public class LensAdjustment {
double[]postUVscrewSensitivity,// microns/turn for 3 post-UV fixture adjustment screws
booleanflatFieldCorrection,
doubleflatFieldExpand,
doublethresholdFinish,// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
doublethresholdFinish,// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
intnumIterations,// maximal number of iterations
booleancameraIsConfigured,
booleanuseExtraSensor,
...
...
@@ -655,15 +658,15 @@ public class LensAdjustment {
this.showResults=showResults;// show focusing (includingh intermediate) results
this.serialNumber=serialNumber;// camera serial number string
this.sensorTemperature=sensorTemperature;// last measured sensor temperature
this.result_lastKT=result_lastKT;// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20=result_lastFD20;// focal distance for 20C, measured from last run
this.result_allHistoryKT=result_allHistoryKT;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_lastKT=result_lastKT;// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20=result_lastFD20;// focal distance for 20C, measured from last run
this.result_allHistoryKT=result_allHistoryKT;// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_allHistoryFD20=result_allHistoryFD20;// focal distance for 20C, measured from all the measurement histgory
this.result_fDistance=result_fDistance;// last measured focal distance
this.result_tiltX=result_tiltX;// last measured tilt X
this.result_tiltY=result_tiltY;// last measured tilt Y
this.result_R50=result_R50;// last measured R50 (average PSF 50% level radius, pixels - somewhat larged than actual because of measurement settings)
this.result_A50=result_A50;// last measured A50 (simailar, but R^2 are averaged)
this.result_A50=result_A50;// last measured A50 (simailar, but R^2 are averaged)
this.result_B50=result_B50;// last measured B50 (simailar, but R^4 are averaged)
this.result_RC50=result_RC50;// last measured RC50(R50 calculated only for the 2 center samples)
this.result_PX0=result_PX0;// lens center shift, X
...
...
@@ -676,7 +679,7 @@ public class LensAdjustment {
this.manufacturingState=manufacturingState;
this.askLensSerial=askLensSerial;
this.includeLensSerial=includeLensSerial;// add lens serial to config filename
this.centerDeltaX=centerDeltaX;// required X-difference between lens center and sensor center
this.centerDeltaX=centerDeltaX;// required X-difference between lens center and sensor center
this.centerDeltaY=centerDeltaY;// required Y-difference between lens center and sensor center
this.margins=(Rectangle)margins.clone();
// this.origin=origin.clone(); // top left corner
...
...
@@ -701,17 +704,17 @@ public class LensAdjustment {
this.weightRatioRedToGreen=weightRatioRedToGreen;// Use this data when combining defocusing data from different color PSF
this.targetFarNear=targetFarNear;// target logariphm of average tangential-to-radial resolution
this.useRadialTangential=useRadialTangential;// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
this.useRadialTangential=useRadialTangential;// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
this.targetMicrons=targetMicrons;// target lens center distance (away from "best focus"
this.toleranceMicrons=toleranceMicrons;// microns
this.toleranceTilt=toleranceTilt;//
this.toleranceTilt=toleranceTilt;//
this.toleranceThreshold=toleranceThreshold;// When each error is under swcaled thereshold, reduce correxction step twice
this.parallelAdjustThreshold=parallelAdjustThreshold;// adjust 3 motors parallel if focal distance error in the center exceeds this
this.parallelAdjustThreshold=parallelAdjustThreshold;// adjust 3 motors parallel if focal distance error in the center exceeds this
this.motorsSigma=motorsSigma;// when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
this.motorsSigma3=motorsSigma3;// same when 3 motors move together
this.motorsMinSigma=motorsMinSigma;// sigma will not drop below this value when fitting walk is getting smaller
this.motorsMinSigma=motorsMinSigma;// sigma will not drop below this value when fitting walk is getting smaller
this.motorsVarSigmaToTravel=motorsVarSigmaToTravel;// when walk is getting smaller, sigma will keep going down proportionally
this.motorsFadeSigma=motorsFadeSigma;// after each step new sigma will have this part of the calculated from the travel
this.motorsFadeSigma=motorsFadeSigma;// after each step new sigma will have this part of the calculated from the travel
this.motorsOverShootToBalance=motorsOverShootToBalance;//For quadratic maximum the correction will be increased by 1+motorsOverShootToBalance if there are less samples on teh other side
this.filterGoodDistance=filterGoodDistance;// when measuring tilt, use those with good center with higher weight
this.goodDistanceSigma=goodDistanceSigma;// sigma for the weight function of tilt measurements, depending on the center distance error
...
...
@@ -722,7 +725,7 @@ public class LensAdjustment {
this.probe_M3_M1M2=probe_M3_M1M2;// how far to move M3 opposite to M1 and M2: M3-(M1+M2)/2
this.probe_M2_M1=probe_M2_M1;// how far to move M2 opposite to M1: M2-M1
this.sigmaToProbe=sigmaToProbe;// data from far samples decay proportionally to the probe distances
this.useTheBest=useTheBest;// adjust from the best known position (false - from the last)
this.useTheBest=useTheBest;// adjust from the best known position (false - from the last)
this.probeSymmetrical=probeSymmetrical;// if true, probe 6 measurements), if false - only 4 (tetrahedron)
this.parallelBeforeProbing=parallelBeforeProbing;// move 3 motors before probing around
this.reProbeDistance=reProbeDistance;// re-run probing around in orthoganal directions, if the current position move farther from the last probing one
...
...
@@ -742,7 +745,7 @@ public class LensAdjustment {
this.scanNumberNegative=scanNumberNegative;// of them negative
this.scanHysteresis=scanHysteresis;// scan both ways
this.scanHysteresisNumber=scanHysteresisNumber;// number of test points for the Hysteresis measurement
@@ -751,15 +754,15 @@ public class LensAdjustment {
this.scanTiltRangeY=scanTiltRangeY;//, //=14336; // 4 periods
this.scanTiltStepsX=scanTiltStepsX;//=24;
this.scanTiltStepsY=scanTiltStepsY;//=24;
this.motorHysteresis=motorHysteresis;
this.measuredHysteresis=measuredHysteresis;// actually measured (will be saved/restored)
this.motorCalm=motorCalm;// wait (seconds) after motors reached final position (for the first time) before acquiring image
this.motorCalm=motorCalm;// wait (seconds) after motors reached final position (for the first time) before acquiring image
this.linearReductionRatio=linearReductionRatio;// sensor travel to motors travel (all 3 together), By design it is 4/38~=0.105
this.motorDebug=motorDebug;// 1 show motor moves, 2 - show hysteresis back-ups too
this.lensDistanceNumPoints=lensDistanceNumPoints;// number of points to tabulate center focus parameters vs. focal distance
this.lensDistancePolynomialDegree=lensDistancePolynomialDegree;// polynomial degree to approximate center focus parameters vs. focal distance
this.lensDistanceWeightY=lensDistanceWeightY;// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
this.lensDistanceNumPoints=lensDistanceNumPoints;// number of points to tabulate center focus parameters vs. focal distance
this.lensDistancePolynomialDegree=lensDistancePolynomialDegree;// polynomial degree to approximate center focus parameters vs. focal distance
this.lensDistanceWeightY=lensDistanceWeightY;// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
this.lensDistanceWeightK=lensDistanceWeightK;// 0.0 use 3 distances (to frac-R, frac-B and Y) with teh same weight when fitting, 1.0 - proportional to squared derivatives
this.lensDistanceInteractive=lensDistanceInteractive;// Open dialog when calibrating focal distance
this.lensDistanceShowResults=lensDistanceShowResults;// show results window from foca
...
...
@@ -774,12 +777,12 @@ public class LensAdjustment {
this.uvLasersCurrents=uvLasersCurrents.clone();// default LED on currents (mA)
this.approximateGrid=approximateGrid;// approximate grid with polynomial
this.centerPSF=centerPSF;// approximate grid with polynomial
this.centerPSF=centerPSF;// approximate grid with polynomial
this.mask1_sigma=mask1_sigma;
this.mask1_threshold=mask1_threshold;
this.gaps_sigma=gaps_sigma;
...
...
@@ -795,7 +798,7 @@ public class LensAdjustment {
this.postUVscrewSensitivity=postUVscrewSensitivity.clone();// microns/turn for 3 post-UV fixture adjustment screws
this.flatFieldCorrection=flatFieldCorrection;
this.flatFieldExpand=flatFieldExpand;
this.thresholdFinish=thresholdFinish;// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
this.thresholdFinish=thresholdFinish;// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
this.numIterations=numIterations;// maximal number of iterations
this.cameraIsConfigured=cameraIsConfigured;
this.useExtraSensor=useExtraSensor;
...
...
@@ -806,7 +809,8 @@ public class LensAdjustment {
this.reportTemperature=reportTemperature;
this.showLegacy=showLegacy;
}
publicFocusMeasurementParametersclone(){
@Override
publicFocusMeasurementParametersclone(){
returnnewFocusMeasurementParameters(
this.gridGeometryFile,
this.initialCalibrationFile,
...
...
@@ -819,15 +823,15 @@ public class LensAdjustment {
this.showResults,// show focusing (includingh intermediate) results
this.serialNumber,// camera serial number string
this.sensorTemperature,// last measured sensor temperature
this.result_lastKT,// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20,// focal distance for 20C, measured from last run
this.result_allHistoryKT,// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_lastKT,// focal distance temperature coefficient (um/C), measured from last run
this.result_lastFD20,// focal distance for 20C, measured from last run
this.result_allHistoryKT,// focal distance temperature coefficient (um/C), measured from all the measurement histgory
this.result_allHistoryFD20,// focal distance for 20C, measured from all the measurement histgory
this.result_fDistance,// last measured focal distance
this.result_tiltX,// last measured tilt X
this.result_tiltY,// last measured tilt Y
this.result_R50,// last measured R50 (average PSF 50% level radius, pixels - somewhat larged than actual because of measurement settings)
this.result_A50,// last measured A50 (simailar, but R^2 are averaged)
this.result_A50,// last measured A50 (simailar, but R^2 are averaged)
this.result_B50,// last measured B50 (simailar, but R^4 are averaged)
this.result_RC50,// last measured RC50(R50 calculated only for the 2 center samples)
this.result_PX0,// lens center shift, X
...
...
@@ -840,7 +844,7 @@ public class LensAdjustment {
this.manufacturingState,
this.askLensSerial,
this.includeLensSerial,// add lens serial to config filename
this.centerDeltaX,// required X-difference between lens center and sensor center
this.centerDeltaX,// required X-difference between lens center and sensor center
this.centerDeltaY,// required Y-difference between lens center and sensor center
this.margins,
this.numSamples,
...
...
@@ -863,18 +867,18 @@ public class LensAdjustment {
this.weightRatioRedToGreen,// Use this data when combining defocusing data from different color PSF
this.weightRatioBlueToGreen,
this.targetFarNear,// target logariphm of average tangential-to-radial resolution
this.useRadialTangential,// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
this.useRadialTangential,// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
this.targetMicrons,// target lens center distance (away from "best focus"
this.toleranceMicrons,// microns
this.toleranceTilt,//
this.toleranceTilt,//
this.toleranceThreshold,// When each error is under swcaled thereshold, reduce correxction step twice
this.parallelAdjustThreshold,// adjust 3 motors parallel if focal distance error in the center exceeds this
this.parallelAdjustThreshold,// adjust 3 motors parallel if focal distance error in the center exceeds this
this.motorsSigma,// when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
this.motorsSigma3,// same when 3 motors move together
this.motorsMinSigma,// sigma will not drop below this value when fitting walk is getting smaller
this.motorsMinSigma,// sigma will not drop below this value when fitting walk is getting smaller
this.motorsVarSigmaToTravel,// when walk is getting smaller, sigma will keep going down proportionally
this.motorsFadeSigma,// after each step new sigma will have this part of the calculated from the travel
this.motorsFadeSigma,// after each step new sigma will have this part of the calculated from the travel
this.motorsOverShootToBalance,//For quadratic maximum the correction will be increased by 1+motorsOverShootToBalance if there are less samples on teh other side
this.filterGoodDistance,// when measuring tilt, use those with good center with higher weight
this.goodDistanceSigma,// sigma for the weight function of tilt measurements, depending on the center distance error
...
...
@@ -884,8 +888,8 @@ public class LensAdjustment {
this.probe_M1M2M3,// how far to move average of the 3 motors: (M1+M2+M3)/3
this.probe_M3_M1M2,// how far to move M3 opposite to M1 and M2: M3-(M1+M2)/2
this.probe_M2_M1,// how far to move M2 opposite to M1: M2-M1
this.sigmaToProbe,// data from far samples decay proportionally to the probe distances
this.useTheBest,// adjust from the best known position (false - from the last)
this.sigmaToProbe,// data from far samples decay proportionally to the probe distances
this.useTheBest,// adjust from the best known position (false - from the last)
this.probeSymmetrical,// if true, probe 6 measurements), if false - only 4 (tetrahedron)
this.parallelBeforeProbing,// move 3 motors before probing around
this.reProbeDistance,// re-run probing around in orthoganal directions, if the current position move farther from the last probing one
...
...
@@ -905,7 +909,7 @@ public class LensAdjustment {
this.scanNumberNegative,// of them negative
this.scanHysteresis,// scan both ways
this.scanHysteresisNumber,// number of test points for the Hysteresis measurement
this.scanTiltEnable,// enable scanning tilt
this.scanTiltReverse,
this.scanMeasureLast,
...
...
@@ -915,14 +919,14 @@ public class LensAdjustment {
this.scanTiltStepsX,
this.scanTiltStepsY,
this.motorHysteresis,
this.measuredHysteresis,// actually measured (will be saved/restored)
this.motorCalm,// wait (seconds) after motors reached final position (for the first time) before acquiring image
this.motorCalm,// wait (seconds) after motors reached final position (for the first time) before acquiring image
this.linearReductionRatio,// sensor travel to motors travel (all 3 together), By design it is 4/38~=0.105
this.motorDebug,// 1 show motor moves, 2 - show hysteresis back-ups too
this.lensDistanceNumPoints,// number of points to tabulate center focus parameters vs. focal distance
this.lensDistancePolynomialDegree,// polynomial degree to approximate center focus parameters vs. focal distance
this.lensDistanceWeightY,// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
this.lensDistanceNumPoints,// number of points to tabulate center focus parameters vs. focal distance
this.lensDistancePolynomialDegree,// polynomial degree to approximate center focus parameters vs. focal distance
this.lensDistanceWeightY,// normalize overall sharpness (that depends on the lens quality and/or PSF parameters) to differential ones
this.lensDistanceWeightK,// 0.0 use 3 distances (to frac-R, frac-B and Y) with teh same weight when fitting, 1.0 - proportional to squared derivatives
this.lensDistanceInteractive,// Open dialog when calibrating focal distance
this.lensDistanceShowResults,// show results window from foca
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);
if(!Double.isNaN(this.result_allHistoryKT))gd.addMessage("Temperature focal distance coefficient calculated from all measurements is "+this.result_allHistoryKT+" microns");
if(!Double.isNaN(this.result_allHistoryFD20))gd.addMessage("Focal distance @20C calculated from all measurements is "+this.result_allHistoryFD20+" microns");
gd.addNumericField("Max frame diff",this.max_frame_diff,0,3,"","Maximal difference in frames between simultaneously acquired channels as calculated from the timestamps");