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

added channel filter to "Remove Outlayers"

parent 59e08875
...@@ -5984,9 +5984,15 @@ if (MORE_BUTTONS) { ...@@ -5984,9 +5984,15 @@ if (MORE_BUTTONS) {
IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set"); IJ.showMessage("LENS_DISTORTION.fittingStrategy is not set");
return; return;
} }
boolean [] selectedChannels=null;
if (ABERRATIONS_PARAMETERS!=null){
selectedChannels=ABERRATIONS_PARAMETERS.getChannelSelection(LENS_DISTORTIONS);
}
LENS_DISTORTIONS.removeOutLayers( LENS_DISTORTIONS.removeOutLayers(
-1, //int series, (<0 - ask) -1, //int series, (<0 - ask)
-1 //int numOutLayers (<0 - ask) -1, //int numOutLayers (<0 - ask)
selectedChannels
); );
return; return;
} }
......
...@@ -3676,14 +3676,23 @@ List calibration ...@@ -3676,14 +3676,23 @@ List calibration
return true; return true;
} }
public boolean removeOutLayers(int series, int numOutLayers){ public boolean removeOutLayers(
int series,
int numOutLayers,
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;
int filter=filterForAll; int filter=filterForAll;
if ((series<0) || (numOutLayers<0)) { if ((series<0) || (numOutLayers<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) {
String s="";
for (boolean b:selectedChannels)s+=b?"+":"-";
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 outlayers to show", 10, 0);
gd.addCheckbox("Remove empty (rms==NaN) images", removeEmpty); gd.addCheckbox("Remove empty (rms==NaN) images", removeEmpty);
...@@ -3691,6 +3700,7 @@ List calibration ...@@ -3691,6 +3700,7 @@ List calibration
gd.showDialog(); gd.showDialog();
if (gd.wasCanceled()) return false; if (gd.wasCanceled()) return false;
this.seriesNumber= (int) gd.getNextNumber(); this.seriesNumber= (int) gd.getNextNumber();
if (selectedChannels != null) applyChannelFilter= gd.getNextBoolean();
recalculate= gd.getNextBoolean(); recalculate= gd.getNextBoolean();
numOutLayers= (int) gd.getNextNumber(); numOutLayers= (int) gd.getNextNumber();
removeEmpty= gd.getNextBoolean(); removeEmpty= gd.getNextBoolean();
...@@ -3700,12 +3710,22 @@ List calibration ...@@ -3700,12 +3710,22 @@ List calibration
} else { } else {
this.seriesNumber=series; this.seriesNumber=series;
} }
if (!applyChannelFilter) selectedChannels=null;
// initFittingSeries(!recalculate,this.filterForAll,this.seriesNumber); // will set this.currentVector // initFittingSeries(!recalculate,this.filterForAll,this.seriesNumber); // will set this.currentVector
initFittingSeries(!recalculate,this.filterForAll,this.seriesNumber); // will set this.currentVector initFittingSeries(!recalculate,this.filterForAll,this.seriesNumber); // will set this.currentVector
this.currentfX=calculateFxAndJacobian(this.currentVector, false); // is it always true here (this.jacobian==null) this.currentfX=calculateFxAndJacobian(this.currentVector, false); // is it always true here (this.jacobian==null)
double [] errors=calcErrors(calcYminusFx(this.currentfX)); // seem to have errors? - now may return NaN! double [] errors=calcErrors(calcYminusFx(this.currentfX)); // seem to have errors? - now may return NaN!
double rms= calcError (calcYminusFx(this.currentfX)); double rms= calcError (calcYminusFx(this.currentfX));
boolean [] selectedImages=fittingStrategy.selectedImages(); boolean [] selectedImages=fittingStrategy.selectedImages();
if (selectedChannels!=null){
selectedImages=selectedImages.clone(); // disconnect from original for modification
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i]){
int chn=this.fittingStrategy.distortionCalibrationData.gIP[i].channel;
if ((chn<0) || (chn>=selectedChannels.length) || !selectedChannels[chn]){
selectedImages[i]=false;
}
}
}
int numSelectedNotNaNImages=0; int numSelectedNotNaNImages=0;
int numNaN=0; int numNaN=0;
for (int i=0;i<selectedImages.length;i++) if (selectedImages[i]) { for (int i=0;i<selectedImages.length;i++) if (selectedImages[i]) {
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