Loading src/main/java/com/elphel/imagej/calibration/Distortions.java +58 −44 Original line number Diff line number Diff line Loading @@ -65,7 +65,8 @@ import ij.text.TextWindow; // 1 - put commons-configuration-1.7.jar under ImageJ plugins directory (I used ImageJ-Elphel) // 2 - in Eclipse project properties -> Build Path -> Libraries -> Add External jar public class Distortions { final public double hintedMaxRelativeRadius=1.2; // make adjustable? // final public double hintedMaxRelativeRadius=1.2; // make adjustable? final public double hintedMaxRelativeRadiusToDiagonal= 1.1; // 0.96; // make adjustable? private ShowDoubleFloatArrays SDFA_INSTANCE=new ShowDoubleFloatArrays(); // just for debugging? // int numInputs=27; // with A8...// 24; // parameters in subcamera+... // int numOutputs=16; // with A8...//13; // parameters in a single camera Loading Loading @@ -3331,7 +3332,7 @@ For each point in the image int global_debug_level, // DEBUG_LEVEL int debug_level // debug level used inside loops ){ boolean invert = false; int debugThreshold0=0; int debugThreshold=2; MatchSimulatedPattern matchSimulatedPattern = new MatchSimulatedPattern(64); // new instance, all reset, FFTSize=64 will not be used Loading Loading @@ -3484,6 +3485,7 @@ For each point in the image removeOutOfGridPointers, // hintGrid, // predicted grid array (or null) hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only invert, global_debug_level, // DEBUG_LEVEL noMessageBoxes ); if (global_debug_level>0){ Loading Loading @@ -4040,7 +4042,14 @@ For each point in the image int numImg, int u, // grid signed u,v int v){ double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable int subCamera= this.fittingStrategy.distortionCalibrationData.gIP[numImg].channel; int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); // double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable double maxRelativeRadius=hintedMaxRelativeRadiusToDiagonal * Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; return reprojectGridNode( lensDistortionParameters, numImg, Loading Loading @@ -4134,7 +4143,12 @@ For each point in the image double goniometerInterAxis, // interAxisAngle int imageSet, boolean filterBorder){ double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); // double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable double maxRelativeRadius=hintedMaxRelativeRadiusToDiagonal * Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; // 1.1 is sufficient // double maxRelativeRadius= 2.0*Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; int debugThreshold=2; // Get parameter vector (22) for the selected sensor, current Eyesisparameters and specified orientation angles double [] parVector=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getParametersVector(stationNumber,subCamera); Loading @@ -4156,8 +4170,6 @@ For each point in the image parVector[goniometerInterAxisAngleIndex]= goniometerInterAxis; } // /interAxis int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); System.out.println("estimateGridOnSensor(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial); this.lensDistortionParameters.lensCalcInterParamers( this.lensDistortionParameters, // 22-long parameter vector for the image Loading Loading @@ -4187,7 +4199,8 @@ For each point in the image // simple fix - remove pixels with too few neighbors (maybe just all border pixels? for (int v=0;v<result.length;v++) for (int u=0;u<result[v].length;u++){ for (int v=0;v<result.length;v++) { for (int u=0;u<result[v].length;u++){ int [] iUV=this.patternParameters.uvIndicesToUV (u, v); if (iUV==null) { result[v][u]=null; Loading Loading @@ -4227,6 +4240,7 @@ For each point in the image } } } } if (filterBorder){ // now filter border nodes boolean [] mask= new boolean [patternGeometry.length*patternGeometry[0].length]; Loading src/main/java/com/elphel/imagej/calibration/EyesisAberrations.java +12 −1 Original line number Diff line number Diff line Loading @@ -1455,6 +1455,7 @@ public class EyesisAberrations { multiFilePSF , // MULTIFILE_PSF = new EyesisAberrations.MultiFilePSF( fileList[nChn], resultPaths[nChn], nChn, // int sensor_channel, // just for debugging sdfa_instance, // SDFA_INSTANCE impShow, // just to show in the same window? saveResult, Loading @@ -1478,6 +1479,7 @@ public class EyesisAberrations { EyesisAberrations.MultiFilePSF multiFilePSF , // MULTIFILE_PSF = new EyesisAberrations.MultiFilePSF( String [] filenames, String resultPath, int sensor_channel, // just for debugging ShowDoubleFloatArrays sdfa_instance, // SDFA_INSTANCE ImagePlus imp_sel, // just to show in the same window? boolean saveResult, Loading Loading @@ -1819,7 +1821,7 @@ public class EyesisAberrations { } } if (multiFilePSF.showWeights) sdfa_instance.showArrays(weights, kWidth, kHeight, true, "weights"); if (multiFilePSF.showWeights) sdfa_instance.showArrays(weights, kWidth, kHeight, true, "weights-"+sensor_channel); // double [][] weights=new double[nFiles+1][kLength]; for (int i=0;i<kLength;i++) weights[0][i]=0.0; psfKernelMap=new double [kHeight][kWidth][nChn][]; Loading Loading @@ -2299,6 +2301,15 @@ public class EyesisAberrations { final int full_fft_size = fft_size * PSF_subpixel / (is_mono? 2: 1); // for LWIR - 64, 5MPix: 1024. fft_size = 32/256 if (debug_level>3) { double [] dbg_index = new double [commonMatchSimulatedPattern.UV_INDEX.length]; for (int i = 0; i < dbg_index.length; i++) { dbg_index[i] = commonMatchSimulatedPattern.UV_INDEX[i]; } SDFA_INSTANCE.showArrays(dbg_index, imp_sel.getWidth(), dbg_index.length/imp_sel.getWidth(), "UV_INDEX"); } final boolean debugLateralShifts=(globalDebugLevel>1); System.out.println("createPSFMap(): masterDebugLevel="+masterDebugLevel+" globalDebugLevel="+globalDebugLevel+" debug_level="+debug_level); // 2 2 0 final long startTime = System.nanoTime(); Loading src/main/java/com/elphel/imagej/calibration/LensDistortionParameters.java +1 −0 Original line number Diff line number Diff line Loading @@ -960,6 +960,7 @@ dPXmmc/dphi= double zp, // target point horizontal, positive - away from camera, mm double maxRelativeRadius, // make configurable? boolean calculateAll){ // calculate derivatives, false - values only // maxRelativeRadius *= 1.3; // REMOVE me! switch (this.lensDistortionModelType){ case 0: case 1: Loading src/main/java/com/elphel/imagej/calibration/MatchSimulatedPattern.java +34 −17 Original line number Diff line number Diff line Loading @@ -6720,6 +6720,7 @@ public class MatchSimulatedPattern { int threadsMax, boolean updateStatus, int global_debug_level, // DEBUG_LEVEL int debug_level, // debug level used inside loops boolean noMessageBoxes) { if (imp == null) { IJ.showMessage("Error", "There are no images open\nProcess canceled"); return 0; Loading @@ -6733,6 +6734,8 @@ public class MatchSimulatedPattern { int minimal_pattern_cluster = is_lwir ? distortionParameters.minimalPatternClusterLwir : distortionParameters.minimalPatternCluster; boolean invert = false; // is_lwir; int fft_size = is_lwir ? distortionParameters.FFTSize_lwir : distortionParameters.FFTSize; long startTime = System.nanoTime(); Loading Loading @@ -6991,6 +6994,7 @@ public class MatchSimulatedPattern { pointersXY, removeOutOfGridPointers, // hintGrid, // predicted grid array (or null) hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only invert, // b/w global_debug_level, // DEBUG_LEVEL noMessageBoxes); } Loading Loading @@ -7738,7 +7742,7 @@ public class MatchSimulatedPattern { return flipsToRot(flips[0], flips[1], flips[2]); } public int[][] gridMatrixApproximate(double[][] coeff) { public int[][] gridMatrixApproximate(double[][] coeff, boolean invert) { int rot = matrixToRot(coeff); boolean[] flips = rotToFlips(rot); double[][] aI = { { 1, 0 }, { 0, 1 } }; Loading @@ -7755,7 +7759,8 @@ public class MatchSimulatedPattern { // now M reconstructs coeff double[][] aM = M.getArray(); // Black/white cells have to be flipped if flipU XOR flipW, regardless of swapUV int flipForWhite = (flips[1] ^ flips[2]) ? 1 : 0; int flipForWhite = (invert ^ flips[1] ^ flips[2]) ? 1 : 0; int[][] shifts = { { 2 * ((int) Math.round(0.5 * (coeff[0][2] + 0))), 2 * ((int) Math.round(0.5 * (coeff[1][2] + flipForWhite))) - flipForWhite }, Loading @@ -7774,10 +7779,6 @@ public class MatchSimulatedPattern { + " d1=" + d1 + " d2=" + d2); } int[][] iCoeff = { // {(int) Math.round(aM[0][0]), (int) Math.round(aM[0][1]),(int) // Math.round(coeff[0][2])}, // {(int) Math.round(aM[1][0]), (int) Math.round(aM[1][1]),(int) // Math.round(coeff[1][2])}}; { (int) Math.round(aM[0][0]), (int) Math.round(aM[0][1]), shifts[shiftSelect][0] }, { (int) Math.round(aM[1][0]), (int) Math.round(aM[1][1]), shifts[shiftSelect][1] } }; return iCoeff; Loading Loading @@ -7805,8 +7806,17 @@ public class MatchSimulatedPattern { return iCoeff; } public double worstGridMatchRotSkew(double[][] coeff) { int[][] iCoeff = gridMatrixApproximate(coeff); public double worstGridMatchRotSkew( double[][] coeff) { return worstGridMatchRotSkew(coeff, false); } public double worstGridMatchRotSkew( double[][] coeff, boolean invert ) { int[][] iCoeff = gridMatrixApproximate(coeff, invert); double worst = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { Loading @@ -7817,8 +7827,15 @@ public class MatchSimulatedPattern { return worst; } public double worstGridMatchTranslate(double[][] coeff) { // in grids half-periods, not pixels! int[][] iCoeff = gridMatrixApproximate(coeff); public double worstGridMatchTranslate( double[][] coeff) { // in grids half-periods, not pixels! return worstGridMatchTranslate(coeff, false); } public double worstGridMatchTranslate( double[][] coeff, boolean invert) { // in grids half-periods, not pixels! int[][] iCoeff = gridMatrixApproximate(coeff, invert); double worst = 0; for (int i = 0; i < 2; i++) { double d = Math.abs(coeff[i][2] - iCoeff[i][2]); Loading Loading @@ -8246,7 +8263,7 @@ public class MatchSimulatedPattern { if (gridMatchCoeff != null) { gridRotation = matrixToRot(gridMatchCoeff); this.debugLevel = global_debug_level; int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff); int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff, false); if (global_debug_level > 1) { System.out.println("gridMatchCoeff[0]={" + IJ.d2s(gridMatchCoeff[0][0], 5) + ", " + IJ.d2s(gridMatchCoeff[0][1], 5) + ", " + IJ.d2s(gridMatchCoeff[0][2], 5) + "}"); Loading Loading @@ -8320,6 +8337,7 @@ public class MatchSimulatedPattern { double[][] pointersXYUV, boolean removeOutOfGridPointers, // double[][][] hintGrid, // predicted grid array (or null) double hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only boolean invert, // for lwir int global_debug_level, // DEBUG_LEVEL boolean noMessageBoxes) { boolean has_lasers = false; Loading @@ -8342,7 +8360,7 @@ public class MatchSimulatedPattern { if (gridMatchCoeff != null) { gridRotation = matrixToRot(gridMatchCoeff); this.debugLevel = global_debug_level; int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff); int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff, invert); if (global_debug_level > 0) { System.out.println("gridMatchCoeff[0]={" + IJ.d2s(gridMatchCoeff[0][0], 5) + ", " + IJ.d2s(gridMatchCoeff[0][1], 5) + ", " + IJ.d2s(gridMatchCoeff[0][2], 5) + "}"); Loading @@ -8353,9 +8371,8 @@ public class MatchSimulatedPattern { + ", " + iGridMatchCoeff[0][2] + "}"); System.out.println("iGridMatchCoeff[1]={" + iGridMatchCoeff[1][0] + ", " + iGridMatchCoeff[1][1] + ", " + iGridMatchCoeff[1][2] + "}"); System.out.println("worstGridMatchRotSkew()=" + IJ.d2s(worstGridMatchRotSkew(gridMatchCoeff), 5)); System.out .println("worstGridMatchTranslate()=" + IJ.d2s(worstGridMatchTranslate(gridMatchCoeff), 5)); System.out.println("worstGridMatchRotSkew()=" + IJ.d2s(worstGridMatchRotSkew(gridMatchCoeff, invert), 5)); System.out.println("worstGridMatchTranslate()=" + IJ.d2s(worstGridMatchTranslate(gridMatchCoeff, invert), 5)); } // hintGridTolerance==0 - do not try to determine shift from the hint (not // reliable yet) Loading Loading
src/main/java/com/elphel/imagej/calibration/Distortions.java +58 −44 Original line number Diff line number Diff line Loading @@ -65,7 +65,8 @@ import ij.text.TextWindow; // 1 - put commons-configuration-1.7.jar under ImageJ plugins directory (I used ImageJ-Elphel) // 2 - in Eclipse project properties -> Build Path -> Libraries -> Add External jar public class Distortions { final public double hintedMaxRelativeRadius=1.2; // make adjustable? // final public double hintedMaxRelativeRadius=1.2; // make adjustable? final public double hintedMaxRelativeRadiusToDiagonal= 1.1; // 0.96; // make adjustable? private ShowDoubleFloatArrays SDFA_INSTANCE=new ShowDoubleFloatArrays(); // just for debugging? // int numInputs=27; // with A8...// 24; // parameters in subcamera+... // int numOutputs=16; // with A8...//13; // parameters in a single camera Loading Loading @@ -3331,7 +3332,7 @@ For each point in the image int global_debug_level, // DEBUG_LEVEL int debug_level // debug level used inside loops ){ boolean invert = false; int debugThreshold0=0; int debugThreshold=2; MatchSimulatedPattern matchSimulatedPattern = new MatchSimulatedPattern(64); // new instance, all reset, FFTSize=64 will not be used Loading Loading @@ -3484,6 +3485,7 @@ For each point in the image removeOutOfGridPointers, // hintGrid, // predicted grid array (or null) hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only invert, global_debug_level, // DEBUG_LEVEL noMessageBoxes ); if (global_debug_level>0){ Loading Loading @@ -4040,7 +4042,14 @@ For each point in the image int numImg, int u, // grid signed u,v int v){ double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable int subCamera= this.fittingStrategy.distortionCalibrationData.gIP[numImg].channel; int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); // double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable double maxRelativeRadius=hintedMaxRelativeRadiusToDiagonal * Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; return reprojectGridNode( lensDistortionParameters, numImg, Loading Loading @@ -4134,7 +4143,12 @@ For each point in the image double goniometerInterAxis, // interAxisAngle int imageSet, boolean filterBorder){ double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); // double maxRelativeRadius=this.hintedMaxRelativeRadius; // make adjustable double maxRelativeRadius=hintedMaxRelativeRadiusToDiagonal * Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; // 1.1 is sufficient // double maxRelativeRadius= 2.0*Math.sqrt(sensorWidth * sensorWidth + sensorHeight*sensorHeight)/ sensorWidth; int debugThreshold=2; // Get parameter vector (22) for the selected sensor, current Eyesisparameters and specified orientation angles double [] parVector=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getParametersVector(stationNumber,subCamera); Loading @@ -4156,8 +4170,6 @@ For each point in the image parVector[goniometerInterAxisAngleIndex]= goniometerInterAxis; } // /interAxis int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); System.out.println("estimateGridOnSensor(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial); this.lensDistortionParameters.lensCalcInterParamers( this.lensDistortionParameters, // 22-long parameter vector for the image Loading Loading @@ -4187,7 +4199,8 @@ For each point in the image // simple fix - remove pixels with too few neighbors (maybe just all border pixels? for (int v=0;v<result.length;v++) for (int u=0;u<result[v].length;u++){ for (int v=0;v<result.length;v++) { for (int u=0;u<result[v].length;u++){ int [] iUV=this.patternParameters.uvIndicesToUV (u, v); if (iUV==null) { result[v][u]=null; Loading Loading @@ -4227,6 +4240,7 @@ For each point in the image } } } } if (filterBorder){ // now filter border nodes boolean [] mask= new boolean [patternGeometry.length*patternGeometry[0].length]; Loading
src/main/java/com/elphel/imagej/calibration/EyesisAberrations.java +12 −1 Original line number Diff line number Diff line Loading @@ -1455,6 +1455,7 @@ public class EyesisAberrations { multiFilePSF , // MULTIFILE_PSF = new EyesisAberrations.MultiFilePSF( fileList[nChn], resultPaths[nChn], nChn, // int sensor_channel, // just for debugging sdfa_instance, // SDFA_INSTANCE impShow, // just to show in the same window? saveResult, Loading @@ -1478,6 +1479,7 @@ public class EyesisAberrations { EyesisAberrations.MultiFilePSF multiFilePSF , // MULTIFILE_PSF = new EyesisAberrations.MultiFilePSF( String [] filenames, String resultPath, int sensor_channel, // just for debugging ShowDoubleFloatArrays sdfa_instance, // SDFA_INSTANCE ImagePlus imp_sel, // just to show in the same window? boolean saveResult, Loading Loading @@ -1819,7 +1821,7 @@ public class EyesisAberrations { } } if (multiFilePSF.showWeights) sdfa_instance.showArrays(weights, kWidth, kHeight, true, "weights"); if (multiFilePSF.showWeights) sdfa_instance.showArrays(weights, kWidth, kHeight, true, "weights-"+sensor_channel); // double [][] weights=new double[nFiles+1][kLength]; for (int i=0;i<kLength;i++) weights[0][i]=0.0; psfKernelMap=new double [kHeight][kWidth][nChn][]; Loading Loading @@ -2299,6 +2301,15 @@ public class EyesisAberrations { final int full_fft_size = fft_size * PSF_subpixel / (is_mono? 2: 1); // for LWIR - 64, 5MPix: 1024. fft_size = 32/256 if (debug_level>3) { double [] dbg_index = new double [commonMatchSimulatedPattern.UV_INDEX.length]; for (int i = 0; i < dbg_index.length; i++) { dbg_index[i] = commonMatchSimulatedPattern.UV_INDEX[i]; } SDFA_INSTANCE.showArrays(dbg_index, imp_sel.getWidth(), dbg_index.length/imp_sel.getWidth(), "UV_INDEX"); } final boolean debugLateralShifts=(globalDebugLevel>1); System.out.println("createPSFMap(): masterDebugLevel="+masterDebugLevel+" globalDebugLevel="+globalDebugLevel+" debug_level="+debug_level); // 2 2 0 final long startTime = System.nanoTime(); Loading
src/main/java/com/elphel/imagej/calibration/LensDistortionParameters.java +1 −0 Original line number Diff line number Diff line Loading @@ -960,6 +960,7 @@ dPXmmc/dphi= double zp, // target point horizontal, positive - away from camera, mm double maxRelativeRadius, // make configurable? boolean calculateAll){ // calculate derivatives, false - values only // maxRelativeRadius *= 1.3; // REMOVE me! switch (this.lensDistortionModelType){ case 0: case 1: Loading
src/main/java/com/elphel/imagej/calibration/MatchSimulatedPattern.java +34 −17 Original line number Diff line number Diff line Loading @@ -6720,6 +6720,7 @@ public class MatchSimulatedPattern { int threadsMax, boolean updateStatus, int global_debug_level, // DEBUG_LEVEL int debug_level, // debug level used inside loops boolean noMessageBoxes) { if (imp == null) { IJ.showMessage("Error", "There are no images open\nProcess canceled"); return 0; Loading @@ -6733,6 +6734,8 @@ public class MatchSimulatedPattern { int minimal_pattern_cluster = is_lwir ? distortionParameters.minimalPatternClusterLwir : distortionParameters.minimalPatternCluster; boolean invert = false; // is_lwir; int fft_size = is_lwir ? distortionParameters.FFTSize_lwir : distortionParameters.FFTSize; long startTime = System.nanoTime(); Loading Loading @@ -6991,6 +6994,7 @@ public class MatchSimulatedPattern { pointersXY, removeOutOfGridPointers, // hintGrid, // predicted grid array (or null) hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only invert, // b/w global_debug_level, // DEBUG_LEVEL noMessageBoxes); } Loading Loading @@ -7738,7 +7742,7 @@ public class MatchSimulatedPattern { return flipsToRot(flips[0], flips[1], flips[2]); } public int[][] gridMatrixApproximate(double[][] coeff) { public int[][] gridMatrixApproximate(double[][] coeff, boolean invert) { int rot = matrixToRot(coeff); boolean[] flips = rotToFlips(rot); double[][] aI = { { 1, 0 }, { 0, 1 } }; Loading @@ -7755,7 +7759,8 @@ public class MatchSimulatedPattern { // now M reconstructs coeff double[][] aM = M.getArray(); // Black/white cells have to be flipped if flipU XOR flipW, regardless of swapUV int flipForWhite = (flips[1] ^ flips[2]) ? 1 : 0; int flipForWhite = (invert ^ flips[1] ^ flips[2]) ? 1 : 0; int[][] shifts = { { 2 * ((int) Math.round(0.5 * (coeff[0][2] + 0))), 2 * ((int) Math.round(0.5 * (coeff[1][2] + flipForWhite))) - flipForWhite }, Loading @@ -7774,10 +7779,6 @@ public class MatchSimulatedPattern { + " d1=" + d1 + " d2=" + d2); } int[][] iCoeff = { // {(int) Math.round(aM[0][0]), (int) Math.round(aM[0][1]),(int) // Math.round(coeff[0][2])}, // {(int) Math.round(aM[1][0]), (int) Math.round(aM[1][1]),(int) // Math.round(coeff[1][2])}}; { (int) Math.round(aM[0][0]), (int) Math.round(aM[0][1]), shifts[shiftSelect][0] }, { (int) Math.round(aM[1][0]), (int) Math.round(aM[1][1]), shifts[shiftSelect][1] } }; return iCoeff; Loading Loading @@ -7805,8 +7806,17 @@ public class MatchSimulatedPattern { return iCoeff; } public double worstGridMatchRotSkew(double[][] coeff) { int[][] iCoeff = gridMatrixApproximate(coeff); public double worstGridMatchRotSkew( double[][] coeff) { return worstGridMatchRotSkew(coeff, false); } public double worstGridMatchRotSkew( double[][] coeff, boolean invert ) { int[][] iCoeff = gridMatrixApproximate(coeff, invert); double worst = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) { Loading @@ -7817,8 +7827,15 @@ public class MatchSimulatedPattern { return worst; } public double worstGridMatchTranslate(double[][] coeff) { // in grids half-periods, not pixels! int[][] iCoeff = gridMatrixApproximate(coeff); public double worstGridMatchTranslate( double[][] coeff) { // in grids half-periods, not pixels! return worstGridMatchTranslate(coeff, false); } public double worstGridMatchTranslate( double[][] coeff, boolean invert) { // in grids half-periods, not pixels! int[][] iCoeff = gridMatrixApproximate(coeff, invert); double worst = 0; for (int i = 0; i < 2; i++) { double d = Math.abs(coeff[i][2] - iCoeff[i][2]); Loading Loading @@ -8246,7 +8263,7 @@ public class MatchSimulatedPattern { if (gridMatchCoeff != null) { gridRotation = matrixToRot(gridMatchCoeff); this.debugLevel = global_debug_level; int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff); int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff, false); if (global_debug_level > 1) { System.out.println("gridMatchCoeff[0]={" + IJ.d2s(gridMatchCoeff[0][0], 5) + ", " + IJ.d2s(gridMatchCoeff[0][1], 5) + ", " + IJ.d2s(gridMatchCoeff[0][2], 5) + "}"); Loading Loading @@ -8320,6 +8337,7 @@ public class MatchSimulatedPattern { double[][] pointersXYUV, boolean removeOutOfGridPointers, // double[][][] hintGrid, // predicted grid array (or null) double hintGridTolerance, // allowed mismatch (fraction of period) or 0 - orientation only boolean invert, // for lwir int global_debug_level, // DEBUG_LEVEL boolean noMessageBoxes) { boolean has_lasers = false; Loading @@ -8342,7 +8360,7 @@ public class MatchSimulatedPattern { if (gridMatchCoeff != null) { gridRotation = matrixToRot(gridMatchCoeff); this.debugLevel = global_debug_level; int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff); int[][] iGridMatchCoeff = gridMatrixApproximate(gridMatchCoeff, invert); if (global_debug_level > 0) { System.out.println("gridMatchCoeff[0]={" + IJ.d2s(gridMatchCoeff[0][0], 5) + ", " + IJ.d2s(gridMatchCoeff[0][1], 5) + ", " + IJ.d2s(gridMatchCoeff[0][2], 5) + "}"); Loading @@ -8353,9 +8371,8 @@ public class MatchSimulatedPattern { + ", " + iGridMatchCoeff[0][2] + "}"); System.out.println("iGridMatchCoeff[1]={" + iGridMatchCoeff[1][0] + ", " + iGridMatchCoeff[1][1] + ", " + iGridMatchCoeff[1][2] + "}"); System.out.println("worstGridMatchRotSkew()=" + IJ.d2s(worstGridMatchRotSkew(gridMatchCoeff), 5)); System.out .println("worstGridMatchTranslate()=" + IJ.d2s(worstGridMatchTranslate(gridMatchCoeff), 5)); System.out.println("worstGridMatchRotSkew()=" + IJ.d2s(worstGridMatchRotSkew(gridMatchCoeff, invert), 5)); System.out.println("worstGridMatchTranslate()=" + IJ.d2s(worstGridMatchTranslate(gridMatchCoeff, invert), 5)); } // hintGridTolerance==0 - do not try to determine shift from the hint (not // reliable yet) Loading