Commit 9d5dd318 authored by Andrey Filippov's avatar Andrey Filippov

refactoring + fixing sensor correction for different resolutions in the

same system
parent 5e90425c
...@@ -1555,6 +1555,16 @@ import ij.text.TextWindow; ...@@ -1555,6 +1555,16 @@ import ij.text.TextWindow;
sb.append("Lens Distortion Model\t"); sb.append("Lens Distortion Model\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]); for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]);
sb.append("\n"); sb.append("\n");
sb.append("Sensor width\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+eyesisCameraParameters.getSensorWidth(i));
sb.append("\n");
sb.append("Sensor height\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+eyesisCameraParameters.getSensorHeight(i));
sb.append("\n");
double [][] cameraPars=new double [numSubCameras][]; double [][] cameraPars=new double [numSubCameras][];
for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i); for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i);
...@@ -1626,6 +1636,15 @@ import ij.text.TextWindow; ...@@ -1626,6 +1636,15 @@ import ij.text.TextWindow;
// sb.append("Lens Distortion Model\t"); // sb.append("Lens Distortion Model\t");
// for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]); // for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]);
// sb.append("\n"); // sb.append("\n");
sb.append("Sensor width\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+eyesisCameraParameters.getSensorWidth(i));
sb.append("\n");
sb.append("Sensor height\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+eyesisCameraParameters.getSensorHeight(i));
sb.append("\n");
double [][] cameraPars=new double [numSubCameras][]; double [][] cameraPars=new double [numSubCameras][];
for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i); for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i);
...@@ -2396,7 +2415,7 @@ import ij.text.TextWindow; ...@@ -2396,7 +2415,7 @@ import ij.text.TextWindow;
IJ.showMessage(msg); IJ.showMessage(msg);
} }
for (int i=0; i<this.gIS.length;i++){ for (int i=0; i<this.gIS.length;i++){
if (selectedImages==null){ // if all selected - remove orientation if there are no enabled images (i.e. after removeOutlayers) if (selectedImages==null){ // if all selected - remove orientation if there are no enabled images (i.e. after removeOutliers)
this.gIS[i].goniometerAxial=Double.NaN; this.gIS[i].goniometerAxial=Double.NaN;
this.gIS[i].goniometerTilt= Double.NaN; this.gIS[i].goniometerTilt= Double.NaN;
this.gIS[i].orientationEstimated=true; this.gIS[i].orientationEstimated=true;
...@@ -3379,7 +3398,7 @@ import ij.text.TextWindow; ...@@ -3379,7 +3398,7 @@ import ij.text.TextWindow;
return true; return true;
} }
/** /**
* Sometimes "Process grid files" generates outlayers (by 0.1..5 pixels) TODO: find the bug * Sometimes "Process grid files" generates outliers (by 0.1..5 pixels) TODO: find the bug
* This program replaces the "bad" ones with predicted by 8 neighbors using 2-nd order interpolation * This program replaces the "bad" ones with predicted by 8 neighbors using 2-nd order interpolation
* @param fPixels stack of pX,pY,target-U,target-V,contrast (some bad pixels have low contrast), red,green,blue * @param fPixels stack of pX,pY,target-U,target-V,contrast (some bad pixels have low contrast), red,green,blue
* @param width grid width * @param width grid width
......
...@@ -4102,16 +4102,16 @@ List calibration ...@@ -4102,16 +4102,16 @@ List calibration
return true; return true;
} }
public boolean removeOutLayers( public boolean removeOutLiers(
int series, int series,
int numOutLayers, int numOutLiers,
boolean [] selectedChannels){ boolean [] selectedChannels){
int numSeries=fittingStrategy.getNumSeries(); int numSeries=fittingStrategy.getNumSeries();
boolean removeEmpty=false; boolean removeEmpty=false;
boolean recalculate=false; boolean recalculate=false;
boolean applyChannelFilter=false; boolean applyChannelFilter=false;
int filter=filterForAll; int filter=filterForAll;
if ((series<0) || (numOutLayers<0)) { if ((series<0) || (numOutLiers<0)) {
GenericDialog gd = new GenericDialog("Select series to process"); GenericDialog gd = new GenericDialog("Select series to process");
gd.addNumericField("Iteration number to start (0.."+(numSeries-1)+")", this.seriesNumber, 0); gd.addNumericField("Iteration number to start (0.."+(numSeries-1)+")", this.seriesNumber, 0);
if (selectedChannels != null) { if (selectedChannels != null) {
...@@ -4120,7 +4120,7 @@ List calibration ...@@ -4120,7 +4120,7 @@ List calibration
gd.addCheckbox("Filter by channel selection ("+s+")", applyChannelFilter); gd.addCheckbox("Filter by channel selection ("+s+")", applyChannelFilter);
} }
gd.addCheckbox("Recalculate parameters vector from selected strategy",recalculate); gd.addCheckbox("Recalculate parameters vector from selected strategy",recalculate);
gd.addNumericField("Number of outlayers to show", 10, 0); gd.addNumericField("Number of outliers to show", 10, 0);
gd.addCheckbox("Remove empty (rms==NaN) images", removeEmpty); gd.addCheckbox("Remove empty (rms==NaN) images", removeEmpty);
gd.addCheckbox("Ask filter (current filter="+filter+")", this.askFilter); gd.addCheckbox("Ask filter (current filter="+filter+")", this.askFilter);
gd.showDialog(); gd.showDialog();
...@@ -4128,7 +4128,7 @@ List calibration ...@@ -4128,7 +4128,7 @@ List calibration
this.seriesNumber= (int) gd.getNextNumber(); this.seriesNumber= (int) gd.getNextNumber();
if (selectedChannels != null) applyChannelFilter= gd.getNextBoolean(); if (selectedChannels != null) applyChannelFilter= gd.getNextBoolean();
recalculate= gd.getNextBoolean(); recalculate= gd.getNextBoolean();
numOutLayers= (int) gd.getNextNumber(); numOutLiers= (int) gd.getNextNumber();
removeEmpty= gd.getNextBoolean(); removeEmpty= gd.getNextBoolean();
this.askFilter= gd.getNextBoolean(); this.askFilter= gd.getNextBoolean();
if (this.askFilter) filter= selectFilter(filter); if (this.askFilter) filter= selectFilter(filter);
...@@ -4162,14 +4162,14 @@ List calibration ...@@ -4162,14 +4162,14 @@ List calibration
int index=0; int index=0;
for (int i=0;i<selectedImages.length;i++) if ( selectedImages[i] && !Double.isNaN(errors[i])) imgIndices[index++]=i; // OOB 2389 for (int i=0;i<selectedImages.length;i++) if ( selectedImages[i] && !Double.isNaN(errors[i])) imgIndices[index++]=i; // OOB 2389
if (numOutLayers>numSelectedNotNaNImages) numOutLayers=numSelectedNotNaNImages; if (numOutLiers>numSelectedNotNaNImages) numOutLiers=numSelectedNotNaNImages;
int [] indices=new int [numOutLayers]; int [] indices=new int [numOutLiers];
boolean [] availableImages=selectedImages.clone(); boolean [] availableImages=selectedImages.clone();
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])) availableImages[i]=false; for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])) availableImages[i]=false;
if ((this.debugLevel>0) && (numNaN>0)){ if ((this.debugLevel>0) && (numNaN>0)){
System.out.println("removeOutLayers(): Number of empty (rms=NaN) images="+numNaN+":"); System.out.println("removeOutLiers(): Number of empty (rms=NaN) images="+numNaN+":");
int n=0; int n=0;
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])){ for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])){
n++; n++;
...@@ -4187,8 +4187,8 @@ List calibration ...@@ -4187,8 +4187,8 @@ List calibration
} }
System.out.println("removeOutLayers(): availableImages.length="+availableImages.length+" numSelectedNotNaNImages="+numSelectedNotNaNImages); System.out.println("removeOutLiers(): availableImages.length="+availableImages.length+" numSelectedNotNaNImages="+numSelectedNotNaNImages);
for (int n=0;n<numOutLayers;n++){ for (int n=0;n<numOutLiers;n++){
double maxRMS=-1.0; double maxRMS=-1.0;
indices[n]=-1; indices[n]=-1;
for (int i=0;i<availableImages.length;i++)if (availableImages[i] && (Double.isNaN(errors[i]) || (errors[i]>maxRMS))){ // Double.NaN will be greater for (int i=0;i<availableImages.length;i++)if (availableImages[i] && (Double.isNaN(errors[i]) || (errors[i]>maxRMS))){ // Double.NaN will be greater
...@@ -4196,14 +4196,14 @@ List calibration ...@@ -4196,14 +4196,14 @@ List calibration
indices[n]=i; indices[n]=i;
} }
if (indices[n]<0){ if (indices[n]<0){
System.out.println("removeOutLayers(): indices["+n+"]="+indices[n]); System.out.println("removeOutLiers(): indices["+n+"]="+indices[n]);
continue; continue;
} }
availableImages[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1 availableImages[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1
} }
GenericDialog gd = new GenericDialog("Select images to remove (RMS="+IJ.d2s(rms,3)+")"); GenericDialog gd = new GenericDialog("Select images to remove (RMS="+IJ.d2s(rms,3)+")");
if (this.debugLevel>0) System.out.println("Listing "+numOutLayers+" worst images:"); if (this.debugLevel>0) System.out.println("Listing "+numOutLiers+" worst images:");
for (int n=0;n<indices.length;n++){ for (int n=0;n<indices.length;n++){
String msg=n+" ("+indices[n]+" / "+ this.fittingStrategy.distortionCalibrationData.gIP[indices[n]].getSetNumber()+"): "+ String msg=n+" ("+indices[n]+" / "+ this.fittingStrategy.distortionCalibrationData.gIP[indices[n]].getSetNumber()+"): "+
IJ.d2s(errors[indices[n]],3)+" "+ IJ.d2s(errors[indices[n]],3)+" "+
...@@ -4218,7 +4218,7 @@ List calibration ...@@ -4218,7 +4218,7 @@ List calibration
WindowTools.addScrollBars(gd); WindowTools.addScrollBars(gd);
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return false; if (gd.wasCanceled()) return false;
if (this.debugLevel>0) System.out.println("Removing outlayers:"); if (this.debugLevel>0) System.out.println("Removing outliers:");
for (int n=0;n<indices.length;n++){ for (int n=0;n<indices.length;n++){
if (gd.getNextBoolean()) { if (gd.getNextBoolean()) {
if (this.debugLevel>0) System.out.println(n+" :"+IJ.d2s(errors[indices[n]],3)+" "+this.fittingStrategy.distortionCalibrationData.gIP[indices[n]].path); if (this.debugLevel>0) System.out.println(n+" :"+IJ.d2s(errors[indices[n]],3)+" "+this.fittingStrategy.distortionCalibrationData.gIP[indices[n]].path);
...@@ -4230,18 +4230,18 @@ List calibration ...@@ -4230,18 +4230,18 @@ List calibration
return true; return true;
} }
public boolean removeOutLayerSets(int numOutLayers){ public boolean removeOutLierSets(int numOutLiers){
boolean removeEmptySets=false; boolean removeEmptySets=false;
if (numOutLayers<0) { if (numOutLiers<0) {
GenericDialog gd = new GenericDialog("Select sets to process"); GenericDialog gd = new GenericDialog("Select sets to process");
gd.addNumericField("Series number (<0 - all images)", -1, 0); gd.addNumericField("Series number (<0 - all images)", -1, 0);
gd.addNumericField("Number of outlayers to show", 5, 0); gd.addNumericField("Number of outliers to show", 5, 0);
gd.addCheckbox("Remove empty sets", removeEmptySets); gd.addCheckbox("Remove empty sets", removeEmptySets);
gd.addCheckbox("Ask for weight function filter", this.askFilter); gd.addCheckbox("Ask for weight function filter", this.askFilter);
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return false; if (gd.wasCanceled()) return false;
this.seriesNumber= (int) gd.getNextNumber(); this.seriesNumber= (int) gd.getNextNumber();
numOutLayers= (int) gd.getNextNumber(); numOutLiers= (int) gd.getNextNumber();
removeEmptySets= gd.getNextBoolean(); removeEmptySets= gd.getNextBoolean();
this.askFilter= gd.getNextBoolean(); this.askFilter= gd.getNextBoolean();
} }
...@@ -4291,12 +4291,12 @@ List calibration ...@@ -4291,12 +4291,12 @@ List calibration
// int index=0; // int index=0;
// for (int i=0;i<imageSets.length;i++) if ( selectedImages[i]) imgIndices[index++]=i; // for (int i=0;i<imageSets.length;i++) if ( selectedImages[i]) imgIndices[index++]=i;
if (numOutLayers>numSelectedSets) numOutLayers=numSelectedSets; if (numOutLiers>numSelectedSets) numOutLiers=numSelectedSets;
int [] indices=new int [numOutLayers]; int [] indices=new int [numOutLiers];
boolean [] availableSets= new boolean [imageSets.length]; boolean [] availableSets= new boolean [imageSets.length];
for (int i=0;i<imageSets.length;i++) availableSets[i]= !allNaNInSet[i]; //!Double.isNaN(rmsPerSet[i]); for (int i=0;i<imageSets.length;i++) availableSets[i]= !allNaNInSet[i]; //!Double.isNaN(rmsPerSet[i]);
if (removeEmptySets && (numNaN>0)){ //(this.debugLevel>0) if (removeEmptySets && (numNaN>0)){ //(this.debugLevel>0)
if (this.debugLevel>0) System.out.println("removeOutLayerSets(): Number of empty (rms=NaN) sets="+numNaN+":"); if (this.debugLevel>0) System.out.println("removeOutLierSets(): Number of empty (rms=NaN) sets="+numNaN+":");
// int n=0; // int n=0;
for (int setNum=0;setNum<imageSets.length;setNum++) if (!availableSets[setNum]){ for (int setNum=0;setNum<imageSets.length;setNum++) if (!availableSets[setNum]){
// n++; // n++;
...@@ -4311,8 +4311,8 @@ List calibration ...@@ -4311,8 +4311,8 @@ List calibration
} }
} }
System.out.println("removeOutLayerSets(): availableSets.length="+availableSets.length+" numSelectedSets="+numSelectedSets); System.out.println("removeOutLierSets(): availableSets.length="+availableSets.length+" numSelectedSets="+numSelectedSets);
for (int n=0;n<numOutLayers;n++){ for (int n=0;n<numOutLiers;n++){
double maxRMS=-1.0; double maxRMS=-1.0;
indices[n]=-1; indices[n]=-1;
for (int i=0;i<availableSets.length;i++)if (availableSets[i] && (rmsPerSet[i]>maxRMS)){ // NaN are already skipped for (int i=0;i<availableSets.length;i++)if (availableSets[i] && (rmsPerSet[i]>maxRMS)){ // NaN are already skipped
...@@ -4320,14 +4320,14 @@ List calibration ...@@ -4320,14 +4320,14 @@ List calibration
indices[n]=i; indices[n]=i;
} }
if (indices[n]<0){ if (indices[n]<0){
System.out.println("removeOutLayerSets(): indices["+n+"]="+indices[n]); System.out.println("removeOutLierSets(): indices["+n+"]="+indices[n]);
continue; continue;
} }
availableSets[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1 availableSets[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1
} }
GenericDialog gd = new GenericDialog("Select image Sets to remove (RMS="+IJ.d2s(rms,3)+")"); GenericDialog gd = new GenericDialog("Select image Sets to remove (RMS="+IJ.d2s(rms,3)+")");
if (this.debugLevel>0) System.out.println("Listing "+numOutLayers+" worst image sets"); if (this.debugLevel>0) System.out.println("Listing "+numOutLiers+" worst image sets");
for (int n=0;n<indices.length;n++){ for (int n=0;n<indices.length;n++){
int numSet=indices[n]; int numSet=indices[n];
double setWeight=this.fittingStrategy.distortionCalibrationData.gIS[numSet].setWeight; double setWeight=this.fittingStrategy.distortionCalibrationData.gIS[numSet].setWeight;
...@@ -4351,7 +4351,7 @@ List calibration ...@@ -4351,7 +4351,7 @@ List calibration
// this.fittingStrategy.setImageSelection(0, oldSelection); // restore original selection in series 0 // this.fittingStrategy.setImageSelection(0, oldSelection); // restore original selection in series 0
return false; return false;
} }
if (this.debugLevel>0) System.out.println("Removing outlayers:"); if (this.debugLevel>0) System.out.println("Removing outliers:");
for (int n=0;n<indices.length;n++){ for (int n=0;n<indices.length;n++){
if (gd.getNextBoolean()) { if (gd.getNextBoolean()) {
int numSet=indices[n]; int numSet=indices[n];
...@@ -4371,16 +4371,16 @@ List calibration ...@@ -4371,16 +4371,16 @@ List calibration
return true; return true;
} }
public boolean removeOutLayersJunk(int series, int numOutLayers){ public boolean removeOutLiersJunk(int series, int numOutLiers){
int numSeries=fittingStrategy.getNumSeries(); int numSeries=fittingStrategy.getNumSeries();
if ((series<0) || (numOutLayers<0)) { if ((series<0) || (numOutLiers<0)) {
GenericDialog gd = new GenericDialog("Select series to process"); GenericDialog gd = new GenericDialog("Select series to process");
gd.addNumericField("Iteration number to start (0.."+(numSeries-1)+")", this.seriesNumber, 0); gd.addNumericField("Iteration number to start (0.."+(numSeries-1)+")", this.seriesNumber, 0);
gd.addNumericField("Number of outlayers to show", 10, 0); gd.addNumericField("Number of outliers to show", 10, 0);
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return false; if (gd.wasCanceled()) return false;
this.seriesNumber= (int) gd.getNextNumber(); this.seriesNumber= (int) gd.getNextNumber();
numOutLayers= (int) gd.getNextNumber(); numOutLiers= (int) gd.getNextNumber();
} else { } else {
this.seriesNumber=series; this.seriesNumber=series;
} }
...@@ -4395,12 +4395,12 @@ List calibration ...@@ -4395,12 +4395,12 @@ List calibration
int index=0; int index=0;
for (int i=0;i<selectedImages.length;i++) if ( selectedImages[i]) imgIndices[index++]=i; for (int i=0;i<selectedImages.length;i++) if ( selectedImages[i]) imgIndices[index++]=i;
if (numOutLayers>numSelectedImages) numOutLayers=numSelectedImages; if (numOutLiers>numSelectedImages) numOutLiers=numSelectedImages;
int [] indices=new int [numOutLayers]; int [] indices=new int [numOutLiers];
int [] indicesSelected=new int [numOutLayers]; int [] indicesSelected=new int [numOutLiers];
boolean [] availableImages=new boolean[numSelectedImages]; boolean [] availableImages=new boolean[numSelectedImages];
for (int i=0;i<availableImages.length;i++)availableImages[i]=true; for (int i=0;i<availableImages.length;i++)availableImages[i]=true;
for (int n=0;n<numOutLayers;n++){ for (int n=0;n<numOutLiers;n++){
double maxRMS=0; double maxRMS=0;
indices[n]=-1; indices[n]=-1;
indicesSelected[n]=-1; indicesSelected[n]=-1;
......
...@@ -1585,7 +1585,7 @@ public class EyesisAberrations { ...@@ -1585,7 +1585,7 @@ public class EyesisAberrations {
if (thisDebugLevel>1) sdfa_instance.showArrays(weightsMasked, kWidth, kHeight, true, "weightsMasked"); if (thisDebugLevel>1) sdfa_instance.showArrays(weightsMasked, kWidth, kHeight, true, "weightsMasked");
double [][][] psfRadius=c[5]; // later may remove all other calculations for c[i]? double [][][] psfRadius=c[5]; // later may remove all other calculations for c[i]?
double [][][] pxfCenterX=c[0]; // some outlayer kernels have large x/y shift with normal radius - remove them too double [][][] pxfCenterX=c[0]; // some outlier kernels have large x/y shift with normal radius - remove them too
double [][][] pxfCenterY=c[1]; double [][][] pxfCenterY=c[1];
if (thisDebugLevel>1) { if (thisDebugLevel>1) {
for (int color=0;color<nChn;color++) sdfa_instance.showArrays(psfRadius[color], kWidth, kHeight, true, "psfRadius-"+color); for (int color=0;color<nChn;color++) sdfa_instance.showArrays(psfRadius[color], kWidth, kHeight, true, "psfRadius-"+color);
...@@ -1610,11 +1610,11 @@ public class EyesisAberrations { ...@@ -1610,11 +1610,11 @@ public class EyesisAberrations {
pxfCenterY[color][0][index]=0.0; pxfCenterY[color][0][index]=0.0;
} }
double sumWeights=0.0; double sumWeights=0.0;
for (int nFile=0;nFile<nFiles;nFile++) if ((weightsMasked[nFile+1][index]>0.0) && (weights[nFile+1][index]>0.0)){ // both, with outlayers removed for (int nFile=0;nFile<nFiles;nFile++) if ((weightsMasked[nFile+1][index]>0.0) && (weights[nFile+1][index]>0.0)){ // both, with outliers removed
for (int i=0;i<dirs.length;i++) { for (int i=0;i<dirs.length;i++) {
int yn=tileY+dirs[i][1]; int yn=tileY+dirs[i][1];
int xn=tileX+dirs[i][0]; int xn=tileX+dirs[i][0];
if ((yn>=0) && (yn<kHeight) && (xn>=0) && (xn<kWidth) && (weightsNotMasked[nFile+1][yn*kWidth+xn]>0.0)){ // including removed outlayers if ((yn>=0) && (yn<kHeight) && (xn>=0) && (xn<kWidth) && (weightsNotMasked[nFile+1][yn*kWidth+xn]>0.0)){ // including removed outliers
int indexNeib=xn+ kWidth*yn; int indexNeib=xn+ kWidth*yn;
double weight=weightsMasked[nFile+1][indexNeib]; double weight=weightsMasked[nFile+1][indexNeib];
if (multiFilePSF.sharpBonusPower>0) { if (multiFilePSF.sharpBonusPower>0) {
...@@ -1643,7 +1643,7 @@ public class EyesisAberrations { ...@@ -1643,7 +1643,7 @@ public class EyesisAberrations {
double [] diffs=new double[nFiles]; double [] diffs=new double[nFiles];
double [] diffsXY2=new double[nFiles]; double [] diffsXY2=new double[nFiles];
// for (int nFile=0;nFile<nFiles;nFile++) if ( weights[nFile+1][index]>0.0){ // here all , not just masked - why? // for (int nFile=0;nFile<nFiles;nFile++) if ( weights[nFile+1][index]>0.0){ // here all , not just masked - why?
for (int nFile=0;nFile<nFiles;nFile++) if ((weights[nFile+1][index]>0.0) && (weightsMasked[nFile+1][index]>0.0)){ //no outlayers, no masked - find worst for (int nFile=0;nFile<nFiles;nFile++) if ((weights[nFile+1][index]>0.0) && (weightsMasked[nFile+1][index]>0.0)){ //no outliers, no masked - find worst
diffs[nFile]=0; diffs[nFile]=0;
diffsXY2[nFile]=0; diffsXY2[nFile]=0;
for (int color=0;color<nChn;color++) { for (int color=0;color<nChn;color++) {
...@@ -1658,11 +1658,11 @@ public class EyesisAberrations { ...@@ -1658,11 +1658,11 @@ public class EyesisAberrations {
diffs[nFile]+=multiFilePSF.shiftToRadiusContrib*(Math.sqrt(diffXY2)/radiusRatio[color][0][index]); // now difference combines size and position diffs[nFile]+=multiFilePSF.shiftToRadiusContrib*(Math.sqrt(diffXY2)/radiusRatio[color][0][index]); // now difference combines size and position
} }
} }
// mask out outlayers // mask out outliers
//weightsMasked[0] //weightsMasked[0]
// TODO: when averaging, divide by r^2 to some power to give bonus low-radius samples. // TODO: when averaging, divide by r^2 to some power to give bonus low-radius samples.
// also - combine dX^2+dY2+dR^2 when selecting outlayers // also - combine dX^2+dY2+dR^2 when selecting outliers
if (thisDebugLevel>1) { if (thisDebugLevel>1) {
System.out.print("\n === "+tileY+":"+tileX); System.out.print("\n === "+tileY+":"+tileX);
for (int nFile=0;nFile<nFiles;nFile++) if ( weights[nFile+1][index]>0.0){ for (int nFile=0;nFile<nFiles;nFile++) if ( weights[nFile+1][index]>0.0){
...@@ -1740,7 +1740,7 @@ public class EyesisAberrations { ...@@ -1740,7 +1740,7 @@ public class EyesisAberrations {
// for each channel, each cell - compare radius calculated for neighbors (use masked weights) and the cell // 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? // TODO: Filter out outliers: Add bonus to cells surrounded by others?
// double [][][][] c= new double[numResults][nChn][nFiles+1][kLength]; // double [][][][] c= new double[numResults][nChn][nFiles+1][kLength];
...@@ -4466,7 +4466,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4466,7 +4466,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
public double shiftToRadiusContrib=1.0; // Center shift (in pixels) addition to the difference relative to radius difference (in pixels) public double shiftToRadiusContrib=1.0; // Center shift (in pixels) addition to the difference relative to radius difference (in pixels)
public double sharpBonusPower=2.0; // increase weight of the "sharp" kernels by dividing weight by radius to this power public double sharpBonusPower=2.0; // increase weight of the "sharp" kernels by dividing weight by radius to this power
public double maxFracDiscardWorse=0.1; // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger) public double maxFracDiscardWorse=0.1; // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger)
public double maxFracDiscardAll=0.5; // continue removing outlayers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse) public double maxFracDiscardAll=0.5; // continue removing outliers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse)
public double internalBonus=1.0; // cell having 8 around will "seem" twice better than having none (radiusDiff* twice higher) public double internalBonus=1.0; // cell having 8 around will "seem" twice better than having none (radiusDiff* twice higher)
public double validateThreshold; // fraction of full PSF "energy" public double validateThreshold; // fraction of full PSF "energy"
public boolean validateShowEllipse; // show ellipse parameters of partial PSF arrays public boolean validateShowEllipse; // show ellipse parameters of partial PSF arrays
...@@ -4480,7 +4480,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4480,7 +4480,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
double shiftToRadiusContrib, // Center shift (in pixels) addition to the difference relative to radius difference (in pixels) double shiftToRadiusContrib, // Center shift (in pixels) addition to the difference relative to radius difference (in pixels)
double sharpBonusPower, // increase weight of the "sharp" kernels by dividing weight by radius to this power double sharpBonusPower, // increase weight of the "sharp" kernels by dividing weight by radius to this power
double maxFracDiscardWorse, // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger) double maxFracDiscardWorse, // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger)
double maxFracDiscardAll, // continue removing outlayers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse) double maxFracDiscardAll, // continue removing outliers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse)
double internalBonus, double internalBonus,
double validateThreshold, double validateThreshold,
boolean validateShowEllipse, boolean validateShowEllipse,
...@@ -4494,7 +4494,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //*********************************** ...@@ -4494,7 +4494,7 @@ if (globalDebugLevel>2)globalDebugLevel=0; //***********************************
this.shiftToRadiusContrib=shiftToRadiusContrib; // Center shift (in pixels) addition to the difference relative to radius difference (in pixels) this.shiftToRadiusContrib=shiftToRadiusContrib; // Center shift (in pixels) addition to the difference relative to radius difference (in pixels)
this.sharpBonusPower=sharpBonusPower; // increase weight of the "sharp" kernels by dividing weight by radius to this power this.sharpBonusPower=sharpBonusPower; // increase weight of the "sharp" kernels by dividing weight by radius to this power
this.maxFracDiscardWorse=maxFracDiscardWorse; // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger) this.maxFracDiscardWorse=maxFracDiscardWorse; // discard up to this fraction of samples that have larger radius (i.e. falling on the target seam that may only make PSF larger)
this.maxFracDiscardAll=maxFracDiscardAll; // continue removing outlayers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse) this.maxFracDiscardAll=maxFracDiscardAll; // continue removing outliers (combined radius and shift), removing not more that this fraction (including maxFracDiscardWorse)
this.internalBonus=internalBonus; this.internalBonus=internalBonus;
this.validateThreshold=validateThreshold; this.validateThreshold=validateThreshold;
this.validateShowEllipse=validateShowEllipse; this.validateShowEllipse=validateShowEllipse;
......
...@@ -960,8 +960,12 @@ import ij.gui.GenericDialog; ...@@ -960,8 +960,12 @@ import ij.gui.GenericDialog;
gd.addNumericField("Channel "+numSubCam+" default weight", subCam.channelWeightDefault, 5,8,""); gd.addNumericField("Channel "+numSubCam+" default weight", subCam.channelWeightDefault, 5,8,"");
} }
if (this.numStations>1) gd.addMessage("--- Station number "+numStation+" ---"); if (this.numStations>1) gd.addMessage("--- Station number "+numStation+" ---");
gd.addNumericField("Subcamera lens distortion model", subCam.lensDistortionModel, 5,0,""); gd.addNumericField("Subcamera lens distortion model", subCam.lensDistortionModel, 8,0,"");
gd.addCheckbox ("Enable matching w/o laser pointers", subCam.enableNoLaser); gd.addCheckbox ("Enable matching w/o laser pointers", subCam.enableNoLaser);
if (numStation == 0) {
gd.addNumericField("Image sensor width", this.getSensorWidth (numSubCam), 0,4,"pix");
gd.addNumericField("Image sensor height", this.getSensorHeight(numSubCam), 0,4,"pix");
}
if (subCam.cartesian) { if (subCam.cartesian) {
gd.addNumericField("Subcamera right from the axis", subCam.right, 5,9,"mm"); gd.addNumericField("Subcamera right from the axis", subCam.right, 5,9,"mm");
gd.addNumericField("Subcamera forward from the rotation axis", subCam.forward, 5,9,"mm"); gd.addNumericField("Subcamera forward from the rotation axis", subCam.forward, 5,9,"mm");
...@@ -1044,6 +1048,10 @@ import ij.gui.GenericDialog; ...@@ -1044,6 +1048,10 @@ import ij.gui.GenericDialog;
subCam.channelWeightDefault= channelWeightDefault; // assign to all stations subCam.channelWeightDefault= channelWeightDefault; // assign to all stations
subCam.lensDistortionModel= (int) gd.getNextNumber(); subCam.lensDistortionModel= (int) gd.getNextNumber();
subCam.enableNoLaser = gd.getNextBoolean(); subCam.enableNoLaser = gd.getNextBoolean();
if (numStation == 0) {
this.setSensorWidth (numSubCam,(int) gd.getNextNumber());
this.setSensorHeight(numSubCam,(int) gd.getNextNumber());
}
if (subCam.cartesian) { if (subCam.cartesian) {
subCam.right= gd.getNextNumber(); subCam.right= gd.getNextNumber();
subCam.forward= gd.getNextNumber(); subCam.forward= gd.getNextNumber();
...@@ -1106,6 +1114,9 @@ import ij.gui.GenericDialog; ...@@ -1106,6 +1114,9 @@ import ij.gui.GenericDialog;
for (int numStation=1;numStation<this.numStations;numStation++) { for (int numStation=1;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam]; EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) { if (subCam!=null) {
this.setSensorWidth (numSubCam,first.getSensorWidth ());
this.setSensorHeight(numSubCam,first.getSensorHeight ());
if (subCam.cartesian) { if (subCam.cartesian) {
subCam.right= first.right; subCam.right= first.right;
subCam.forward= first.forward; subCam.forward= first.forward;
...@@ -1298,22 +1309,39 @@ import ij.gui.GenericDialog; ...@@ -1298,22 +1309,39 @@ import ij.gui.GenericDialog;
public int getGoniometerHorizontalIndex(){return 6;} public int getGoniometerHorizontalIndex(){return 6;}
public int getGoniometerAxialIndex(){return 7;} public int getGoniometerAxialIndex(){return 7;}
public int getInterAxisAngleIndex(){return 9;} public int getInterAxisAngleIndex(){return 9;}
@Deprecated
public int getSensorWidth() { return this.defaultSensorWidth;} public int getSensorWidth() { return this.defaultSensorWidth;}
@Deprecated
public int getSensorHeight() { return this.defaultSensorHeight;} public int getSensorHeight() { return this.defaultSensorHeight;}
@Deprecated
public int getDecimateMasks() { return this.defaultDecimateMasks;} public int getDecimateMasks() { return this.defaultDecimateMasks;}
@Deprecated
public void setSensorWidth(int v) { this.defaultSensorWidth = v;} public void setSensorWidth(int v) { this.defaultSensorWidth = v;}
@Deprecated
public void setSensorHeight(int v) { this.defaultSensorHeight = v;} public void setSensorHeight(int v) { this.defaultSensorHeight = v;}
@Deprecated
public void setDecimateMasks(int v) { this.defaultDecimateMasks = v;} public void setDecimateMasks(int v) { this.defaultDecimateMasks = v;}
public int getSensorWidth(int subCam) { return this.eyesisSubCameras[0][subCam].sensorWidth;} // for the future? different sensors public int getSensorWidth(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorWidth();} // for the future? different sensors
public int getSensorHeight(int subCam) { return this.eyesisSubCameras[0][subCam].sensorHeight;}// for the future? different sensors public int getSensorHeight(int subCam) { return this.eyesisSubCameras[0][subCam].getSensorHeight();}// for the future? different sensors
public int getDecimateMasks(int subCam) { return this.eyesisSubCameras[0][subCam].decimateMasks;}// for the future? different sensors public int getDecimateMasks(int subCam) { return this.eyesisSubCameras[0][subCam].getDecimateMasks();}// for the future? different sensors
public void setSensorWidth(int subCam, int v) { this.eyesisSubCameras[0][subCam].sensorWidth = v;} public void setSensorWidth(int subCam, int v) {
public void setSensorHeight(int subCam, int v) { this.eyesisSubCameras[0][subCam].sensorHeight = v;} for (int station = 0; station < this.eyesisSubCameras.length; station++) {
public void setDecimateMasks(int subCam, int v) { this.eyesisSubCameras[0][subCam].decimateMasks = v;} this.eyesisSubCameras[station][subCam].setSensorWidth(v);
}
}
public void setSensorHeight(int subCam, int v) {
for (int station = 0; station < this.eyesisSubCameras.length; station++) {
this.eyesisSubCameras[station][subCam].setSensorHeight(v);
}
}
public void setDecimateMasks(int subCam, int v) {
for (int station = 0; station < this.eyesisSubCameras.length; station++) {
this.eyesisSubCameras[station][subCam].setDecimateMasks(v);
}
}
public int [] getSensorWidths() { public int [] getSensorWidths() {
int [] v = new int [eyesisSubCameras[0].length]; int [] v = new int [eyesisSubCameras[0].length];
......
...@@ -2863,10 +2863,10 @@ public class EyesisCorrectionParameters { ...@@ -2863,10 +2863,10 @@ public class EyesisCorrectionParameters {
public double stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above public double stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
public double outlayerStrength = 0.3; // Outlayer tiles weaker than this may be replaced from neighbors public double outlierStrength = 0.3; // Outlier tiles weaker than this may be replaced from neighbors
public double outlayerDiff = 0.4; // Replace weak outlayer tiles that do not have neighbors within this disparity difference public double outlierDiff = 0.4; // Replace weak outlier tiles that do not have neighbors within this disparity difference
public double outlayerDiffPos = 1.0; // Replace weak outlayer tiles that have higher disparity than weighted average public double outlierDiffPos = 1.0; // Replace weak outlier tiles that have higher disparity than weighted average
public double outlayerDiffNeg = 0.4; // Replace weak outlayer tiles that have lower disparity than weighted average public double outlierDiffNeg = 0.4; // Replace weak outlier tiles that have lower disparity than weighted average
// TODO: Make refine skip if already good? // TODO: Make refine skip if already good?
public boolean combine_refine = true; // combine with all previous after refine pass public boolean combine_refine = true; // combine with all previous after refine pass
...@@ -3582,10 +3582,10 @@ public class EyesisCorrectionParameters { ...@@ -3582,10 +3582,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"stHighMix", this.stHighMix +""); properties.setProperty(prefix+"stHighMix", this.stHighMix +"");
properties.setProperty(prefix+"outlayerStrength", this.outlayerStrength +""); properties.setProperty(prefix+"outlierStrength", this.outlierStrength +"");
properties.setProperty(prefix+"outlayerDiff", this.outlayerDiff +""); properties.setProperty(prefix+"outlierDiff", this.outlierDiff +"");
properties.setProperty(prefix+"outlayerDiffPos", this.outlayerDiffPos +""); properties.setProperty(prefix+"outlierDiffPos", this.outlierDiffPos +"");
properties.setProperty(prefix+"outlayerDiffNeg", this.outlayerDiffNeg +""); properties.setProperty(prefix+"outlierDiffNeg", this.outlierDiffNeg +"");
properties.setProperty(prefix+"combine_refine", this.combine_refine+"");