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;
sb.append("Lens Distortion Model\t");
for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]);
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][];
for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i);
......@@ -1626,6 +1636,15 @@ import ij.text.TextWindow;
// sb.append("Lens Distortion Model\t");
// for (int i=0;i<numSubCameras;i++) sb.append("\t"+lensDistortionModels[i]);
// 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][];
for (int i=0;i<numSubCameras;i++) cameraPars[i]=eyesisCameraParameters.getParametersVector(stationNumber,i);
......@@ -2396,7 +2415,7 @@ import ij.text.TextWindow;
IJ.showMessage(msg);
}
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].goniometerTilt= Double.NaN;
this.gIS[i].orientationEstimated=true;
......@@ -3379,7 +3398,7 @@ import ij.text.TextWindow;
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
* @param fPixels stack of pX,pY,target-U,target-V,contrast (some bad pixels have low contrast), red,green,blue
* @param width grid width
......
......@@ -4102,16 +4102,16 @@ List calibration
return true;
}
public boolean removeOutLayers(
public boolean removeOutLiers(
int series,
int numOutLayers,
int numOutLiers,
boolean [] selectedChannels){
int numSeries=fittingStrategy.getNumSeries();
boolean removeEmpty=false;
boolean recalculate=false;
boolean applyChannelFilter=false;
int filter=filterForAll;
if ((series<0) || (numOutLayers<0)) {
if ((series<0) || (numOutLiers<0)) {
GenericDialog gd = new GenericDialog("Select series to process");
gd.addNumericField("Iteration number to start (0.."+(numSeries-1)+")", this.seriesNumber, 0);
if (selectedChannels != null) {
......@@ -4120,7 +4120,7 @@ List calibration
gd.addCheckbox("Filter by channel selection ("+s+")", applyChannelFilter);
}
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("Ask filter (current filter="+filter+")", this.askFilter);
gd.showDialog();
......@@ -4128,7 +4128,7 @@ List calibration
this.seriesNumber= (int) gd.getNextNumber();
if (selectedChannels != null) applyChannelFilter= gd.getNextBoolean();
recalculate= gd.getNextBoolean();
numOutLayers= (int) gd.getNextNumber();
numOutLiers= (int) gd.getNextNumber();
removeEmpty= gd.getNextBoolean();
this.askFilter= gd.getNextBoolean();
if (this.askFilter) filter= selectFilter(filter);
......@@ -4162,14 +4162,14 @@ List calibration
int index=0;
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;
int [] indices=new int [numOutLayers];
if (numOutLiers>numSelectedNotNaNImages) numOutLiers=numSelectedNotNaNImages;
int [] indices=new int [numOutLiers];
boolean [] availableImages=selectedImages.clone();
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])) availableImages[i]=false;
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;
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i] && Double.isNaN(errors[i])){
n++;
......@@ -4187,8 +4187,8 @@ List calibration
}
System.out.println("removeOutLayers(): availableImages.length="+availableImages.length+" numSelectedNotNaNImages="+numSelectedNotNaNImages);
for (int n=0;n<numOutLayers;n++){
System.out.println("removeOutLiers(): availableImages.length="+availableImages.length+" numSelectedNotNaNImages="+numSelectedNotNaNImages);
for (int n=0;n<numOutLiers;n++){
double maxRMS=-1.0;
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
......@@ -4196,14 +4196,14 @@ List calibration
indices[n]=i;
}
if (indices[n]<0){
System.out.println("removeOutLayers(): indices["+n+"]="+indices[n]);
System.out.println("removeOutLiers(): indices["+n+"]="+indices[n]);
continue;
}
availableImages[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1
}
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++){
String msg=n+" ("+indices[n]+" / "+ this.fittingStrategy.distortionCalibrationData.gIP[indices[n]].getSetNumber()+"): "+
IJ.d2s(errors[indices[n]],3)+" "+
......@@ -4218,7 +4218,7 @@ List calibration
WindowTools.addScrollBars(gd);
gd.showDialog();
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++){
if (gd.getNextBoolean()) {
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
return true;
}
public boolean removeOutLayerSets(int numOutLayers){
public boolean removeOutLierSets(int numOutLiers){
boolean removeEmptySets=false;
if (numOutLayers<0) {
if (numOutLiers<0) {
GenericDialog gd = new GenericDialog("Select sets to process");
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("Ask for weight function filter", this.askFilter);
gd.showDialog();
if (gd.wasCanceled()) return false;
this.seriesNumber= (int) gd.getNextNumber();
numOutLayers= (int) gd.getNextNumber();
numOutLiers= (int) gd.getNextNumber();
removeEmptySets= gd.getNextBoolean();
this.askFilter= gd.getNextBoolean();
}
......@@ -4291,12 +4291,12 @@ List calibration
// int index=0;
// for (int i=0;i<imageSets.length;i++) if ( selectedImages[i]) imgIndices[index++]=i;
if (numOutLayers>numSelectedSets) numOutLayers=numSelectedSets;
int [] indices=new int [numOutLayers];
if (numOutLiers>numSelectedSets) numOutLiers=numSelectedSets;
int [] indices=new int [numOutLiers];
boolean [] availableSets= new boolean [imageSets.length];
for (int i=0;i<imageSets.length;i++) availableSets[i]= !allNaNInSet[i]; //!Double.isNaN(rmsPerSet[i]);
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;
for (int setNum=0;setNum<imageSets.length;setNum++) if (!availableSets[setNum]){
// n++;
......@@ -4311,8 +4311,8 @@ List calibration
}
}
System.out.println("removeOutLayerSets(): availableSets.length="+availableSets.length+" numSelectedSets="+numSelectedSets);
for (int n=0;n<numOutLayers;n++){
System.out.println("removeOutLierSets(): availableSets.length="+availableSets.length+" numSelectedSets="+numSelectedSets);
for (int n=0;n<numOutLiers;n++){
double maxRMS=-1.0;
indices[n]=-1;
for (int i=0;i<availableSets.length;i++)if (availableSets[i] && (rmsPerSet[i]>maxRMS)){ // NaN are already skipped
......@@ -4320,14 +4320,14 @@ List calibration
indices[n]=i;
}
if (indices[n]<0){
System.out.println("removeOutLayerSets(): indices["+n+"]="+indices[n]);
System.out.println("removeOutLierSets(): indices["+n+"]="+indices[n]);
continue;
}
availableSets[indices[n]]=false; // java.lang.ArrayIndexOutOfBoundsException: -1
}
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++){
int numSet=indices[n];
double setWeight=this.fittingStrategy.distortionCalibrationData.gIS[numSet].setWeight;
......@@ -4351,7 +4351,7 @@ List calibration
// this.fittingStrategy.setImageSelection(0, oldSelection); // restore original selection in series 0
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++){
if (gd.getNextBoolean()) {
int numSet=indices[n];
......@@ -4371,16 +4371,16 @@ List calibration
return true;
}
public boolean removeOutLayersJunk(int series, int numOutLayers){
public boolean removeOutLiersJunk(int series, int numOutLiers){
int numSeries=fittingStrategy.getNumSeries();
if ((series<0) || (numOutLayers<0)) {
if ((series<0) || (numOutLiers<0)) {
GenericDialog gd = new GenericDialog("Select series to process");
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();
if (gd.wasCanceled()) return false;
this.seriesNumber= (int) gd.getNextNumber();
numOutLayers= (int) gd.getNextNumber();
numOutLiers= (int) gd.getNextNumber();
} else {
this.seriesNumber=series;
}
......@@ -4395,12 +4395,12 @@ List calibration
int index=0;
for (int i=0;i<selectedImages.length;i++) if ( selectedImages[i]) imgIndices[index++]=i;
if (numOutLayers>numSelectedImages) numOutLayers=numSelectedImages;
int [] indices=new int [numOutLayers];
int [] indicesSelected=new int [numOutLayers];
if (numOutLiers>numSelectedImages) numOutLiers=numSelectedImages;
int [] indices=new int [numOutLiers];
int [] indicesSelected=new int [numOutLiers];
boolean [] availableImages=new boolean[numSelectedImages];
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;
indices[n]=-1;
indicesSelected[n]=-1;
......
......@@ -1585,7 +1585,7 @@ public class EyesisAberrations {
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 [][][] 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];
if (thisDebugLevel>1) {
for (int color=0;color<nChn;color++) sdfa_instance.showArrays(psfRadius[color], kWidth, kHeight, true, "psfRadius-"+color);
......@@ -1610,11 +1610,11 @@ public class EyesisAberrations {
pxfCenterY[color][0][index]=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++) {
int yn=tileY+dirs[i][1];
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;
double weight=weightsMasked[nFile+1][indexNeib];
if (multiFilePSF.sharpBonusPower>0) {
......@@ -1643,7 +1643,7 @@ public class EyesisAberrations {
double [] diffs=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) && (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;
diffsXY2[nFile]=0;
for (int color=0;color<nChn;color++) {
......@@ -1658,11 +1658,11 @@ public class EyesisAberrations {
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]
// 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) {
System.out.print("\n === "+tileY+":"+tileX);
for (int nFile=0;nFile<nFiles;nFile++) if ( weights[nFile+1][index]>0.0){
......@@ -1740,7 +1740,7 @@ public class EyesisAberrations {
// 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];
......@@ -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 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 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 validateThreshold; // fraction of full PSF "energy"
public boolean validateShowEllipse; // show ellipse parameters of partial PSF arrays
......@@ -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 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 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 validateThreshold,
boolean validateShowEllipse,
......@@ -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.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.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.validateThreshold=validateThreshold;
this.validateShowEllipse=validateShowEllipse;
......
......@@ -960,8 +960,12 @@ import ij.gui.GenericDialog;
gd.addNumericField("Channel "+numSubCam+" default weight", subCam.channelWeightDefault, 5,8,"");
}
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);
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) {
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");
......@@ -1044,6 +1048,10 @@ import ij.gui.GenericDialog;
subCam.channelWeightDefault= channelWeightDefault; // assign to all stations
subCam.lensDistortionModel= (int) gd.getNextNumber();
subCam.enableNoLaser = gd.getNextBoolean();
if (numStation == 0) {
this.setSensorWidth (numSubCam,(int) gd.getNextNumber());
this.setSensorHeight(numSubCam,(int) gd.getNextNumber());
}
if (subCam.cartesian) {
subCam.right= gd.getNextNumber();
subCam.forward= gd.getNextNumber();
......@@ -1106,6 +1114,9 @@ import ij.gui.GenericDialog;
for (int numStation=1;numStation<this.numStations;numStation++) {
EyesisSubCameraParameters subCam=this.eyesisSubCameras[numStation][numSubCam];
if (subCam!=null) {
this.setSensorWidth (numSubCam,first.getSensorWidth ());
this.setSensorHeight(numSubCam,first.getSensorHeight ());
if (subCam.cartesian) {
subCam.right= first.right;
subCam.forward= first.forward;
......@@ -1298,22 +1309,39 @@ import ij.gui.GenericDialog;
public int getGoniometerHorizontalIndex(){return 6;}
public int getGoniometerAxialIndex(){return 7;}
public int getInterAxisAngleIndex(){return 9;}
@Deprecated
public int getSensorWidth() { return this.defaultSensorWidth;}
@Deprecated
public int getSensorHeight() { return this.defaultSensorHeight;}
@Deprecated
public int getDecimateMasks() { return this.defaultDecimateMasks;}
@Deprecated
public void setSensorWidth(int v) { this.defaultSensorWidth = v;}
@Deprecated
public void setSensorHeight(int v) { this.defaultSensorHeight = v;}
@Deprecated
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 getSensorHeight(int subCam) { return this.eyesisSubCameras[0][subCam].sensorHeight;}// for the future? different sensors
public int getDecimateMasks(int subCam) { return this.eyesisSubCameras[0][subCam].decimateMasks;}// 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].getSensorHeight();}// 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 setSensorHeight(int subCam, int v) { this.eyesisSubCameras[0][subCam].sensorHeight = v;}
public void setDecimateMasks(int subCam, int v) { this.eyesisSubCameras[0][subCam].decimateMasks = v;}
public void setSensorWidth(int subCam, int v) {
for (int station = 0; station < this.eyesisSubCameras.length; station++) {
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() {
int [] v = new int [eyesisSubCameras[0].length];
......
......@@ -2863,10 +2863,10 @@ public class EyesisCorrectionParameters {
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 outlayerDiff = 0.4; // Replace weak outlayer 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 outlayerDiffNeg = 0.4; // Replace weak outlayer tiles that have lower disparity than weighted average
public double outlierStrength = 0.3; // Outlier tiles weaker than this may be replaced from neighbors
public double outlierDiff = 0.4; // Replace weak outlier tiles that do not have neighbors within this disparity difference
public double outlierDiffPos = 1.0; // Replace weak outlier tiles that have higher 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?
public boolean combine_refine = true; // combine with all previous after refine pass
......@@ -3582,10 +3582,10 @@ public class EyesisCorrectionParameters {
properties.setProperty(prefix+"stHighMix", this.stHighMix +"");
properties.setProperty(prefix+"outlayerStrength", this.outlayerStrength +"");
properties.setProperty(prefix+"outlayerDiff", this.outlayerDiff +"");
properties.setProperty(prefix+"outlayerDiffPos", this.outlayerDiffPos +"");
properties.setProperty(prefix+"outlayerDiffNeg", this.outlayerDiffNeg +"");
properties.setProperty(prefix+"outlierStrength", this.outlierStrength +"");
properties.setProperty(prefix+"outlierDiff", this.outlierDiff +"");
properties.setProperty(prefix+"outlierDiffPos", this.outlierDiffPos +"");
properties.setProperty(prefix+"outlierDiffNeg", this.outlierDiffNeg +"");
properties.setProperty(prefix+"combine_refine", this.combine_refine+"");
......@@ -4282,10 +4282,17 @@ public class EyesisCorrectionParameters {
if (properties.getProperty(prefix+"stSmallDiff")!=null) this.stSmallDiff=Double.parseDouble(properties.getProperty(prefix+"stSmallDiff"));
if (properties.getProperty(prefix+"stHighMix")!=null) this.stHighMix=Double.parseDouble(properties.getProperty(prefix+"stHighMix"));
if (properties.getProperty(prefix+"outlayerStrength")!=null) this.outlayerStrength=Double.parseDouble(properties.getProperty(prefix+"outlayerStrength"));
if (properties.getProperty(prefix+"outlayerDiff")!=null) this.outlayerDiff=Double.parseDouble(properties.getProperty(prefix+"outlayerDiff"));
if (properties.getProperty(prefix+"outlayerDiffPos")!=null) this.outlayerDiffPos=Double.parseDouble(properties.getProperty(prefix+"outlayerDiffPos"));
if (properties.getProperty(prefix+"outlayerDiffNeg")!=null) this.outlayerDiffNeg=Double.parseDouble(properties.getProperty(prefix+"outlayerDiffNeg"));
// old wrong spelling
if (properties.getProperty(prefix+"outlayerStrength")!=null) this.outlierStrength=Double.parseDouble(properties.getProperty(prefix+"outlayerStrength"));
if (properties.getProperty(prefix+"outlayerDiff")!=null) this.outlierDiff=Double.parseDouble(properties.getProperty(prefix+"outlayerDiff"));
if (properties.getProperty(prefix+"outlayerDiffPos")!=null) this.outlierDiffPos=Double.parseDouble(properties.getProperty(prefix+"outlayerDiffPos"));
if (properties.getProperty(prefix+"outlayerDiffNeg")!=null) this.outlierDiffNeg=Double.parseDouble(properties.getProperty(prefix+"outlayerDiffNeg"));
if (properties.getProperty(prefix+"outlierStrength")!=null) this.outlierStrength=Double.parseDouble(properties.getProperty(prefix+"outlierStrength"));
if (properties.getProperty(prefix+"outlierDiff")!=null) this.outlierDiff=Double.parseDouble(properties.getProperty(prefix+"outlierDiff"));
if (properties.getProperty(prefix+"outlierDiffPos")!=null) this.outlierDiffPos=Double.parseDouble(properties.getProperty(prefix+"outlierDiffPos"));
if (properties.getProperty(prefix+"outlierDiffNeg")!=null) this.outlierDiffNeg=Double.parseDouble(properties.getProperty(prefix+"outlierDiffNeg"));
if (properties.getProperty(prefix+"combine_refine")!=null) this.combine_refine=Boolean.parseBoolean(properties.getProperty(prefix+"combine_refine"));
......@@ -5030,10 +5037,10 @@ public class EyesisCorrectionParameters {
gd.addNumericField("Consider merging initial planes if disparity difference below", this.stSmallDiff, 6);
gd.addNumericField("Consider merging initial planes if jumps between ratio above", this.stHighMix, 6);
gd.addNumericField("Outlier tiles weaker than this may be replaced from neighbors", this.outlayerStrength, 6);
gd.addNumericField("Replace weak outlier tiles that do not have neighbors within this disparity difference", this.outlayerDiff, 6);
gd.addNumericField("Replace weak outlier tiles that have higher disparity than weighted average", this.outlayerDiffPos, 6);
gd.addNumericField("Replace weak outlier tiles that have lower disparity than weighted average", this.outlayerDiffNeg, 6);
gd.addNumericField("Outlier tiles weaker than this may be replaced from neighbors", this.outlierStrength, 6);
gd.addNumericField("Replace weak outlier tiles that do not have neighbors within this disparity difference", this.outlierDiff, 6);
gd.addNumericField("Replace weak outlier tiles that have higher disparity than weighted average", this.outlierDiffPos, 6);
gd.addNumericField("Replace weak outlier tiles that have lower disparity than weighted average", this.outlierDiffNeg, 6);
gd.addCheckbox ("Combine with all previous after refine pass", this.combine_refine);
gd.addNumericField("Disregard weaker tiles when combining scans", this.combine_min_strength, 6);
......@@ -5792,10 +5799,10 @@ public class EyesisCorrectionParameters {
this.stSmallDiff= gd.getNextNumber();
this.stHighMix= gd.getNextNumber();
this.outlayerStrength= gd.getNextNumber();
this.outlayerDiff= gd.getNextNumber();
this.outlayerDiffPos= gd.getNextNumber();
this.outlayerDiffNeg= gd.getNextNumber();
this.outlierStrength= gd.getNextNumber();
this.outlierDiff= gd.getNextNumber();
this.outlierDiffPos= gd.getNextNumber();
this.outlierDiffNeg= gd.getNextNumber();
this.combine_refine= gd.getNextBoolean();
......
......@@ -370,4 +370,25 @@ import java.util.Properties;
return this.distortionRadius;
}
public void setSensorWidth(int v) {
this.sensorWidth = v;
}
public void setSensorHeight(int v) {
this.sensorHeight = v;
}
public void setDecimateMasks(int v) {
this.decimateMasks = v;
}
public int getSensorWidth() {
return this.sensorWidth;
}
public int getSensorHeight() {
return this.sensorHeight;
}
public int getDecimateMasks() {
return this.decimateMasks;
}
}
......@@ -510,7 +510,7 @@ public class EyesisCorrections {
if (this.defectsXY[srcChannel]==null){
System.out.println("No pixel defects info is available for channel "+srcChannel);
} else {
System.out.println("Extracted "+this.defectsXY[srcChannel].length+" pixel outlayers for channel "+srcChannel+
System.out.println("Extracted "+this.defectsXY[srcChannel].length+" pixel outliers for channel "+srcChannel+
" (x:y:difference");
int numInLine=8;
for (int i=0;i<this.defectsXY[srcChannel].length;i++){
......
......@@ -1919,7 +1919,7 @@ public class BiScan {
double rms = Double.NaN;
if (smpl_p == null) smpl_p = new double [smpl_len];
while (num_in_sample >= fin_samples) {
// fit plane to the selected and remove outlayers after each iteration
// fit plane to the selected and remove outliers after each iteration
disp_tilts = fitPlane(
smpl_radius, //int smpl_radius,
max_tilt, //double max_tilt,
......
......@@ -528,7 +528,7 @@ public class CLTPass3d{
final int tilesY = tileProcessor.getTilesY();
final int nTiles = tilesX*tilesY;
final boolean [] weakOutlayers = new boolean [nTiles];
final boolean [] weakOutliers = new boolean [nTiles];
int [] dirs8 = {-tilesX, -tilesX + 1, 1, tilesX +1, tilesX, tilesX - 1, -1, -tilesX - 1};
final int [] dirs = dirs8;
final double [] disparity = getDisparity(0);
......@@ -554,11 +554,11 @@ public class CLTPass3d{
double dbg_disparity_nTile = disparity[nTile];
double dbg_disparityFar = disparityFar;
double dbg_disparityNear = disparityNear;
boolean [] dbg_weakOutlayers = weakOutlayers;
boolean [] dbg_weakOutliers = weakOutliers;
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
if ((tileY > 0) && (tileY < (tilesY -1)) &&(tileX > 0) && (tileX < (tilesX -1))){ // disregard outer row/cols
weakOutlayers[nTile] = true;
weakOutliers[nTile] = true;
boolean hasNeighbors = false;
double sd = 0.0, sw = 0.0;
for (int dir = 0; dir< dirs.length; dir++){
......@@ -572,20 +572,20 @@ public class CLTPass3d{
sd += w * disparity[nTile1];
hasNeighbors = true;
if (Math.abs(disparity[nTile]-disparity[nTile1]) <= maxDiff){ // any outlier - will be false
weakOutlayers[nTile] = false;
weakOutliers[nTile] = false;
// break;
}
}
}
if (sw >= 0.0) {
sd /= sw;
if (disparity[nTile] < (sd - maxDiffNeg)) weakOutlayers[nTile] = true;
else if (disparity[nTile] > (sd + maxDiffPos)) weakOutlayers[nTile] = true;
if (disparity[nTile] < (sd - maxDiffNeg)) weakOutliers[nTile] = true;
else if (disparity[nTile] > (sd + maxDiffPos)) weakOutliers[nTile] = true;
}
if (disparity[nTile] < disparityFar) weakOutlayers[nTile] = true;
if (disparity[nTile] > disparityNear) weakOutlayers[nTile] = true;
if (disparity[nTile] < disparityFar) weakOutliers[nTile] = true;
if (disparity[nTile] > disparityNear) weakOutliers[nTile] = true;
if (!hasNeighbors) {
weakOutlayers[nTile] = false; // lone tile or NaN among NaNs
weakOutliers[nTile] = false; // lone tile or NaN among NaNs
}
}
}
......@@ -606,11 +606,11 @@ public class CLTPass3d{
if (nTile == dbg_nTile){
System.out.println("replaceWeakOutliers():2 nTile="+nTile);
}
if (weakOutlayers[nTile]) {
if (weakOutliers[nTile]) {
double sw = 0.0, sd = 0.0;
for (int dir = 0; dir< dirs.length; dir++){
int nTile1 = nTile + dirs[dir];
if (!weakOutlayers[nTile1] && ((selection == null) || selection[nTile1 ]) ) {
if (!weakOutliers[nTile1] && ((selection == null) || selection[nTile1 ]) ) {
double w = strength[nTile1];
sw += w;
sd += w * src_disparity[nTile1];
......@@ -642,7 +642,7 @@ public class CLTPass3d{
};
}
ImageDtt.startAndJoin(threads);
return weakOutlayers;
return weakOutliers;
}
public boolean [] getUntestedBackgroundBorder (
......
......@@ -829,7 +829,7 @@ public class TilePlanes {
for (int nl = 0; nl < measuredLayers.getNumLayers(); nl ++){
if ((measuredSelection[nl] != null) && ((measSel & (1 << nl)) !=0)) {
if (smplMode) {
disp_strength[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_strength[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
getSTileXY()[0], // int stX,
getSTileXY()[1], // int stY,
......@@ -964,7 +964,7 @@ public class TilePlanes {
if ((measuredSelection[nl] != null) && ((measSel & (1 << nl)) !=0)) {
// recalculate for all measure tiles, not just selected in the original PD
if (smplMode) {
disp_strength[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_strength[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
getSTileXY()[0], // int stX,
getSTileXY()[1], // int stY,
......@@ -1222,7 +1222,7 @@ public class TilePlanes {
for (int nl = 0; nl < measuredSelection.length; nl++){
if (measuredSelection[nl] != null){
if (smplMode) {
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
sTileXY[0], // int stX,
sTileXY[1], // int stY,
......@@ -1373,7 +1373,7 @@ public class TilePlanes {
if (measuredSelection[nl] != null){
if (smplMode) {
// if (need_disp_str) {
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
sTileXY[0], // int stX,
sTileXY[1], // int stY,
......@@ -1652,7 +1652,7 @@ public class TilePlanes {
if (tile_sel[nl] != null){
if (smplMode) {
if (need_disp_str) {
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
sTileXY[0], // int stX,
sTileXY[1], // int stY,
......@@ -2067,7 +2067,7 @@ public class TilePlanes {
if (tile_sel[nl] != null){
if (smplMode) {
if (need_disp_str) {
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_str[nl] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
nl, // int num_layer,
sTileXY[0], // int stX,
sTileXY[1], // int stY,
......@@ -4597,7 +4597,7 @@ public class TilePlanes {
double [][][] disp_strength = new double[measuredLayers.getNumLayers()][][];
for (int ml = 0; ml < disp_strength.length; ml++) if ((stMeasSel & ( 1 << ml)) != 0){
if (smplMode) {
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
ml, // int num_layer,
getSTileXY()[0], // int stX,
getSTileXY()[1], // int stY,
......@@ -5042,7 +5042,7 @@ public class TilePlanes {
double [][][] disp_strength = new double[measuredLayers.getNumLayers()][][];
for (int ml = 0; ml < disp_strength.length; ml++) if ((stMeasSel & ( 1 << ml)) != 0){
if (smplMode) {
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
ml, // int num_layer,
getSTileXY()[0], // int stX,
getSTileXY()[1], // int stY,
......@@ -5822,12 +5822,12 @@ public class TilePlanes {
}
}
// it is foreground, now get measured data and find maximal strength (remove outlayers?
// it is foreground, now get measured data and find maximal strength (remove outliers?
double [] lap_weights = measuredLayers.getLapWeights1d();
double [][][] disp_strength = new double[measuredLayers.getNumLayers()][][];
for (int ml = 0; ml < disp_strength.length; ml++) if (fg_sel[ml] != null){ // if ((stMeasSel & ( 1 << ml)) != 0) {
if (this.smplMode) {
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outlayers
disp_strength[ml] = measuredLayers.getDisparityStrengthMLTilted( // expensive to calculate (improve removing outliers
ml, // int num_layer,
getSTileXY()[0], // int stX,
getSTileXY()[1], // int stY,
......
......@@ -5032,10 +5032,10 @@ public class TileProcessor {
// replace weak outliers tiles with weighted averages (modifies disparity)
boolean[] outliers = scan_prev.replaceWeakOutliers(
null, // final boolean [] selection,
clt_parameters.outlayerStrength , //final double weakStrength, // strength to be considered weak, subject to this replacement
clt_parameters.outlayerDiff, // final double maxDiff)
clt_parameters.outlayerDiffPos, // final double maxDiff)
clt_parameters.outlayerDiffNeg, // final double maxDiff)
clt_parameters.outlierStrength , //final double weakStrength, // strength to be considered weak, subject to this replacement
clt_parameters.outlierDiff, // final double maxDiff)
clt_parameters.outlierDiffPos, // final double maxDiff)
clt_parameters.outlierDiffNeg, // final double maxDiff)
0.5 * disparity_far,
2.0 * disparity_near,
debugLevel);
......@@ -5124,7 +5124,7 @@ public class TileProcessor {
}
if (show_super && (debugLevel > 100)){ // something is broken, java.lang.NullPointerException at TileProcessor.refinePassSetup(TileProcessor.java:4488)
String [] dbg_disp_tiltes={"masked", "filtered", "disp_combo", "disparity","st_disparity", "strength",
"st_strength","outlayers","these","border","border_tiles"}; // ,"before","after","after1","after2","after3","neib"};
"st_strength","outliers","these","border","border_tiles"}; // ,"before","after","after1","after2","after3","neib"};
double [][] dbg_disp = new double [dbg_disp_tiltes.length][];
dbg_disp[0] = masked_filtered; // +
dbg_disp[1] = scan_prev.getDisparity(); // +
......@@ -7165,7 +7165,7 @@ public class TileProcessor {
this_disparity[i] = ortho_disparity[i];
}
// average disparity along the runs, if they are close enough (remove outlayers?)
// average disparity along the runs, if they are close enough (remove outliers?)
if (clt_parameters.ortho_rms > 0){
double ortho_rms2 = clt_parameters.ortho_rms * clt_parameters.ortho_rms;
......
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