...
 
Commits (16)
......@@ -4276,7 +4276,7 @@ List calibration
}
public boolean removeOutLierSets(int numOutLiers){
boolean removeEmptySets=false;
boolean removeEmptySets=true; // false;
if (numOutLiers<0) {
GenericDialog gd = new GenericDialog("Select sets to process");
gd.addNumericField("Series number (<0 - all images)", -1, 0);
......
......@@ -1009,14 +1009,32 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
y0);
}
public double [] extractSimulMono ( // TODO: can use twice smaller barray
double [] localbArray,
SimulParameters simulParameters,
int outSubdiv, // subdivide output pixels - now 4
int size, // number of Bayer cells in width of the square selection (half number of pixels)
double x0, // selection center, X (in pixels)
double y0) {
return extractSimulMono ( // TODO: can use twice smaller barray
localbArray,
false, // boolean invert,
simulParameters,
outSubdiv, // subdivide output pixels - now 4
size, // number of Bayer cells in width of the square selection (half number of pixels)
x0, // selection center, X (in pixels)
y0);
}
public double [] extractSimulMono ( // TODO: can use twice smaller barray
double [] localbArray,
boolean invert,
SimulParameters simulParameters,
int outSubdiv, // subdivide output pixels - now 4
int size, // number of Bayer cells in width of the square selection (half number of pixels)
double x0, // selection center, X (in pixels)
double y0) {
double pattern_sign = invert? -1.0 : 1.0;
int sampleWidth=(int) (Math.sqrt(simulParameters.fill)*simulParameters.subdiv);
int sampleN=sampleWidth*sampleWidth;
if (sampleWidth<1) sampleWidth=1;
......@@ -1043,7 +1061,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
return null;
}
}
simul_pixels[iy*size+ix]= (s-sampleAverage)/sampleAverage;
simul_pixels[iy*size+ix]= pattern_sign * (s - sampleAverage) / sampleAverage;
}
}
if (this.debugLevel>2) {
......@@ -1069,6 +1087,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
return rslt;
}
// colorComp == -1 = mono, positive, colorComp == -2 - mono, negative
public double[] extractBayerSim (
float [][] spixels, // [0] - regular pixels, [1] - shifted by 1/2 diagonally, for checker greens
int full_width,
......@@ -1105,21 +1124,28 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
result[index]=spixels[(ixi+iyi) & 1][iy*full_width+ix];
}
} else { // components 0..3
int ser;
double pattern_sign = (colorComp == -2)? -1.0: 1.0;
if (colorComp < 0) {
ser = 1; // offset by 1/2 pix? should it be so? // FIXME: verify and fix if needed - compare to extractSimulMono()
} else {
ser = 0;
r.x+=(bayerPeriod/2)*(colorComp &1);
r.y+=(bayerPeriod/2)*((colorComp>>1) &1);
}
if (debugLevel>2) System.out.println(">>> r.width="+r.width+
" r.height="+r.height+
" r.x="+r.x+
" r.y="+r.y+
" colorComp="+colorComp);
for (index=0;index<result.length;index++){
int iy=r.y+(index / r.width);
int ix=r.x+(index % r.width);
if (iy<0) iy=0;
else if (iy>=full_height) iy=full_height-1;
if (ix<0) ix=0;
else if (ix>=full_width) iy=full_width-1;
result[index]=spixels[0][iy*full_width+ix];
int iy = r.y + (index / r.width);
int ix = r.x + (index % r.width);
if (iy < 0) iy = 0;
else if (iy >= full_height) iy = full_height - 1;
if (ix < 0) ix = 0;
else if (ix >= full_width) iy = full_width - 1;
result[index] = pattern_sign * spixels[ser][iy * full_width + ix];
}
}
return result;
......
......@@ -2,8 +2,8 @@ package com.elphel.imagej.common;
/**
* The code below is extracted form ImageJ plugin GaussianBlur.java, stripped of ImageProcessor and used (double) instead of (float) arrays.
* The following are notes from the original file:
*
*
*
*
* This plug-in filter uses convolution with a Gaussian function for smoothing.
* 'Radius' means the radius of decay to exp(-0.5) ~ 61%, i.e. the standard
* deviation sigma of the Gaussian (this is the same as in Photoshop, but
......@@ -20,7 +20,7 @@ package com.elphel.imagej.common;
* - For increased speed, except for small blur radii, the lines (rows or
* columns of the image) are downscaled before convolution and upscaled
* to their original length thereafter.
*
*
* Version 03-Jun-2007 M. Schmid with preview, progressBar stack-aware,
* snapshot via snapshot flag; restricted range for resetOutOfRoi
*
......@@ -39,12 +39,12 @@ public class DoubleGaussianBlur {
private int nPasses = 1; // The number of passes (filter directions * color channels * stack slices)
// private int nChannels = 1; // The number of color channels
private int pass; // Current pass
/* Default constructor */
public DoubleGaussianBlur() {
}
public void blurDouble(double[] pixels,
int width,
int height,
......@@ -64,7 +64,7 @@ public class DoubleGaussianBlur {
* @param sigma Standard deviation of the Gaussian
* @param accuracy Accuracy of kernel, should not be > 0.02
* @param xDirection True for blurring in x direction, false for y direction
* @param extraLines Number of lines (parallel to the blurring direction)
* @param extraLines Number of lines (parallel to the blurring direction)
* below and above the roi bounds that should be processed.
*/
public void blur1Direction(double [] pixels,
......@@ -73,7 +73,7 @@ public class DoubleGaussianBlur {
double sigma,
double accuracy,
boolean xDirection
// int extraLines
// int extraLines
) {
final int UPSCALE_K_RADIUS = 2; //number of pixels to add for upscaling
final double MIN_DOWNSCALED_SIGMA = 4.; //minimum standard deviation in the downscaled image
......@@ -171,7 +171,7 @@ public class DoubleGaussianBlur {
if (kRadius > maxRadius) kRadius = maxRadius;
double[][] kernel = new double[2][kRadius];
for (int i=0; i<kRadius; i++) // Gaussian function
kernel[0][i] = (double)(Math.exp(-0.5*i*i/sigma/sigma));
kernel[0][i] = (Math.exp(-0.5*i*i/sigma/sigma));
if (kRadius < maxRadius && kRadius > 3) { // edge correction
double sqrtSlope = Double.MAX_VALUE;
int r = kRadius;
......@@ -184,7 +184,7 @@ public class DoubleGaussianBlur {
break;
}
for (int r1 = r+2; r1 < kRadius; r1++)
kernel[0][r1] = (double)((kRadius-r1)*(kRadius-r1)*sqrtSlope*sqrtSlope);
kernel[0][r1] = (kRadius-r1)*(kRadius-r1)*sqrtSlope*sqrtSlope;
}
double sum; // sum over all kernel elements for normalization
if (kRadius < maxRadius) {
......@@ -193,13 +193,13 @@ public class DoubleGaussianBlur {
sum += 2*kernel[0][i];
} else
sum = sigma * Math.sqrt(2*Math.PI);
double rsum = 0.5 + 0.5*kernel[0][0]/sum;
for (int i=0; i<kRadius; i++) {
double v = (kernel[0][i]/sum);
kernel[0][i] = (double)v;
kernel[0][i] = v;
rsum -= v;
kernel[1][i] = (double)rsum;
kernel[1][i] = rsum;
//IJ.log("k["+i+"]="+(float)v+" sum="+(float)rsum);
}
return kernel;
......@@ -213,6 +213,10 @@ public class DoubleGaussianBlur {
*/
void downscaleLine(double[] pixels, double[] cache, double[] kernel,
int reduceBy, int pixel0, int unscaled0, int length, int pointInc, int newLength) {
if (pixel0 > pixels.length) {
System.out.println("++++++ Error in DoubleGaussianBlur, pixel0="+pixel0+", pixels.length="+(pixels.length));
return;
}
double first = pixels[pixel0];
double last = pixels[pixel0 + pointInc*(length-1)];
int xin = unscaled0 - reduceBy/2;
......@@ -241,13 +245,13 @@ public class DoubleGaussianBlur {
double[] kernel = new double[3*unitLength];
for (int i=0; i<=unitLength/2; i++) {
double x = i/(double)unitLength;
double v = (double)((0.75-x*x)/unitLength);
double v = (0.75-x*x)/unitLength;
kernel[mid-i] = v;
kernel[mid+i] = v;
}
for (int i=unitLength/2+1; i<(unitLength*3+1)/2; i++) {
double x = i/(double)unitLength;
double v = (double)((0.125 + 0.5*(x-1)*(x-2))/unitLength);
double v = (0.125 + 0.5*(x-1)*(x-2))/unitLength;
kernel[mid-i] = v;
kernel[mid+i] = v;
}
......@@ -284,13 +288,13 @@ public class DoubleGaussianBlur {
kernel[0] = 0;
for (int i=0; i<unitLength; i++) {
double x = i/(double)unitLength;
double v = (double)((2./3. -x*x*(1-0.5*x)));
double v = ((2./3. -x*x*(1-0.5*x)));
kernel[mid+i] = v;
kernel[mid-i] = v;
}
for (int i=unitLength; i<2*unitLength; i++) {
double x = i/(double)unitLength;
double v = (double)((2.-x)*(2.-x)*(2.-x)/6.);
double v = (2.-x)*(2.-x)*(2.-x)/6.;
kernel[mid+i] = v;
kernel[mid-i] = v;
}
......@@ -350,7 +354,7 @@ public class DoubleGaussianBlur {
result += kern[k] * (input[i-k] + input[i+k]);
pixels[p] = result;
}
for (; i<writeTo; i++,p+=pointInc) { //while the sum would include pixels >= length
for (; i<writeTo; i++,p+=pointInc) { //while the sum would include pixels >= length
double result = input[i]*kern0;
if (i<kRadius) result += kernSum[i]*first;
if (i+kRadius>=length) result += kernSum[length-i-1]*last;
......
package com.elphel.imagej.common;
import java.util.Properties;
public class EProperties extends Properties{
private static final long serialVersionUID = -425120416815883045L;
public int getProperty(String key, int value){
return Integer.parseInt(getProperty(key, ""+value));
}
public double getProperty(String key, double value){
return Double.parseDouble(getProperty(key, ""+value));
}
public boolean getProperty(String key, boolean value){
return Boolean.parseBoolean(getProperty(key, ""+value));
}
}