Commit 5fdebd94 authored by Andrey Filippov's avatar Andrey Filippov

fixing projected grid used for aberrations kernels generation

parent 9e7ad476
...@@ -1094,6 +1094,7 @@ if (MORE_BUTTONS) { ...@@ -1094,6 +1094,7 @@ if (MORE_BUTTONS) {
boolean noAuto=label.equals("Restore no autoload"); boolean noAuto=label.equals("Restore no autoload");
ABERRATIONS_PARAMETERS.autoRestore=false; ABERRATIONS_PARAMETERS.autoRestore=false;
loadProperties(null,PROCESS_PARAMETERS.kernelsDirectory,PROCESS_PARAMETERS.useXML, PROPERTIES); loadProperties(null,PROCESS_PARAMETERS.kernelsDirectory,PROCESS_PARAMETERS.useXML, PROPERTIES);
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (ABERRATIONS_PARAMETERS.autoRestore && !noAuto){ if (ABERRATIONS_PARAMETERS.autoRestore && !noAuto){
if (DEBUG_LEVEL>0)System.out.println("Auto-loading configuration files"); if (DEBUG_LEVEL>0)System.out.println("Auto-loading configuration files");
if (LENS_DISTORTIONS==null) { if (LENS_DISTORTIONS==null) {
...@@ -1141,6 +1142,27 @@ if (MORE_BUTTONS) { ...@@ -1141,6 +1142,27 @@ if (MORE_BUTTONS) {
} }
if (LENS_DISTORTIONS.fittingStrategy != null) { // trying to fix restore
if (DEBUG_LEVEL>0) System.out.println("LENS_DISTORTIONS.fittingStrategy != null -> Extra after loading");
int minGridsNoPointer=1000;
int [] numImages=DISTORTION_CALIBRATION_DATA.filterImages(
false, // resetHinted,
2, // minPointers,
0.4, // minGridPeriod,
true, // disableNoVignetting,
minGridsNoPointer); //minGridsNoPointer);
System.out.println("Number of enabled grid images: "+numImages[0]+
", of them new: "+numImages[1]+
", disabled without vignetting info: "+numImages[2]+
", disabled having less than "+minGridsNoPointer+" nodes and no matched pointers: "+numImages[3]);
if (DISTORTION_CALIBRATION_DATA.gIS==null) {
int numImageSets=DISTORTION_CALIBRATION_DATA.buildImageSets(false); // from scratch
if (DEBUG_LEVEL>0) System.out.println("Image set was empty, built a new one with "+numImageSets+" image sets (\"panoramas\"): ");
DISTORTION_CALIBRATION_DATA.updateSetOrientation(null); // restore orientation from (enabled) image files
if (DEBUG_LEVEL>0) System.out.println("Setting sets orientation from per-grid image data");
}
}
restoreFocusingHistory(false); restoreFocusingHistory(false);
} }
return; return;
......
...@@ -3073,12 +3073,16 @@ For each point in the image ...@@ -3073,12 +3073,16 @@ For each point in the image
(this.fittingStrategy.distortionCalibrationData.gIS[imageSet]!=null)){ (this.fittingStrategy.distortionCalibrationData.gIS[imageSet]!=null)){
this.fittingStrategy.distortionCalibrationData.gIS[imageSet].updateParameterVectorFromSet(parVector); this.fittingStrategy.distortionCalibrationData.gIS[imageSet].updateParameterVectorFromSet(parVector);
} }
int goniometerHorizontalIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerHorizontalIndex(); if (!Double.isNaN(goniometerHorizontal)) {
int goniometerAxialIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerAxialIndex(); int goniometerHorizontalIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerHorizontalIndex();
parVector[goniometerHorizontalIndex]=goniometerHorizontal;
}
if (!Double.isNaN(goniometerAxial)) {
int goniometerAxialIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerAxialIndex();
parVector[goniometerAxialIndex]= goniometerAxial;
}
int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera); int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera);
int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera); int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera);
parVector[goniometerHorizontalIndex]=goniometerHorizontal;
parVector[goniometerAxialIndex]= goniometerAxial;
System.out.println("estimateGridOnSensor(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial); System.out.println("estimateGridOnSensor(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial);
calcInterParamers( calcInterParamers(
this.lensDistortionParameters, // 22-long parameter vector for the image this.lensDistortionParameters, // 22-long parameter vector for the image
...@@ -1116,7 +1116,7 @@ public class EyesisAberrations { ...@@ -1116,7 +1116,7 @@ public class EyesisAberrations {
} else if (debugLevel>2){ } else if (debugLevel>2){
System.out.println("Skipping disabled image "+imgNum); System.out.println("Skipping disabled image "+imgNum);
} }
if (debugLevel>0)System.out.println("Enabled "+numSelected+" source files ("+numDeselected+") were removed by channel selection"); if (debugLevel>0)System.out.println("Enabled "+numSelected+" source files ("+numDeselected+") were removed by channel selection. partialToReprojected="+partialToReprojected);
String [] sourcePaths=new String [selectedImages.length]; String [] sourcePaths=new String [selectedImages.length];
// Set/verify source paths // Set/verify source paths
...@@ -1254,7 +1254,7 @@ public class EyesisAberrations { ...@@ -1254,7 +1254,7 @@ public class EyesisAberrations {
Double.NaN, // goniometerAxial, - not used Double.NaN, // goniometerAxial, - not used
distortions.fittingStrategy.distortionCalibrationData.gIP[numGridImage].getSetNumber(), //imageSet, distortions.fittingStrategy.distortionCalibrationData.gIP[numGridImage].getSetNumber(), //imageSet,
true); //filterBorder) true); //filterBorder)
hintTolerance=5.0; // TODO:set from configurable parameter hintTolerance=5.0; // TO DO:set from configurable parameter
} }
int rslt=matchSimulatedPattern.calculateDistortions( int rslt=matchSimulatedPattern.calculateDistortions(
...@@ -2095,14 +2095,17 @@ public class EyesisAberrations { ...@@ -2095,14 +2095,17 @@ public class EyesisAberrations {
PSFParameters psfParameters, PSFParameters psfParameters,
boolean [] correlationSizesUsed boolean [] correlationSizesUsed
){ ){
int numDifferentFFT=0; int [] corrSizes={};
for (int i=0;i<correlationSizesUsed.length;i++) if (correlationSizesUsed[i]) { if (correlationSizesUsed!=null) {
numDifferentFFT++; int numDifferentFFT=0;
} for (int i=0;i<correlationSizesUsed.length;i++) if (correlationSizesUsed[i]) {
int [] corrSizes=new int [numDifferentFFT]; numDifferentFFT++;
int index=0; }
for (int i=0;i<correlationSizesUsed.length;i++) if (correlationSizesUsed[i]) { corrSizes=new int [numDifferentFFT];
corrSizes[index++]=1<<i; int index=0;
for (int i=0;i<correlationSizesUsed.length;i++) if (correlationSizesUsed[i]) {
corrSizes[index++]=1<<i;
}
} }
ImagePlus impPsf = new ImagePlus(path, stack); ImagePlus impPsf = new ImagePlus(path, stack);
......
...@@ -7013,15 +7013,25 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7013,15 +7013,25 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
grid[v-minV][u-minU]=xy; grid[v-minV][u-minU]=xy;
} }
int numNewDefined=0; int numNewDefined=0;
// System.out.println("this.PATTERN_GRID.length="+this.PATTERN_GRID.length+"this.PATTERN_GRID[0.length="+this.PATTERN_GRID[0].length);
// System.out.println("this.targetUV.length="+this.targetUV.length+"this.targetUV[0.length="+this.targetUV[0].length);
for (int v=0;v<this.PATTERN_GRID.length;v++) for (int u=0;u<this.PATTERN_GRID[v].length;u++) { for (int v=0;v<this.PATTERN_GRID.length;v++) for (int u=0;u<this.PATTERN_GRID[v].length;u++) {
double [][] cell=this.PATTERN_GRID[v][u]; double [][] cell=this.PATTERN_GRID[v][u];
if ((cell !=null) && (cell.length>0) &&(cell[0] !=null) && (cell[0].length>1)){ if ((cell !=null) && (cell.length>0) &&(cell[0] !=null) && (cell[0].length>1)){
cell[0][0]=grid[this.targetUV[v][u][1]+minV][this.targetUV[v][u][0]+minU][0]; // System.out.print("v="+v+" u="+u);
cell[0][1]=grid[this.targetUV[v][u][1]+minV][this.targetUV[v][u][0]+minU][1]; int tu=this.targetUV[v][u][0]-minU;
if (Double.isNaN(cell[0][0]) || Double.isNaN(cell[0][1])){ int tv=this.targetUV[v][u][1]-minV;
this.PATTERN_GRID[v][u]=null; // make it undefined // System.out.println(" tv="+tv+" tu="+tu);
if ((tu>=0) && (tv>=0) && (tv<grid.length) && (tu<grid[tv].length) && (grid[tv][tu]!=null)) {
cell[0][0]=grid[tv][tu][0]; // -81 -.-1
cell[0][1]=grid[tv][tu][1];
if (Double.isNaN(cell[0][0]) || Double.isNaN(cell[0][1])){
this.PATTERN_GRID[v][u]=null; // make it undefined
} else {
numNewDefined++;
}
} else { } else {
numNewDefined++; this.PATTERN_GRID[v][u]=null; // make it undefined
} }
} }
} }
...@@ -7294,7 +7304,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7294,7 +7304,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
} }
// Now remove pointers that are not on white cells // Now remove pointers that are not on white cells
if (laserPointer.whiteOnly){ if ((laserPointer!=null) && laserPointer.whiteOnly){
int numBad=0; int numBad=0;
for (int i=0;i<uv.length;i++) if (uv[i]!=null) { for (int i=0;i<uv.length;i++) if (uv[i]!=null) {
// Verify that laser spots are on the white cells (sum of uv is even) // Verify that laser spots are on the white cells (sum of uv is even)
...@@ -7364,7 +7374,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7364,7 +7374,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
for (int i=0;i<uv.length;i++) if (uv[i]!=null) for (int j=i+1;j<uv.length;j++) if (uv[j]!=null) { for (int i=0;i<uv.length;i++) if (uv[i]!=null) for (int j=i+1;j<uv.length;j++) if (uv[j]!=null) {
pairMatch=false; pairMatch=false;
allMatch=false; allMatch=false;
diffUVTable[0]=(int) Math.round(laserPointer.laserUVMap[j][0]-laserPointer.laserUVMap[i][0]); diffUVTable[0]=(int) Math.round(laserPointer.laserUVMap[j][0]-laserPointer.laserUVMap[i][0]); // should not get here if uv is {}
diffUVTable[1]=(int) Math.round(laserPointer.laserUVMap[j][1]-laserPointer.laserUVMap[i][1]); diffUVTable[1]=(int) Math.round(laserPointer.laserUVMap[j][1]-laserPointer.laserUVMap[i][1]);
diffUVMeas[0]= (int) Math.round(uv[j][0]-uv[i][0]); diffUVMeas[0]= (int) Math.round(uv[j][0]-uv[i][0]);
diffUVMeas[1]= (int) Math.round(uv[j][1]-uv[i][1]); diffUVMeas[1]= (int) Math.round(uv[j][1]-uv[i][1]);
...@@ -7450,7 +7460,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7450,7 +7460,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
} }
} }
//TODO: here at least some rotations match all points. If there ere more than two - try to use closest to the default/previous //TODO: here at least some rotations match all points. If there ere more than two - try to use closest to the default/previous
int rotation=flipsToRot(laserPointer.swapUV,laserPointer.flipU,laserPointer.flipV); int rotation=(laserPointer!=null)?(flipsToRot(laserPointer.swapUV,laserPointer.flipU,laserPointer.flipV)):0;
if (!possibleRotations[rotation]) { // current rotation value defined by laserPointer.{swapUV,flipU,flipV} does not match if (!possibleRotations[rotation]) { // current rotation value defined by laserPointer.{swapUV,flipU,flipV} does not match
// find a new one (first - without mirroring) // find a new one (first - without mirroring)
for (int i=0; i<8;i++) if (possibleRotations[(((rotation ^ i) & 4)) | ((rotation+i) & 3)]) { for (int i=0; i<8;i++) if (possibleRotations[(((rotation ^ i) & 4)) | ((rotation+i) & 3)]) {
...@@ -7466,12 +7476,14 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7466,12 +7476,14 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
} }
} }
// now rotation is the correct one, update laserPointer.{swapUV,flipU,flipV}; // now rotation is the correct one, update laserPointer.{swapUV,flipU,flipV};
laserPointer.swapUV=rotToFlips(rotation)[0]; if (laserPointer!=null){
laserPointer.flipU =rotToFlips(rotation)[1]; laserPointer.swapUV=rotToFlips(rotation)[0];
laserPointer.flipV =rotToFlips(rotation)[2]; laserPointer.flipU =rotToFlips(rotation)[1];
laserPointer.flipV =rotToFlips(rotation)[2];
}
//calculate shift //calculate shift
int [] uvShift=dfltShifts[rotation].clone(); //{0,0}; int [] uvShift=dfltShifts[rotation].clone(); //{0,0};
for (int i=0;i<uv.length;i++) if (uv[i]!=null) { for (int i=0;i<uv.length;i++) if (uv[i]!=null) { // laserPointer -> uv=={}
uvShift[0]=(int) Math.round(uv[i][0]- uvShift[0]=(int) Math.round(uv[i][0]-
(rotations[rotation][0][0]*laserPointer.laserUVMap[i][0]+ (rotations[rotation][0][0]*laserPointer.laserUVMap[i][0]+
rotations[rotation][0][1]*laserPointer.laserUVMap[i][1])); rotations[rotation][0][1]*laserPointer.laserUVMap[i][1]));
...@@ -7480,6 +7492,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7480,6 +7492,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
rotations[rotation][1][1]*laserPointer.laserUVMap[i][1])); rotations[rotation][1][1]*laserPointer.laserUVMap[i][1]));
break; break;
} }
// Hinted shift will only be used if no laser pointers are available, otherwise - only verify/warn // Hinted shift will only be used if no laser pointers are available, otherwise - only verify/warn
if (hintTranslateUV!=null) { if (hintTranslateUV!=null) {
// if ((uv.length==0) || (numPointesLeft==0)){ // if ((uv.length==0) || (numPointesLeft==0)){
...@@ -7549,7 +7562,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1]) ...@@ -7549,7 +7562,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
int numBad=0; int numBad=0;
double [] distUV=new double[2]; double [] distUV=new double[2];
double dist; double dist;
for (int i=0;i<uv.length;i++) if (uv[i]!=null) { for (int i=0;i<uv.length;i++) if (uv[i]!=null) { //laserPointer == null > uv={}
// Verify that laser spots are inside specified distance from the cell centers // Verify that laser spots are inside specified distance from the cell centers
distUV[0]=reReMap[0][0]*uv[i][0]+reReMap[0][1]*uv[i][1]+reReMap[0][2]-laserPointer.laserUVMap[i][0]; distUV[0]=reReMap[0][0]*uv[i][0]+reReMap[0][1]*uv[i][1]+reReMap[0][2]-laserPointer.laserUVMap[i][0];
distUV[1]=reReMap[1][0]*uv[i][0]+reReMap[1][1]*uv[i][1]+reReMap[1][2]-laserPointer.laserUVMap[i][1]; distUV[1]=reReMap[1][0]*uv[i][0]+reReMap[1][1]*uv[i][1]+reReMap[1][2]-laserPointer.laserUVMap[i][1];
......
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