Commit 95386703 authored by Andrey Filippov's avatar Andrey Filippov

adjusting parameters, improved filtering, added error display by the

targets
parent 25577f58
...@@ -546,7 +546,7 @@ public class LensAdjustment { ...@@ -546,7 +546,7 @@ public class LensAdjustment {
double targetMicrons, // target lens center distance (away from "best focus" double targetMicrons, // target lens center distance (away from "best focus"
double toleranceMicrons, // microns double toleranceMicrons, // microns
double toleranceTilt, // double toleranceTilt, //
double toleranceThreshold, // When each error is under swcaled thereshold, reduce correxction step twice double toleranceThreshold, // When each error is under swcaled threshold, reduce correxction step twice
double parallelAdjustThreshold, // adjust 3 motors parallel if focal distance error in the center exceeds this double parallelAdjustThreshold, // adjust 3 motors parallel if focal distance error in the center exceeds this
double motorsSigma, // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma double motorsSigma, // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
double motorsSigma3, // all 3 motors together (focusing center) double motorsSigma3, // all 3 motors together (focusing center)
...@@ -710,7 +710,7 @@ public class LensAdjustment { ...@@ -710,7 +710,7 @@ public class LensAdjustment {
this.targetMicrons=targetMicrons; // target lens center distance (away from "best focus" this.targetMicrons=targetMicrons; // target lens center distance (away from "best focus"
this.toleranceMicrons=toleranceMicrons; // microns this.toleranceMicrons=toleranceMicrons; // microns
this.toleranceTilt=toleranceTilt; // this.toleranceTilt=toleranceTilt; //
this.toleranceThreshold=toleranceThreshold; // When each error is under swcaled thereshold, reduce correxction step twice this.toleranceThreshold=toleranceThreshold; // When each error is under swcaled threshold, reduce correxction step twice
this.parallelAdjustThreshold=parallelAdjustThreshold; // adjust 3 motors parallel if focal distance error in the center exceeds this this.parallelAdjustThreshold=parallelAdjustThreshold; // adjust 3 motors parallel if focal distance error in the center exceeds this
this.motorsSigma=motorsSigma; // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma this.motorsSigma=motorsSigma; // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
this.motorsSigma3=motorsSigma3; // same when 3 motors move together this.motorsSigma3=motorsSigma3; // same when 3 motors move together
...@@ -873,7 +873,7 @@ public class LensAdjustment { ...@@ -873,7 +873,7 @@ public class LensAdjustment {
this.targetMicrons, // target lens center distance (away from "best focus" this.targetMicrons, // target lens center distance (away from "best focus"
this.toleranceMicrons, // microns this.toleranceMicrons, // microns
this.toleranceTilt, // this.toleranceTilt, //
this.toleranceThreshold, // When each error is under swcaled thereshold, reduce correxction step twice this.toleranceThreshold, // When each error is under swcaled threshold, reduce correxction step twice
this.parallelAdjustThreshold, // adjust 3 motors parallel if focal distance error in the center exceeds this this.parallelAdjustThreshold, // adjust 3 motors parallel if focal distance error in the center exceeds this
this.motorsSigma, // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma this.motorsSigma, // when fitting planes for far/near, tiltX and tiltY the weights of the samples decay with this sigma
......
...@@ -3512,7 +3512,7 @@ public class CLTParameters { ...@@ -3512,7 +3512,7 @@ public class CLTParameters {
gd.addCheckbox ("Add port weights to RGBA stack (debug feature)", this.keep_weights); gd.addCheckbox ("Add port weights to RGBA stack (debug feature)", this.keep_weights);
gd.addCheckbox ("Replace port weights with per-channel MIDCT (16x16) - were relevant", this.replace_weights); gd.addCheckbox ("Replace port weights with per-channel MIDCT (16x16) - were relevant", this.replace_weights);
gd.addCheckbox ("Alpha channel: use center 8x8 (unchecked - treat same as RGB)", this.sharp_alpha); gd.addCheckbox ("Alpha channel: use center 8x8 (unchecked - treat same as RGB)", this.sharp_alpha);
gd.addNumericField("Alpha channel 0.0 thereshold (lower - transparent)", this.alpha0, 3); gd.addNumericField("Alpha channel 0.0 threshold (lower - transparent)", this.alpha0, 3);
gd.addNumericField("Alpha channel 1.0 threshold (higher - opaque)", this.alpha1, 3); gd.addNumericField("Alpha channel 1.0 threshold (higher - opaque)", this.alpha1, 3);
gd.addCheckbox ("Generate shifted channel linear RGB stacks", this.gen_chn_stacks); gd.addCheckbox ("Generate shifted channel linear RGB stacks", this.gen_chn_stacks);
gd.addCheckbox ("Generate shifted channel color image stack", this.gen_chn_img); gd.addCheckbox ("Generate shifted channel color image stack", this.gen_chn_img);
...@@ -4130,11 +4130,11 @@ public class CLTParameters { ...@@ -4130,11 +4130,11 @@ public class CLTParameters {
"Absolute inter-sensor difference to seed transparent texture."); "Absolute inter-sensor difference to seed transparent texture.");
gd.addNumericField("Seed fat zero of combo variance", this.lre_seed_same_fz, 5,7,"", // 6.5; // 13; // seed_inter = 50.0; gd.addNumericField("Seed fat zero of combo variance", this.lre_seed_same_fz, 5,7,"", // 6.5; // 13; // seed_inter = 50.0;
"Add to the denominator (to combined variance) to divide inter-sensor variance."); "Add to the denominator (to combined variance) to divide inter-sensor variance.");
gd.addNumericField("Seed FOM thereshold", this.lre_seed_fom, 5,7,"", // 2.0; // 1.9; // 1.2; gd.addNumericField("Seed FOM threshold", this.lre_seed_fom, 5,7,"", // 2.0; // 1.9; // 1.2;
"Seed threshold for var_inter/(var_same+var_same_fz) - definitely not a foreground."); "Seed threshold for var_inter/(var_same+var_same_fz) - definitely not a foreground.");
gd.addNumericField("Seed fat zero of inter-sensor variance",this.lre_trim_inter_fz, 5,7,"", //5.0; // 13.0; gd.addNumericField("Seed fat zero of inter-sensor variance",this.lre_trim_inter_fz, 5,7,"", //5.0; // 13.0;
"Add to the denominator (to inter-sensor variance) to divide combo variance."); "Add to the denominator (to inter-sensor variance) to divide combo variance.");
gd.addNumericField("Trim FOM thereshold", this.lre_trim_fom, 5,7,"", // 0.5; // 0.8; // 1.3; // 1.8; // 1.2; // 0.8; // 0.4; // 0.7; gd.addNumericField("Trim FOM threshold", this.lre_trim_fom, 5,7,"", // 0.5; // 0.8; // 1.3; // 1.8; // 1.2; // 0.8; // 0.4; // 0.7;
"Trim threshold for var_same/(var_inter+var_inter_fz) - seems to be foreground."); "Trim threshold for var_same/(var_inter+var_inter_fz) - seems to be foreground.");
gd.addMessage("Reducing Trim FOM near high-contrast FG over sky by thresholding, bluring and dividing"); gd.addMessage("Reducing Trim FOM near high-contrast FG over sky by thresholding, bluring and dividing");
// Scale down FOM for pixels near high-variance VAR_SAME // Scale down FOM for pixels near high-variance VAR_SAME
......
...@@ -106,7 +106,8 @@ public class DoubleGaussianBlur { ...@@ -106,7 +106,8 @@ public class DoubleGaussianBlur {
return; return;
} }
/* Blur an image in one direction (x or y) by a Gaussian. /**
* Blur an image in one direction (x or y) by a Gaussian.
* @param ip The Image with the original data where also the result will be stored * @param ip The Image with the original data where also the result will be stored
* @param sigma Standard deviation of the Gaussian * @param sigma Standard deviation of the Gaussian
* @param accuracy Accuracy of kernel, should not be > 0.02 * @param accuracy Accuracy of kernel, should not be > 0.02
...@@ -188,7 +189,8 @@ public class DoubleGaussianBlur { ...@@ -188,7 +189,8 @@ public class DoubleGaussianBlur {
} }
return; return;
} }
/* Create a 1-dimensional normalized Gaussian kernel with standard deviation sigma /**
* Create a 1-dimensional normalized Gaussian kernel with standard deviation sigma
* and the running sum over the kernel * and the running sum over the kernel
* Note: this is one side of the kernel only, not the full kernel as used by the * Note: this is one side of the kernel only, not the full kernel as used by the
* Convolver class of ImageJ. * Convolver class of ImageJ.
...@@ -252,14 +254,15 @@ public class DoubleGaussianBlur { ...@@ -252,14 +254,15 @@ public class DoubleGaussianBlur {
} }
return kernel; return kernel;
} }
/* Scale a line (row or column of a FloatProcessor or part thereof)
/** Scale a line (row or column of a FloatProcessor or part thereof)
* down by a factor <code>reduceBy</code> and write the result into * down by a factor <code>reduceBy</code> and write the result into
* <code>cache</code>. * <code>cache</code>.
* Input line pixel # <code>unscaled0</code> will correspond to output * Input line pixel # <code>unscaled0</code> will correspond to output
* line pixel # 0. <code>unscaled0</code> may be negative. Out-of-line * line pixel # 0. <code>unscaled0</code> may be negative. Out-of-line
* pixels of the input are replaced by the edge pixels. * pixels of the input are replaced by the edge pixels.
*/ */
void downscaleLine(double[] pixels, double[] cache, double[] kernel, static void downscaleLine(double[] pixels, double[] cache, double[] kernel,
int reduceBy, int pixel0, int unscaled0, int length, int pointInc, int newLength) { int reduceBy, int pixel0, int unscaled0, int length, int pointInc, int newLength) {
if (pixel0 > pixels.length) { if (pixel0 > pixels.length) {
System.out.println("++++++ Error in DoubleGaussianBlur, pixel0="+pixel0+", pixels.length="+(pixels.length)); System.out.println("++++++ Error in DoubleGaussianBlur, pixel0="+pixel0+", pixels.length="+(pixels.length));
...@@ -280,7 +283,8 @@ public class DoubleGaussianBlur { ...@@ -280,7 +283,8 @@ public class DoubleGaussianBlur {
} }
} }
/* Create a kernel for downscaling. The kernel function preserves /**
* Create a kernel for downscaling. The kernel function preserves
* norm and 1st moment (i.e., position) and has fixed 2nd moment, * norm and 1st moment (i.e., position) and has fixed 2nd moment,
* (in contrast to linear interpolation). * (in contrast to linear interpolation).
* In scaled space, the length of the kernel runs from -1.5 to +1.5, * In scaled space, the length of the kernel runs from -1.5 to +1.5,
...@@ -288,7 +292,7 @@ public class DoubleGaussianBlur { ...@@ -288,7 +292,7 @@ public class DoubleGaussianBlur {
* Array index corresponding to the kernel center is * Array index corresponding to the kernel center is
* unitLength*3/2 * unitLength*3/2
*/ */
double[] makeDownscaleKernel (int unitLength) { static double[] makeDownscaleKernel (int unitLength) {
int mid = unitLength*3/2; int mid = unitLength*3/2;
double[] kernel = new double[3*unitLength]; double[] kernel = new double[3*unitLength];
for (int i=0; i<=unitLength/2; i++) { for (int i=0; i<=unitLength/2; i++) {
...@@ -306,10 +310,11 @@ public class DoubleGaussianBlur { ...@@ -306,10 +310,11 @@ public class DoubleGaussianBlur {
return kernel; return kernel;
} }
/* Scale a line up by factor <code>reduceBy</code> and write as a row /**
* Scale a line up by factor <code>reduceBy</code> and write as a row
* or column (or part thereof) to the pixels array of a FloatProcessor. * or column (or part thereof) to the pixels array of a FloatProcessor.
*/ */
void upscaleLine (double[] cache, double[] pixels, double[] kernel, static void upscaleLine (double[] cache, double[] pixels, double[] kernel,
int reduceBy, int pixel0, int unscaled0, int writeFrom, int writeTo, int pointInc) { int reduceBy, int pixel0, int unscaled0, int writeFrom, int writeTo, int pointInc) {
int p = pixel0 + pointInc*writeFrom; int p = pixel0 + pointInc*writeFrom;
for (int xout = writeFrom; xout < writeTo; xout++, p+=pointInc) { for (int xout = writeFrom; xout < writeTo; xout++, p+=pointInc) {
...@@ -322,7 +327,8 @@ public class DoubleGaussianBlur { ...@@ -322,7 +327,8 @@ public class DoubleGaussianBlur {
} }
} }
/* Create a kernel for upscaling. The kernel function is a convolution /**
* Create a kernel for upscaling. The kernel function is a convolution
* of four unit squares, i.e., four uniform kernels with value +1 * of four unit squares, i.e., four uniform kernels with value +1
* from -0.5 to +0.5 (in downscaled coordinates). The second derivative * from -0.5 to +0.5 (in downscaled coordinates). The second derivative
* of this kernel is smooth, the third is not. Its standard deviation * of this kernel is smooth, the third is not. Its standard deviation
...@@ -330,7 +336,7 @@ public class DoubleGaussianBlur { ...@@ -330,7 +336,7 @@ public class DoubleGaussianBlur {
* The kernel runs from [-2 to +2[, corresponding to array index * The kernel runs from [-2 to +2[, corresponding to array index
* 0 ... 4*unitLength (whereby the last point is not in the array any more). * 0 ... 4*unitLength (whereby the last point is not in the array any more).
*/ */
double[] makeUpscaleKernel (int unitLength) { static double[] makeUpscaleKernel (int unitLength) {
double[] kernel = new double[4*unitLength]; double[] kernel = new double[4*unitLength];
int mid = 2*unitLength; int mid = 2*unitLength;
kernel[0] = 0; kernel[0] = 0;
...@@ -349,7 +355,8 @@ public class DoubleGaussianBlur { ...@@ -349,7 +355,8 @@ public class DoubleGaussianBlur {
return kernel; return kernel;
} }
/* Convolve a line with a symmetric kernel and write to a separate array, /**
* Convolve a line with a symmetric kernel and write to a separate array,
* possibly the pixels array of a FloatProcessor (as a row or column or part thereof) * possibly the pixels array of a FloatProcessor (as a row or column or part thereof)
* *
* @param input Input array containing the line * @param input Input array containing the line
...@@ -371,7 +378,7 @@ public class DoubleGaussianBlur { ...@@ -371,7 +378,7 @@ public class DoubleGaussianBlur {
* @param pointInc Increment of the pixels array index to the next point (for an ImageProcessor, * @param pointInc Increment of the pixels array index to the next point (for an ImageProcessor,
* it should be <code>1</code> for a row, <code>width</code> for a column) * it should be <code>1</code> for a row, <code>width</code> for a column)
*/ */
public void convolveLine(double[] input, double[] pixels, double[][] kernel, int readFrom, public static void convolveLine(double[] input, double[] pixels, double[][] kernel, int readFrom,
int readTo, int writeFrom, int writeTo, int point0, int pointInc) { int readTo, int writeFrom, int writeTo, int point0, int pointInc) {
int length = input.length; int length = input.length;
double first = input[0]; //out-of-edge pixels are replaced by nearest edge pixels double first = input[0]; //out-of-edge pixels are replaced by nearest edge pixels
......
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