Commit 24b642b0 authored by Andrey Filippov's avatar Andrey Filippov

Updating batch mode of the 3d scene processing

parent 91409a1a
......@@ -3,12 +3,12 @@
** CorrectionColorProc.java
**
** Color conversion methods used in aberration correction for Eyesis4pi
**
**
**
** Copyright (C) 2012 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
**
** CorrectionColorProc.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
......@@ -25,12 +25,12 @@
**
*/
import ij.ImageStack;
import ij.gui.GenericDialog;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import ij.ImageStack;
import ij.gui.GenericDialog;
public class CorrectionColorProc {
showDoubleFloatArrays SDFA_INSTANCE= new showDoubleFloatArrays();
......@@ -46,7 +46,7 @@ public class CorrectionColorProc {
int getDenoiseMaskChromaWidth() {return this.denoiseMaskChromaWidth;}
void setDebug(int debugLevel){this.debugLevel=debugLevel;}
public void processColorsWeights(ImageStack stack, // does not like NaN (in GaussianBlur
double scale, // initial maximal pixel value (16))
EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
......@@ -108,9 +108,9 @@ public class CorrectionColorProc {
for (i=0;i<length;i++) {
double Y=Ar*fpixels_r[i]+Ag*fpixels_g[i]+Ab*fpixels_b[i];
Y= (Y !=0.0) ? (linGamma(colorProcParameters.gamma, gamma_a, gamma_linK, colorProcParameters.minLin, Y)/Y): 0.0;
fpixels_r[i]*=Y*gain_red;
fpixels_g[i]*=Y*gain_green;
fpixels_b[i]*=Y*gain_blue;
fpixels_r[i]*=Y*gain_red;
fpixels_g[i]*=Y*gain_green;
fpixels_b[i]*=Y*gain_blue;
}
if (colorProcParameters.corrBlueLeak && blueProc) {
......@@ -222,11 +222,11 @@ public class CorrectionColorProc {
gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
if (debugLevel> 2) {
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
}
double mp;
double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin);
......@@ -241,7 +241,7 @@ public class CorrectionColorProc {
//TODO: null DENOISE_MASK if it is not calculated
if (colorProcParameters.combineWithSharpnessMask) {
if (denoiseMask==null) {
System.out.println ( "Can not combine masks as denoiseMask is null (i.e. no denoise was performed)");
System.out.println ( "Can not combine masks as denoiseMask is null (i.e. no denoise was performed)"); // here
} else if (denoiseMask.length!=dmask.length) {
System.out.println ( "Can not combine masks as denoiseMask length is different from that of dmask");
} else {
......@@ -324,7 +324,7 @@ public class CorrectionColorProc {
fpixels_g[i]=(float) linGamma(colorProcParameters.gamma, gamma_a, gamma_linK, colorProcParameters.minLin, fpixels_g[i]*gain_green);
fpixels_b[i]=(float) linGamma(colorProcParameters.gamma, gamma_a, gamma_linK, colorProcParameters.minLin, fpixels_b[i]*gain_blue);
}
/* Convert to YPbPr */
double Y,Pb,Pr;
double Kg=1.0-colorProcParameters.kr-colorProcParameters.kb;
......@@ -411,11 +411,11 @@ public class CorrectionColorProc {
gb.blurDouble(dpixels_pr_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
gb.blurDouble(dpixels_pb_dark, width, height, colorProcParameters.chromaDarkSigma, colorProcParameters.chromaDarkSigma, 0.01);
if (debugLevel>2) {
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
SDFA_INSTANCE.showArrays(dmask, width, height,"dmask");
SDFA_INSTANCE.showArrays(dpixels_pr, width, height,"dpixels_pr");
SDFA_INSTANCE.showArrays(dpixels_pb, width, height,"dpixels_pb");
SDFA_INSTANCE.showArrays(dpixels_pr_dark, width, height,"dpixels_pr_dark");
SDFA_INSTANCE.showArrays(dpixels_pb_dark, width, height,"dpixels_pb_dark");
}
double mp;
double k =1.0/(colorProcParameters.maskMax-colorProcParameters.maskMin);
......@@ -439,7 +439,7 @@ public class CorrectionColorProc {
if (dmask[i]>1.0) dmask[i]=1.0;
}
}
}
for (i=0;i<dmask.length;i++) {
mp=dmask[i];
......@@ -469,7 +469,7 @@ public class CorrectionColorProc {
}
/* ======================================================================== */
public double linGamma(double gamma, double a, double k, double x0, double x) {
if (x<0) return 0.0;
......@@ -518,25 +518,25 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
}
public static class ColorGainsParameters {
public double[] gain={
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
public double[] balanceRed={
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
public double[] balanceBlue={
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0};
public ColorGainsParameters(){
}
......@@ -561,7 +561,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
}
}
}
public void modifyNumChannels(int numChannels){
if ((numChannels>0) && (numChannels!=this.gain.length)) {
double [] gain1=this.gain;
......@@ -579,7 +579,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
}
}
}
public boolean showDialog() {
GenericDialog gd = new GenericDialog("Individual channels colors/gains");
for (int i =0; i<this.gain.length;i++){
......
......@@ -3004,6 +3004,9 @@ public class EyesisCorrectionParameters {
public HashMap<String,Double> z_corr_map = new HashMap<String,Double>();
public static String Z_CORR_PREFIX = "z_corr.";
public boolean batch_run = false; // turned on only while running in batch mode
public CLTParameters(){}
public void setProperties(String prefix,Properties properties){
......
......@@ -5,7 +5,7 @@
** Copyright (C) 2016 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
**
** EyesisDCT.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
......@@ -25,7 +25,6 @@
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import ij.CompositeImage;
import ij.IJ;
import ij.ImagePlus;
......@@ -48,7 +47,7 @@ public class EyesisDCT {
/// public int extra_items = 8; // number of extra items saved with kernels (center offset (partial, full, derivatives)
public ImagePlus eyesisKernelImage = null;
public long startTime;
public EyesisDCT(
Properties properties,
EyesisCorrections eyesisCorrections,
......@@ -63,7 +62,7 @@ public class EyesisDCT {
}
// TODO:Add saving just calibration
/***
/***
public void setProperties(){
for (int n = 0; n < fine_corr.length; n++){
for (int d = 0; d < fine_corr[n].length; d++){
......@@ -73,7 +72,7 @@ public class EyesisDCT {
}
}
}
}
}
public void getProperties(){
for (int n = 0; n < fine_corr.length; n++){
......@@ -84,7 +83,7 @@ public class EyesisDCT {
}
}
}
}
}
*/
public class DCTKernels{
// -- old --
......@@ -94,26 +93,26 @@ public class EyesisDCT {
public double [][] kern = null; // kernel image in linescan order
// -- new --
public int numHor = 164; // number of kernel tiles in a row
public int dct_size = 8; // DCT-II size, sym. kernel square side is 2*dct_size-1
public int dct_size = 8; // DCT-II size, sym. kernel square side is 2*dct_size-1
public int asym_size = 15; // asymmetrical convolution limits, odd
public int asym_nonzero = 4; // maximal number of non-zero elements in the asymmetrical kernels
public int asym_nonzero = 4; // maximal number of non-zero elements in the asymmetrical kernels
public double [][] sym_kernels = null; // per-color channel, DCT kernels in linescan order
public double [][] sym_direct = null; // per-color channel, DCT kernels in linescan order (direct, not dct-iii transformed) - debug feature
public double [][] asym_kernels = null; // per-color channel, asymmetrical kernels (all but asym_nonzero elements are strictly 0)
public double [][][][] st_kernels = null; // [color][tileY][tileX][pixel]
public double [][][][] st_direct = null; // [color][tileY][tileX][pixel] - direct, not converted with DCT-III - debug feature
public double [][][][] asym_val = null; // [color][tileY][tileX][index] // value - asym kernel for elements
public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list
public int [][][][] asym_indx = null; // [color][tileY][tileX][index] // value - index of non-zero elements in the list
}
public void setKernelImageFile(ImagePlus img_kernels){
eyesisKernelImage = img_kernels;
}
public boolean kernelImageSet(){
return eyesisKernelImage != null;
}
public boolean DCTKernelsAvailable(){
return kernels != null;
}
......@@ -122,7 +121,7 @@ public class EyesisDCT {
final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
final int kernelSize, // 64
final EyesisCorrectionParameters.DCTParameters dct_parameters,
final int threadsMax, // maximal number of threads to launch
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int globalDebugLevel) // update status info
{
......@@ -142,22 +141,23 @@ public class EyesisDCT {
final AtomicInteger ai = new AtomicInteger(0);
final int numberOfKernels= kernelNumHor*kernelNumVert*nChn;
final int numberOfKernelsInChn=kernelNumHor*kernelNumVert;
final int dct_size = dct_parameters.dct_size;
final int preTargetSize = 4 * dct_size;
final int dct_size = dct_parameters.dct_size;
final int preTargetSize = 4 * dct_size;
final int targetSize = 2 * dct_size; // normally 16
final double [] anitperiodic_window = createAntiperiodicWindow(dct_size);
final long startTime = System.nanoTime();
System.out.println("calculateDCTKernel():numberOfKernels="+numberOfKernels);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
@Override
public void run() {
DoubleGaussianBlur gb=null;
if (dct_parameters.decimateSigma > 0) gb=new DoubleGaussianBlur();
float [] kernelPixels= null; // will be initialized at first use NOT yet?
double [] kernel= new double[kernelSize*kernelSize];
double [] pre_target_kernel= new double [preTargetSize * preTargetSize]; // before made antiperiodic
double [] pre_target_kernel= new double [preTargetSize * preTargetSize]; // before made antiperiodic
double [] target_kernel = new double [targetSize * targetSize]; // strictly antiperiodic in both x and y directions
FactorConvKernel factorConvKernel = new FactorConvKernel();
factorConvKernel.setDebugLevel (0); // globalDebugLevel);
factorConvKernel.setTargetWindowMode (dct_parameters.centerWindowToTarget);
......@@ -165,7 +165,7 @@ public class EyesisDCT {
factorConvKernel.setAsymCompactness (dct_parameters.compactness, dct_parameters.asym_tax_free);
factorConvKernel.setSymCompactness (dct_parameters.sym_compactness);
factorConvKernel.setDCWeight (dct_parameters.dc_weight);
int chn,tileY,tileX;
for (int nTile = ai.getAndIncrement(); nTile < numberOfKernels; nTile = ai.getAndIncrement()) {
chn=nTile/numberOfKernelsInChn;
......@@ -176,15 +176,15 @@ public class EyesisDCT {
if (globalDebugLevel>2) System.out.println("Processing kernels, channel "+(chn+1)+" of "+nChn+", row "+(tileY+1)+" of "+kernelNumVert+" : "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
}
kernelPixels=(float[]) kernelStack.getPixels(chn+1);
/* read convolution kernel */
extractOneKernel(
kernelPixels, // array of combined square kernels, each
kernelPixels, // array of combined square kernels, each
kernel, // will be filled, should have correct size before call
kernelNumHor, // number of kernels in a row
tileX, // horizontal number of kernel to extract
tileY); // vertical number of kernel to extract
if ((dct_parameters.decimation == 2) && (dct_parameters.decimateSigma<0)) {
reformatKernel2( // averages by exactly 2 (decimate==2)
kernel,
......@@ -220,8 +220,8 @@ public class EyesisDCT {
pre_target_kernel, // 16*dct_zize*dct_zize
anitperiodic_window, // 16*dct_zize*dct_zize
target_kernel); // 4*dct_zize*dct_zize
factorConvKernel.calcKernels(
target_kernel,
dct_parameters.asym_size,
......@@ -230,7 +230,7 @@ public class EyesisDCT {
dct_parameters.asym_pixels, // maximal number of non-zero pixels in asymmmetrical kernel
dct_parameters.asym_distance, // how far to seed a new pixel
dct_parameters.seed_size);
double [] sym_kernel = factorConvKernel.getSymKernel();
double [] sym_kernel = factorConvKernel.getSymKernel();
double [] asym_kernel = factorConvKernel.getAsymKernel();
int sym_kernel_inc_index = kernelNumHor * dct_parameters.dct_size;
int sym_kernel_start_index = (sym_kernel_inc_index * tileY + tileX) * dct_parameters.dct_size;
......@@ -255,7 +255,7 @@ public class EyesisDCT {
}
}
};
}
}
ImageDtt.startAndJoin(threads);
if (globalDebugLevel > 1) System.out.println("Threads done at "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
System.out.println("1.Threads done at "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
......@@ -263,11 +263,11 @@ public class EyesisDCT {
return dct_kernel;
}
public boolean createDCTKernels(
EyesisCorrectionParameters.DCTParameters dct_parameters,
int srcKernelSize,
int threadsMax, // maximal number of threads to launch
int threadsMax, // maximal number of threads to launch
boolean updateStatus,
int debugLevel
){
......@@ -286,7 +286,7 @@ public class EyesisDCT {
}
}
showDoubleFloatArrays sdfa_instance = new showDoubleFloatArrays(); // just for debugging?
for (int chn=0;chn<eyesisCorrections.usedChannels.length;chn++){
if (eyesisCorrections.usedChannels[chn] && (sharpKernelPaths[chn]!=null) && (kernels[chn]==null)){
......@@ -303,7 +303,7 @@ public class EyesisDCT {
kernel_sharp_stack, // final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
srcKernelSize, // final int kernelSize, // 64
dct_parameters, // final double blurSigma,
threadsMax, // maximal number of threads to launch
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel); // update status info
int sym_width = kernels.numHor * kernels.dct_size;
......@@ -331,7 +331,7 @@ public class EyesisDCT {
}
FileSaver fs=new FileSaver(imp_sym);
fs.saveAsTiffStack(symPath);
// sdfa_instance.showArrays(kernels.sym_kernels, sym_width, sym_height, true, imp_kernel_sharp.getTitle()+"-sym");
int asym_width = kernels.numHor * kernels.asym_size;
......@@ -385,11 +385,11 @@ public class EyesisDCT {
final int xTile, // horizontal number of kernel to extract
final int yTile) // vertical number of kernel to extract
{
final int kernelWidth=kernelStack.getWidth();
final int kernelNumHor=kernelWidth/kernelSize;
double [] kernel = new double [kernelSize*kernelSize];
extractOneKernel((float[]) kernelStack.getPixels(chn+1), // array of combined square kernels, each
extractOneKernel((float[]) kernelStack.getPixels(chn+1), // array of combined square kernels, each
kernel, // will be filled, should have correct size before call
kernelNumHor, // number of kernels in a row
xTile, // horizontal number of kernel to extract
......@@ -397,7 +397,7 @@ public class EyesisDCT {
return kernel;
}
// to be used in threaded method
private void extractOneKernel(float [] pixels, // array of combined square kernels, each
private void extractOneKernel(float [] pixels, // array of combined square kernels, each
double [] kernel, // will be filled, should have correct size before call
int numHor, // number of kernels in a row
int xTile, // horizontal number of kernel to extract
......@@ -490,7 +490,7 @@ public class EyesisDCT {
double [] weights = {0.25,0.125,0.125,0.125,0.125,0.0625,0.0625,0.0625,0.0625};
int src_center = src_size / 2; // 32
int dst_center = dst_size / 2; // 7
int src_len = src_size*src_size;
int src_len = src_size*src_size;
for (int i = 0; i< dst_size; i++){
int src_i = (i - dst_center)*decimation + src_center;
if ((src_i >= 0) && (src_i < src_size)) {
......@@ -513,7 +513,7 @@ public class EyesisDCT {
}
}
}
private double [] createAntiperiodicWindow(
int dct_size)
{
......@@ -528,12 +528,12 @@ public class EyesisDCT {
double [] window = new double [n4 * n4];
for (int i =0; i < n4; i++){
for (int j =0; j < n4; j++){
window[i * n4 + j] = wnd[i]*wnd[j];
window[i * n4 + j] = wnd[i]*wnd[j];
}
}
return window;
}
public double []makeAntiperiodic(
int dct_size,
double [] src_kernel) // 16*dct_zize*dct_zize
......@@ -545,11 +545,11 @@ public class EyesisDCT {
src_kernel, // 16*dct_zize*dct_zize
window, // 16*dct_zize*dct_zize
antiperiodic_kernel); // 4*dct_zize*dct_zize
return antiperiodic_kernel;
}
private void makeAntiperiodic(
int dct_size,
double [] src_kernel, // 16*dct_zize*dct_zize
......@@ -569,12 +569,12 @@ public class EyesisDCT {
int src_index1= (isrcp) * n4 + jsrc;
int src_index2= (isrc) * n4 + jsrcp;
int src_index3= (isrcp) * n4 + jsrcp;
antiperiodic_kernel[dst_index] =
src_kernel[src_index0] * window[src_index0]
- src_kernel[src_index1] * window[src_index1]
- src_kernel[src_index2] * window[src_index2]
+ src_kernel[src_index3] * window[src_index3];
+ src_kernel[src_index3] * window[src_index3];
}
}
}
......@@ -586,7 +586,7 @@ public class EyesisDCT {
public boolean readDCTKernels(
EyesisCorrectionParameters.DCTParameters dct_parameters,
int srcKernelSize,
int threadsMax, // maximal number of threads to launch
int threadsMax, // maximal number of threads to launch
boolean updateStatus,
int debugLevel
){
......@@ -649,12 +649,12 @@ public class EyesisDCT {
for (int nc = 0; nc < nColors; nc++){
float [] pixels = (float[]) kernel_sym_stack.getPixels(nc + 1);
kernels[chn].sym_kernels[nc]= new double[pixels.length];
kernels[chn].sym_kernels[nc]= new double[pixels.length];
for (int i = 0; i<pixels.length; i++){
kernels[chn].sym_kernels[nc][i] = pixels[i];
}
pixels = (float[]) kernel_asym_stack.getPixels(nc + 1);
kernels[chn].asym_kernels[nc]= new double[pixels.length];
kernels[chn].asym_kernels[nc]= new double[pixels.length];
for (int i = 0; i<pixels.length; i++){
kernels[chn].asym_kernels[nc][i] = pixels[i];
}
......@@ -745,7 +745,7 @@ public class EyesisDCT {
// kernels[chn].asym_val[nc][tileY][tileX][i] /= scale_asym;
kernels[chn].asym_val[nc][tileY][tileX][i] *= k; // includes correction for different number of pixels in r,b(1/4) and G (2/4)
}
if ((debugLevel > 0) && (tileY==67) && (tileX==125)) {
System.out.println("nc="+nc+" sum="+scale_asym+", k="+k +", k*scale_asym="+(k*scale_asym)+", normalized:");
......@@ -770,13 +770,13 @@ public class EyesisDCT {
// sym_kernel pre-compensation for window function
if (dct_parameters.antiwindow) {
for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) {
kernels[chn].st_kernels[nc][tileY][tileX][i] *= inv_window[i];
kernels[chn].st_kernels[nc][tileY][tileX][i] *= inv_window[i];
}
}
if (scale_asym != 1.0){
for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) {
kernels[chn].st_kernels[nc][tileY][tileX][i] *= scale_asym;
kernels[chn].st_kernels[nc][tileY][tileX][i] *= scale_asym;
}
}
......@@ -789,7 +789,7 @@ public class EyesisDCT {
scale_sym += norm_sym_weights[i]*kernels[chn].st_kernels[nc][tileY][tileX][i];
}
for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) {
kernels[chn].st_kernels[nc][tileY][tileX][i] /= scale_sym;
kernels[chn].st_kernels[nc][tileY][tileX][i] /= scale_sym;
}
if ((debugLevel > 0) && (tileY== dct_parameters.tileY) && (tileX==dct_parameters.tileX)) {
System.out.println("chn="+chn+" tileY="+tileY+", tileX"+tileY+" scale_sym="+scale_sym);
......@@ -806,7 +806,7 @@ public class EyesisDCT {
}
// scale so multiplication will not change normalization
for (int i=0; i < kernels[chn].st_kernels[nc][tileY][tileX].length;i++) {
kernels[chn].st_kernels[nc][tileY][tileX][i] *= dct_size;
kernels[chn].st_kernels[nc][tileY][tileX][i] *= dct_size;
}
// kernels[chn].st_kernels[nc][tileY][tileX]= dtt.dttt_iii(kernels[chn].st_kernels[nc][tileY][tileX]);
......@@ -826,7 +826,7 @@ public class EyesisDCT {
}
return true;
}
public void showKernels(){
// System.out.println("showKernels(): kernels.length="+kernels.length);
for (int chn=0;chn < kernels.length; chn++){
......@@ -922,7 +922,7 @@ public class EyesisDCT {
}
// public boolean isChannelEnabled(int channel){
// return ((channel>=0) && (channel<this.usedChannels.length) && this.usedChannels[channel]);
// return ((channel>=0) && (channel<this.usedChannels.length) && this.usedChannels[channel]);
// }
......@@ -936,7 +936,7 @@ public class EyesisDCT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
int convolveFFTSize, // 128 - fft size, kernel size should be size/2
final int threadsMax, // maximal number of threads to launch
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel)
{
......@@ -1011,8 +1011,8 @@ public class EyesisDCT {
imp_src=eyesisCorrections.JP4_INSTANCE.demuxImage(imp_composite, subchannel);
if (imp_src==null) imp_src=imp_composite; // not a composite image
// do we need to add any properties?
} else {
// do we need to add any properties?
} else {
imp_src=new ImagePlus(sourceFiles[nFile]);
// (new JP46_Reader_camera(false)).decodeProperiesFromInfo(imp_src); // decode existent properties from info
eyesisCorrections.JP4_INSTANCE.decodeProperiesFromInfo(imp_src); // decode existent properties from info
......@@ -1039,7 +1039,7 @@ public class EyesisDCT {
rgbParameters,
convolveFFTSize, // 128 - fft size, kernel size should be size/2
scaleExposure,
threadsMax, // maximal number of threads to launch
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
// warp result (add support for different color modes)
......@@ -1060,7 +1060,7 @@ public class EyesisDCT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
}
public ImagePlus processDCTChannelImage(
ImagePlus imp_src, // should have properties "name"(base for saving results), "channel","path"
......@@ -1073,14 +1073,14 @@ public class EyesisDCT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
int convolveFFTSize, // 128 - fft size, kernel size should be size/2
double scaleExposure,
final int threadsMax, // maximal number of threads to launch
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final int debugLevel){
boolean advanced=this.correctionsParameters.zcorrect || this.correctionsParameters.equirectangular;
boolean crop= advanced? true: this.correctionsParameters.crop;
boolean rotate= advanced? false: this.correctionsParameters.rotate;
boolean crop= advanced? true: this.correctionsParameters.crop;
boolean rotate= advanced? false: this.correctionsParameters.rotate;
double JPEG_scale= advanced? 1.0: this.correctionsParameters.JPEG_scale;
boolean toRGB= advanced? true: this.correctionsParameters.toRGB;
boolean toRGB= advanced? true: this.correctionsParameters.toRGB;
// may use this.StartTime to report intermediate steps execution times
String name=(String) imp_src.getProperty("name");
......@@ -1134,7 +1134,7 @@ public class EyesisDCT {
pixels[y*width+x+width ] *= dct_parameters.scale_b;
}
}
} else { // assuming GR/BG pattern
System.out.println("Applying fixed color gain correction parameters: Gr="+
dct_parameters.novignetting_r+", Gg="+dct_parameters.novignetting_g+", Gb="+dct_parameters.novignetting_b);
......@@ -1168,9 +1168,9 @@ public class EyesisDCT {
dct_parameters.dct_size/2, // addTop
dct_parameters.dct_size/2, // addRight
dct_parameters.dct_size/2 // addBottom
);
);
// Split into Bayer components, oversample, increase canvas
// Split into Bayer components, oversample, increase canvas
ImageStack stack= eyesisCorrections.bayerToStack(
result, // source Bayer image, linearized, 32-bit (float))
splitParameters);
......@@ -1180,7 +1180,7 @@ public class EyesisDCT {
float [] pixels;
int width = stack.getWidth();
int height = stack.getHeight();
for (int c = 0; c <3; c++){
pixels = (float[]) stack.getPixels(c+1);
for (int i = 0; i<pixels.length; i++){
......@@ -1190,11 +1190,11 @@ public class EyesisDCT {
chn_avg[0] /= width*height/4;
chn_avg[1] /= width*height/4;
chn_avg[2] /= width*height/2;
System.out.println("Split channels averages: R="+chn_avg[0]+", G="+chn_avg[2]+", B="+chn_avg[1]);
System.out.println("Split channels averages: R="+chn_avg[0]+", G="+chn_avg[2]+", B="+chn_avg[1]);
}
if (!this.correctionsParameters.debayer) {
result= new ImagePlus(titleFull, stack);
result= new ImagePlus(titleFull, stack);
eyesisCorrections.saveAndShow(result, this.correctionsParameters);
return result;
}
......@@ -1267,7 +1267,7 @@ public class EyesisDCT {
double [][] idct_data = new double [dct_data.length][];
for (int chn=0; chn<idct_data.length;chn++){
idct_data[chn] = image_dtt.lapped_idct(
dct_data[chn], // scanline representation of dcd data, organized as dct_size x dct_size tiles
dct_data[chn], // scanline representation of dcd data, organized as dct_size x dct_size tiles
dct_parameters.dct_size, // final int
dct_parameters.dct_window, //window_type
threadsMax,
......@@ -1296,7 +1296,7 @@ public class EyesisDCT {
(dct_parameters.denoise? dct_parameters.denoise_c:0.0), // final double denoise_c, // = 1.0; // maximal total smoothing of the color differences post-kernel (will compete with edge emphasis)
dct_parameters.denoise_y_corn, // final double denoise_y_corn, // = 0.5; // weight of the 4 corner pixels during denoise y (relative to 4 straight)
dct_parameters.denoise_c_corn, // final double denoise_c_corn, // = 0.5; // weight of the 4 corner pixels during denoise y (relative to 4 straight)
dct_parameters.dct_size, //, // final int threadsMax, // maximal number of threads to launch
dct_parameters.dct_size, //, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel)
if (debugLevel > 0) sdfa_instance.showArrays(
idct_data,
......@@ -1321,12 +1321,12 @@ public class EyesisDCT {
(tilesY + 1) * dct_parameters.dct_size,
true,
result.getTitle()+"-rbg_before");
idct_data = post_debayer( // debayer in pixel domain after aberration correction
idct_data, // final double [][] rbg, // yPrPb,
(tilesX + 1) * dct_parameters.dct_size, // final int width,
dct_parameters.dct_size, // final int step, // just for multi-threading efficiency?
dct_parameters.dct_size, // final int threadsMax, // maximal number of threads to launch
dct_parameters.dct_size, // final int threadsMax, // maximal number of threads to launch
debugLevel); // final int globalDebugLevel)
// add here YPrPb conversion, then edge_emphasis
if (debugLevel > -1) sdfa_instance.showArrays(
......@@ -1370,7 +1370,7 @@ public class EyesisDCT {
float [] pixels;
int width = stack.getWidth();
int height = stack.getHeight();
for (int c = 0; c <3; c++){
pixels = (float[]) stack.getPixels(c+1);
for (int i = 0; i<pixels.length; i++){
......@@ -1380,11 +1380,11 @@ public class EyesisDCT {
chn_avg[0] /= width*height;
chn_avg[1] /= width*height;
chn_avg[2] /= width*height;
System.out.println("Processed channels averages: R="+chn_avg[0]+", G="+chn_avg[2]+", B="+chn_avg[1]);
System.out.println("Processed channels averages: R="+chn_avg[0]+", G="+chn_avg[2]+", B="+chn_avg[1]);
}
if (!this.correctionsParameters.colorProc){
result= new ImagePlus(titleFull, stack);
result= new ImagePlus(titleFull, stack);
eyesisCorrections.saveAndShow(
result,
this.correctionsParameters);
......@@ -1409,7 +1409,7 @@ public class EyesisDCT {
CorrectionColorProc correctionColorProc=new CorrectionColorProc(eyesisCorrections.stopRequested);
double [][] yPrPb=new double [3][];
// if (dct_parameters.color_DCT){
// need to get YPbPr - not RGB here
// need to get YPbPr - not RGB here
// } else {
correctionColorProc.processColorsWeights(stack, // just gamma convert? TODO: Cleanup? Convert directly form the linear YPrPb
// 255.0/this.psfSubpixelShouldBe4/this.psfSubpixelShouldBe4, // double scale, // initial maximal pixel value (16))
......@@ -1439,7 +1439,9 @@ public class EyesisDCT {
}
if (toRGB) {
System.out.println("correctionColorProc.YPrPbToRGB");
if (debugLevel > 0){
System.out.println("correctionColorProc.YPrPbToRGB");
}
stack = YPrPbToRGB(yPrPb,
colorProcParameters.kr, // 0.299;
colorProcParameters.kb, // 0.114;
......@@ -1462,7 +1464,7 @@ public class EyesisDCT {
if (debugLevel > 1) System.out.println("Using full stack, including YPbPr");
}
result= new ImagePlus(titleFull, stack);
result= new ImagePlus(titleFull, stack);
// Crop image to match original one (scaled to oversampling)
if (crop){ // always crop if equirectangular
if (debugLevel > 1) System.out.println("cropping");
......@@ -1474,7 +1476,7 @@ public class EyesisDCT {
this.correctionsParameters);
}
}
// rotate the result
// rotate the result
if (rotate){ // never rotate for equirectangular
stack=eyesisCorrections.rotateStack32CW(stack);
}
......@@ -1494,7 +1496,7 @@ public class EyesisDCT {
ImagePlus imp_RGB;
stack=eyesisCorrections.convertRGB32toRGB16Stack(
stack,
rgbParameters);
rgbParameters);
titleFull=title+"-RGB48";
result= new ImagePlus(titleFull, stack);
......@@ -1611,7 +1613,7 @@ public class EyesisDCT {
final double [][] rbg, // yPrPb,
final int width,
final int step, // just for multi-threading efficiency?
final int threadsMax, // maximal number of threads to launch
final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel)
{
final double [][] rbg_new = new double [rbg.length][rbg[0].length];
......@@ -1628,15 +1630,16 @@ public class EyesisDCT {
0.125, 0.25, 0.125,
0.0625, 0.125, 0.0625};
final double [][] kerns = {kern_rb,kern_rb,kern_g};
final int [] neib_indices = {-width-1,-width,-width+1,-1,0,1,width-1,width,width+1};
final int [] neib_indices = {-width-1,-width,-width+1,-1,0,1,width-1,width,width+1};
final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
@Override
public void run() {
int tileY,tileX;
double [] neibs = new double[9]; // pixels around current, first Y, then each color diff
for (int nTile = ai.getAndIncrement(); nTile < nTiles; nTile = ai.getAndIncrement()) {
......@@ -1665,7 +1668,7 @@ public class EyesisDCT {
}
}
};
}
}
ImageDtt.startAndJoin(threads);
return rbg_new;
}
......@@ -1683,7 +1686,7 @@ public class EyesisDCT {
final double denoise_c, // = 1.0; // maximal total smoothing of the color differences post-kernel (will compete with edge emphasis)
final double denoise_y_corn, // = 0.3; // weight of the 4 corner pixels during denoise y (relative to 4 straight)
final double denoise_c_corn, // = 0.3; // weight of the 4 corner pixels during denoise y (relative to 4 straight)
final int threadsMax, // maximal number of threads to launch
final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel)
{
final double [][] yPrPb_new = new double [yPrPb.length][yPrPb[0].length];
......@@ -1694,7 +1697,7 @@ public class EyesisDCT {
final int [][] probes = {{1,7},{3,5},{2,6},{0,8}}; // indices in [012/345/678] 3x3 square to calculate squared sums of differences
final int [][] kerns = {{ 1, 3, 5, 7}, {1, 3, 5, 7}, {0, 2, 6, 8}, {0, 2, 6, 8}}; // indices in [012/345/678] 3x3 square to convolve data
final double [][] kernsw = {{-1.0,1.0,1.0,-1.0},{1.0,-1.0,-1.0,1.0},{1.0,-1.0,-1.0,1.0},{-1.0,1.0,1.0,-1.0}}; // weights of kern elements
final int [] neib_indices = {-width-1,-width,-width+1,-1,0,1,width-1,width,width+1};
final int [] neib_indices = {-width-1,-width,-width+1,-1,0,1,width-1,width,width+1};
final double [][] kernsw_y = new double [kernsw.length][];
final double [][] kernsw_c = new double [kernsw.length][];
final double [] denoise_kern_y = {
......@@ -1710,10 +1713,10 @@ public class EyesisDCT {
kernsw_y[n] = new double [kernsw[n].length];
kernsw_c[n] = new double [kernsw[n].length];
for (int i = 0; i < kernsw[n].length; i++){
double dy = nonlin_y * ((n>=2)? nonlin_corn: 1.0);
double dc = nonlin_c * ((n>=2)? nonlin_corn: 1.0);
kernsw_y[n][i] = kernsw[n][i] * dy* dy;
kernsw_c[n][i] = kernsw[n][i] * dc* dc;
double dy = nonlin_y * ((n>=2)? nonlin_corn: 1.0);
double dc = nonlin_c * ((n>=2)? nonlin_corn: 1.0);
kernsw_y[n][i] = kernsw[n][i] * dy* dy;
kernsw_c[n][i] = kernsw[n][i] * dc* dc;
}
}
if (globalDebugLevel > 0){
......@@ -1749,7 +1752,8 @@ public class EyesisDCT {
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
@Override
public void run() {
int tileY,tileX;
double [] neibs = new double[9]; // pixels around current, first Y, then each color diff
double [] kern_y = new double[9]; // weights of neighbors to add to the current for Y
......@@ -1830,11 +1834,11 @@ public class EyesisDCT {
}
for (int i = 0; i<kern_y.length; i++){
yPrPb_new[0][indx] += neibs[i]*kern_y[i];
yPrPb_new[0][indx] += neibs[i]*kern_y[i];
}
for (int n = 1;n < 3; n++){ //color components
for (int i = 0; i < neibs.length; i++){
yPrPb_new[n][indx] += yPrPb[0][indx+neib_indices[i]]*kern_c[i];
yPrPb_new[n][indx] += yPrPb[0][indx+neib_indices[i]]*kern_c[i];
}
}
}
......@@ -1843,13 +1847,13 @@ public class EyesisDCT {
}
}
};
}
}
ImageDtt.startAndJoin(threads);
return yPrPb_new;
}
public void debayer_rbg(
ImageStack stack_rbg){
debayer_rbg(stack_rbg, 1.0);
......@@ -1893,10 +1897,10 @@ public class EyesisDCT {
if (odd_col){ // GB site
fpixels_r[indx] = 0.5f*(
fpixels_r[indx+av_col[row_type][col_type][0]]+
fpixels_r[indx+av_col[row_type][col_type][1]]);
fpixels_r[indx+av_col[row_type][col_type][1]]);
fpixels_b[indx] = 0.5f*(
fpixels_b[indx+av_row[row_type][col_type][0]]+
fpixels_b[indx+av_row[row_type][col_type][1]]);
fpixels_b[indx+av_row[row_type][col_type][1]]);
} else { // !odd col // B site
fpixels_r[indx] = 0.25f*(
fpixels_r[indx+av_xcross[row_type][col_type][0]]+
......@@ -1907,10 +1911,10 @@ public class EyesisDCT {
fpixels_g[indx+av_plus[row_type][col_type][0]]+
fpixels_g[indx+av_plus[row_type][col_type][1]]+
fpixels_g[indx+av_plus[row_type][col_type][2]]+
fpixels_g[indx+av_plus[row_type][col_type][3]]);
fpixels_g[indx+av_plus[row_type][col_type][3]]);
}
} else { // !odd_row
} else { // !odd_row
if (odd_col){ // R site
fpixels_b[indx] = 0.25f*(
fpixels_b[indx+av_xcross[row_type][col_type][0]]+
......@@ -1921,17 +1925,17 @@ public class EyesisDCT {
fpixels_g[indx+av_plus[row_type][col_type][0]]+
fpixels_g[indx+av_plus[row_type][col_type][1]]+
fpixels_g[indx+av_plus[row_type][col_type][2]]+
fpixels_g[indx+av_plus[row_type][col_type][3]]);
fpixels_g[indx+av_plus[row_type][col_type][3]]);
} else { // !odd col // G site
fpixels_r[indx] = 0.5f*(
fpixels_r[indx+av_row[row_type][col_type][0]]+
fpixels_r[indx+av_row[row_type][col_type][1]]);
fpixels_r[indx+av_row[row_type][col_type][1]]);
fpixels_b[indx] = 0.5f*(
fpixels_b[indx+av_col[row_type][col_type][0]]+
fpixels_b[indx+av_col[row_type][col_type][1]]);
fpixels_b[indx+av_col[row_type][col_type][1]]);
}
}
}
}
}
if (scale !=1.0){
for (int i = 0; i< fpixels_r.length; i++){
......@@ -1941,6 +1945,6 @@ public class EyesisDCT {
}
}
}
}
......@@ -776,7 +776,7 @@ private Panel panel1,
Runtime runtime = Runtime.getRuntime();
runtime.gc();
if (DEBUG_LEVEL>0) System.out.println("--- Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")");
CLT_PARAMETERS.batch_run = false;
if (label==null) return;
/* ======================================================================== */
if (label.equals("Configure spilt")) {
......@@ -5051,7 +5051,6 @@ private Panel panel1,
RGB_PARAMETERS, // EyesisCorrectionParameters.RGBParameters rgbParameters,
THREADS_MAX, // final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, // final boolean updateStatus,
false, // final boolean batch_mode,
DEBUG_LEVEL); //final int debugLevel);
if (!OK) {
String msg="Image data not initialized, run 'CLT 3D' command first";
......@@ -5059,18 +5058,9 @@ private Panel panel1,
IJ.showMessage("Error",msg);
}
/*
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
null, // use as default directory if path==null
true,
PROPERTIES);
}
*/
} else if (label.equals("CLT batch process")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
CLT_PARAMETERS.batch_run = true;
EYESIS_CORRECTIONS.setDebug(DEBUG_LEVEL);
if (QUAD_CLT == null){
QUAD_CLT = new QuadCLT (
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -269,7 +269,7 @@ public class MacroCorrelation {
clt_parameters.corr_magic_scale, // still not understood coefficient that reduces reported disparity value. Seems to be around 0.85
clt_parameters.shift_x, // final int shiftX, // shift image horizontally (positive - right) - just for testing
clt_parameters.shift_y, // final int shiftY, // shift image vertically (positive - down)
31, // clt_parameters.tileX, // final int debug_tileX,
clt_parameters.batch_run? -1: 31, // clt_parameters.tileX, // final int debug_tileX,
10, // clt_parameters.tileY, // final int debug_tileY,
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
true, // no convolve
......
......@@ -732,7 +732,7 @@ public class MeasuredLayers {
int st2 = 2 * superTileSize;
int st_half = superTileSize/2;
double [][] ds = new double [2][st2*st2];
final int dbg_tile = ((stX == 22) && (stY == 19)) ? (5 + 7*16) : -1;// 50397;
final int dbg_tile = -1; // = ((stX == 22) && (stY == 19)) ? (5 + 7*16) : -1;// 50397;
int num_selected = 0;
int smpl_center = mlfp.smplSide /2;
......@@ -1023,7 +1023,7 @@ public class MeasuredLayers {
int st2 = 2 * superTileSize;
int st_half = superTileSize/2;
double [][] ds = new double [2][st2*st2];
final int dbg_tile = ((stX == 22) && (stY == 19)) ? (5 + 7*16) : -1;// 50397;
final int dbg_tile =-1; // ((stX == 22) && (stY == 19)) ? (5 + 7*16) : -1;// 50397;
int num_selected = 0;
int smpl_center = mlfp.smplSide /2;
......
......@@ -1668,7 +1668,9 @@ public class QuadCLT {
}
if (toRGB) {
System.out.println("correctionColorProc.YPrPbToRGB");
if (debugLevel > 0){
System.out.println("correctionColorProc.YPrPbToRGB");
}
stack = YPrPbToRGB(yPrPb,
colorProcParameters.kr, // 0.299;
colorProcParameters.kb, // 0.114;
......@@ -2315,7 +2317,9 @@ public class QuadCLT {
}
if (toRGB) {
System.out.println("correctionColorProc.YPrPbToRGB");
if (debugLevel > 0){
System.out.println("correctionColorProc.YPrPbToRGB");
}
stack = YPrPbToRGB(yPrPb,
colorProcParameters.kr, // 0.299;
colorProcParameters.kb, // 0.114;
......@@ -2890,7 +2894,9 @@ public class QuadCLT {
}
if (toRGB) {
System.out.println("correctionColorProc.YPrPbToRGB");
if (debugLevel > 0){
System.out.println("correctionColorProc.YPrPbToRGB");
}
stack = YPrPbToRGB(yPrPb,
colorProcParameters.kr, // 0.299;
colorProcParameters.kb, // 0.114;
......@@ -3315,7 +3321,6 @@ public class QuadCLT {
infinity_corr, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
updateStatus,
false, // batch_mode
debugLevel);
Runtime.getRuntime().gc();
if (debugLevel >-1) System.out.println("Processing set "+(nSet+1)+" (of "+setNames.size()+") finished at "+
......@@ -3562,8 +3567,8 @@ public class QuadCLT {
final boolean infinity_corr, // calculate and apply geometry correction at infinity
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode, //no debug images
final int debugLevel){
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
boolean advanced=this.correctionsParameters.zcorrect || this.correctionsParameters.equirectangular;
// boolean crop= advanced? true: this.correctionsParameters.crop;
// boolean rotate= advanced? false: this.correctionsParameters.rotate;
......@@ -3807,7 +3812,6 @@ public class QuadCLT {
// visualize correlation results
if (clt_corr_combo!=null){
if (disparity_map != null){
// if (!batch_mode && !infinity_corr && clt_parameters.show_map && (debugLevel > -1)){
if (!batch_mode && clt_parameters.show_map && (debugLevel > -1)){
sdfa_instance.showArrays(
disparity_map,
......@@ -4241,7 +4245,9 @@ public class QuadCLT {
}
String titleFull = "";
if (toRGB) {
System.out.println("correctionColorProc.YPrPbToRGB");
if (debugLevel > 0){
System.out.println("correctionColorProc.YPrPbToRGB");
}
stack = YPrPbToRGB(yPrPb,
colorProcParameters.kr, // 0.299;
colorProcParameters.kb, // 0.114;
......@@ -5223,7 +5229,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
false, // batch_mode
// false, // batch_mode
debugLevel);
Runtime.getRuntime().gc();
System.out.println("showCLTPlanes(): processing finished at "+
......@@ -5250,7 +5256,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
false, // boolean batch_mode,
// false, // boolean batch_mode,
debugLevel);
Runtime.getRuntime().gc();
System.out.println("assignCLTPlanes(): processing finished at "+
......@@ -5279,7 +5285,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
false, // batch_mode
// false, // batch_mode
debugLevel);
// CLTPass3d last_scan = tp.clt_3d_passes.get(tp.clt_3d_passes.size() -1); // get last one
......@@ -5566,7 +5572,7 @@ public class QuadCLT {
adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus,// final boolean updateStatus,
false, // final boolean batch_mode,
// false, // final boolean batch_mode,
debugLevel); // final int debugLevel)
......@@ -5581,7 +5587,6 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
false, // final boolean batch_mode,
debugLevel);
}
......@@ -6045,9 +6050,9 @@ public class QuadCLT {
boolean adjust_poly,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run;
int debugLevelInner = batch_mode ? -5: debugLevel;
boolean update_disp_from_latest = clt_parameters.lym_update_disp ; // true;
int max_tries = clt_parameters.lym_iter; // 25;
......@@ -6361,13 +6366,11 @@ public class QuadCLT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
// final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
final int debugLevelInner = batch_mode ? -3: debugLevel;
// final int tilesX = tp.getTilesX();
// final int tilesY = tp.getTilesY();
final double trustedCorrelation = tp.getTrustedCorrelation();
final int max_expand = 500; // 150; // 30;
final boolean show_retry_far = clt_parameters.show_retry_far && false; // (max_expand <= 10);
......@@ -6569,7 +6572,6 @@ public class QuadCLT {
/// int next_pass = tp.clt_3d_passes.size(); //
tp.secondPassSetup( // prepare tile tasks for the second pass based on the previous one(s)
// final double [][][] image_data, // first index - number of image in a quad
clt_parameters,
clt_parameters.stUsePass2, // use supertiles
bg_pass,
......@@ -6587,7 +6589,6 @@ public class QuadCLT {
geometryCorrection,
threadsMax, // maximal number of threads to launch
updateStatus,
batch_mode,
debugLevelInner);
// Save tp.clt_3d_passes.size() to roll back without restarting the program
......@@ -7035,9 +7036,9 @@ public class QuadCLT {
EyesisCorrectionParameters.RGBParameters rgbParameters,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run;
this.startStepTime=System.nanoTime();
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
......@@ -8155,9 +8156,9 @@ public class QuadCLT {
final double [] referenceExposures, // =eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
final double [] scaleExposures, // = new double[channelFiles.length]; //
final boolean [][] saturation_imp, // = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
final boolean batch_mode, // disable any debug images
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
String [] sourceFiles=correctionsParameters.getSourcePaths();
int maxChn = 0;
for (int i = 0; i < setFiles.get(nSet).size(); i++){
......@@ -8410,6 +8411,7 @@ public class QuadCLT {
final boolean updateStatus,
final int debugLevel)
{
final int debugLevelInner=clt_parameters.batch_run? -2: debugLevel;
this.startTime=System.nanoTime();
String [] sourceFiles=correctionsParameters.getSourcePaths();
boolean [] enabledFiles=new boolean[sourceFiles.length];
......@@ -8439,7 +8441,7 @@ public class QuadCLT {
} else {
if (debugLevel>0) System.out.println(numFilesToProcess+ " files to process (of "+sourceFiles.length+"), "+numImagesToProcess+" images to process");
}
double [] referenceExposures=eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
double [] referenceExposures=eyesisCorrections.calcReferenceExposures(debugLevelInner); // multiply each image by this and divide by individual (if not NaN)
int [][] fileIndices=new int [numImagesToProcess][2]; // file index, channel number
int index=0;
for (int nFile=0;nFile<enabledFiles.length;nFile++){
......@@ -8469,7 +8471,11 @@ public class QuadCLT {
}
setFiles.get(setNames.indexOf(setName)).add(new Integer(nFile));
}
boolean batch_dbg = correctionsParameters.clt_batch_dbg1 && (setNames.size() < 2) ;
// enable debug for single-image when clt_batch_dbg1 is on
if (correctionsParameters.clt_batch_dbg1 && (setNames.size() < 2)) {
clt_parameters.batch_run = false; // disable batch_run for single image if clt_batch_dbg1 is on
}
// Do per 4-image set processing
int nSet = 0;
......@@ -8490,8 +8496,7 @@ public class QuadCLT {
referenceExposures, //final double [] referenceExposures, // =eyesisCorrections.calcReferenceExposures(debugLevel); // multiply each image by this and divide by individual (if not NaN)
scaleExposures, // final double [] scaleExposures, // = new double[channelFiles.length]; //
saturation_imp, // final boolean [][] saturation_imp, // = (clt_parameters.sat_level > 0.0)? new boolean[channelFiles.length][] : null;
!batch_dbg, // final boolean batch_mode, // disable any debug images
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
// once per quad here
if (imp_srcs == null) continue;
......@@ -8565,7 +8570,7 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
debugLevelInner);
if (ok) {
System.out.println("Adjusting extrinsics");
extrinsicsCLT(
......@@ -8573,8 +8578,7 @@ public class QuadCLT {
false, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
!batch_dbg, // final boolean batch_mode,
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
}
}
if (correctionsParameters.clt_batch_poly) {
......@@ -8590,7 +8594,7 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
debugLevelInner);
if (ok) {
System.out.println("Adjusting polynomial fine crorection");
extrinsicsCLT(
......@@ -8598,8 +8602,7 @@ public class QuadCLT {
true, // adjust_poly,
threadsMax, //final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
!batch_dbg, // final boolean batch_mode,
debugLevel); // final int debugLevel)
debugLevelInner); // final int debugLevel)
}
}
......@@ -8618,9 +8621,8 @@ public class QuadCLT {
false, // apply_corr, // calculate and apply additional fine geometry correction
false, // infinity_corr, // calculate and apply geometry correction at infinity
threadsMax, // maximal number of threads to launch
!batch_dbg, // batch_mode
updateStatus,
debugLevel);
debugLevelInner);
}
if (correctionsParameters.clt_batch_explore) {
if (tp != null) tp.resetCLTPasses();
......@@ -8635,7 +8637,7 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
debugLevel);
debugLevelInner);
if (ok) {
System.out.println("Explore 3d space");
expandCLTQuad3d( // returns ImagePlus, but it already should be saved/shown
......@@ -8648,8 +8650,7 @@ public class QuadCLT {
rgbParameters,
threadsMax, // maximal number of threads to launch
updateStatus,
!batch_dbg, // final boolean batch_mode,
debugLevel);
debugLevelInner);
} else continue;
} else continue; // if (correctionsParameters.clt_batch_explore)
......@@ -8660,8 +8661,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
!batch_dbg, // batch_mode
debugLevel);
debugLevelInner);
} else continue; // if (correctionsParameters.clt_batch_surf)
......@@ -8671,8 +8671,7 @@ public class QuadCLT {
geometryCorrection,
threadsMax,
updateStatus,
!batch_dbg, // boolean batch_mode,
debugLevel);
debugLevelInner);
if (!ok) continue;
} else continue; // if (correctionsParameters.clt_batch_assign)
......@@ -8683,8 +8682,8 @@ public class QuadCLT {
rgbParameters, // EyesisCorrectionParameters.RGBParameters rgbParameters,
threadsMax, // final int threadsMax, // maximal number of threads to launch
updateStatus, // final boolean updateStatus,
!batch_dbg, // final boolean batch_mode,
debugLevel); // final int debugLevel)
// !clt_parameters.batch_run, // !batch_dbg, // final boolean batch_mode,
debugLevelInner); // final int debugLevel)
if (!ok) continue;
} else continue; // if (correctionsParameters.clt_batch_gen3d)
......
......@@ -663,9 +663,9 @@ public class SuperTiles{
int numMax = 0;
int lo = 0;
int hi = 1;
if ((globalDebugLevel > -1 ) && (nsTile == 795)) {
System.out.println(nsTile);
}
// if ((globalDebugLevel > -1 ) && (nsTile == 795)) {
// System.out.println("getMaxMinMax(): nsTile="+nsTile);
// }
while (hi < numBins) {
// looking for next max
while ((hi < numBins) && (dh[hi] >= dh[hi - 1])) hi++; // flat or higher - continue
......@@ -949,9 +949,9 @@ public class SuperTiles{
}
}
for (int nsTile = 0; nsTile < sTiles; nsTile++){
if (nsTile == 795){
System.out.println("showMaxMinMax(), nsTile="+nsTile);
}
// if (nsTile == 795){
// System.out.println("showMaxMinMax(), nsTile="+nsTile);
// }
int stileY = nsTile / sTilesX;
int stileX = nsTile % sTilesX;
int x0 = stileX * (numBins + 1);
......@@ -1580,6 +1580,9 @@ public class SuperTiles{
final double [][][][] plane_disp_strength = new double [nStiles][][][];
// DEBUG feature:
final double [][] zero_tilts = {{0.0,0.0}}; // set to null for float
if (debugLevel > -1) {
System.out.println("getPlaneDispStrengthsST(x): debugLevel == "+debugLevel);
}
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
......
......@@ -5,7 +5,7 @@
** Copyright (C) 2017 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
**
** TileAssignment.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
......@@ -38,7 +38,7 @@ public class TileAssignment {
private double [][] tile_tones;
private double [][][] tone_diff_weight; // for each surface (not image) tile, for each of 8 directions,
//a pair of normalized tone difference and weight (both weight and diff == 0.0 for connections to/from undefined tiles
private double kR = 1.0; // relative weight of red to green ratio
private double kR = 1.0; // relative weight of red to green ratio
private double kB = 1.0; // relative weight of blue to green ratio
private double fatZero = 0.01; // for colors, normalized to 0..1.0 range
private int surfTilesX;
......@@ -48,35 +48,35 @@ public class TileAssignment {
private TileNeibs tnImage;
private TileNeibs tnSurface;
private boolean [][][] valid_surf; // per measured layer, per surface tile, per surface layer
// from clt_parameters
private double dispNorm;
private TACosts cost_coeff;
private double minFgBg; // = 0.1; // Minimal foreground/ background separation to look for weak FG edge
private double minFgEdge; // = 0.2; // Minimal foreground edge strength (stronger edges will have proportionally smaller costs)
private double minColSep; // = 0.05; // Minimal surface separation that requires color change
private double minColDiff; // = 0.01; // Minimal color variation (larger proportionally reduces cost)
private double minColSep; // = 0.05; // Minimal surface separation that requires color change
private double minColDiff; // = 0.01; // Minimal color variation (larger proportionally reduces cost)
private double dispOutlier; // = 1.0; // Disparity difference limit (to handle outliers)
private double strengthDiffPwr; // = 0.25; // Strength power when calculating disparity error
private double strengthBestPwr; // = 0.0; // Strength power when calculating disparity error over best
private double strengthDiff9Pwr; // = 0.5; // Strength power when calculating disparity error for group of 9
private double taColSigma; // = 1.5; // Gaussian sigma to blur color difference between tiles along each direction
private double taColFraction; // = 0.3; // Relative amount of the blurred color difference in the mixture
private double taColFraction; // = 0.3; // Relative amount of the blurred color difference in the mixture
private double shrinkWeakFgnd = 0.5; // 0.5; //reduce cost of multiple weak_fgnd links of the same tile
private double shrinkColor = 0.5; // 0.0; //reduce cost of surface transitions w/o color change
private double shrinkColor = 0.5; // 0.0; //reduce cost of surface transitions w/o color change
static double [] NEIB_WEIGHTS = {0.5,0.25, 0.5, 0.25, 0.5,0.25, 0.5, 0.25, 1.0};
static int INDEX_R = 0;
static int INDEX_B = 1;
static int INDEX_G = 2;
static int INDEX_A = 3;
public boolean mutual_weak_fgnd = false; // set to true when using 3x3 grid, false for 5x5;
public class TACosts{
public double empty; // Cost of a tile that is not assigned
public double nolink; // Cost of a tile not having any neighbor in particular direction
......@@ -131,50 +131,51 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
public void set(double [] vals)
{
this.empty = vals[0];
this.nolink = vals[1];
this.nolink = vals[1];
this.swtch = vals[2];
this.color = vals[3];
this.diff = vals[4];
this.diff_best = vals[5];
this.diff9 = vals[6];
this.weak_fgnd = vals[7];
this.weak_fgnd = vals[7];
this.flaps = vals[8];
this.ml_mismatch = vals[9];
}
public double [] toArray(){
double [] rslt = {
this.empty,
this.nolink,
this.nolink,
this.swtch,
this.color,
this.diff,
this.diff_best,
this.diff9,
this.weak_fgnd,
this.weak_fgnd,
this.flaps,
this.ml_mismatch
};
return rslt;
}
public String [] getTitles()
{
String [] titles = {
"empty",
"nolink",
"nolink",
"swtch",
"color",
"diff",
"diff_best",
"diff9",
"weak_fgnd",
"weak_fgnd",
"flaps",
"ml_mismatch"};
return titles;
}
@Override
public String toString()
{
String s = "";
......@@ -182,7 +183,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
s+= String.format("diff_best=%8.5f diff9= %8.5f weak_fgnd=%8.5f flaps=%8.5f ml_mismatch=%8.5f\n",diff_best, diff9, weak_fgnd, flaps, ml_mismatch);
return s;
}
public double dotProd (TACosts costs){
double [] these = toArray();
double [] other = costs.toArray();
......@@ -228,10 +229,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
set (these);
}
}
/**
*
*
* @param ts
* @param p3d
* @param tile_sel
......@@ -269,27 +270,27 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
setDispStrength(dispStrength);
setTones(p3d);
}
public void copyParams(EyesisCorrectionParameters.CLTParameters clt_parameters)
{
this.dispNorm = clt_parameters.plDispNorm;
this.minFgBg = clt_parameters.taMinFgBg;
this.minFgEdge = clt_parameters.taMinFgEdge;
this.minColSep = clt_parameters.taMinColSep;
this.minColDiff = clt_parameters.taMinColDiff;
this.minColSep = clt_parameters.taMinColSep;
this.minColDiff = clt_parameters.taMinColDiff;
this.dispOutlier = clt_parameters.taOutlier;
this.strengthDiffPwr = clt_parameters.taDiffPwr;
this.strengthBestPwr = clt_parameters.taBestPwr;
this.strengthDiff9Pwr = clt_parameters.taDiff9Pwr;
this.taColSigma = clt_parameters.taColSigma;
this.taColFraction = clt_parameters.taColFraction;
this.cost_coeff = new TACosts (clt_parameters);
this.cost_coeff.mul(new TACosts (0)); // make average ~=1.0 for each used component
}
public void setDispStrength(
double [][][] ds)
......@@ -302,10 +303,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
this.dispStrength[ml][nSurfTile] = new double[2]; // ds[ml][nTile];
this.dispStrength[ml][nSurfTile][0] = ds[ml][0][nTile];
this.dispStrength[ml][nSurfTile][1] = ds[ml][1][nTile];
}
}
}
}
public int getSurfTilesX(){
return surfTilesX;
}
......@@ -315,11 +316,11 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
// private int surfTilesX;
// private int surfTilesY;
public void setTones(CLTPass3d p3d)
{
double [][] tt = p3d.getTileRBGA(4);
this.tile_tones = new double [surfTilesX * surfTilesY][tt.length];
for (int nTile = 0; nTile < tt[0].length; nTile++){
int nSurfTile = ts.getSurfaceTileIndex(nTile);
......@@ -327,20 +328,21 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
this.tile_tones[nSurfTile][j] = tt[j][nTile];
}
}
this.tone_diff_weight = new double [surfTilesX * surfTilesY][8][2];
// final int numTiles = imgTilesX * imgTilesY;
final Thread[] threads = ImageDtt.newThreadArray(ts.getThreadsMax());
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int nSurfTile = ai.getAndIncrement(); nSurfTile < tone_diff_weight.length; nSurfTile = ai.getAndIncrement()) {
if (nSurfTile >= 0){
for (int dir = 0; dir < 4; dir++){
int nSurfTile1 = tnSurface.getNeibIndex(nSurfTile, dir);
if (nSurfTile1 >= 0){
tone_diff_weight[nSurfTile][dir] =
tone_diff_weight[nSurfTile][dir] =
getDiffWeight (
tile_tones[nSurfTile],
tile_tones[nSurfTile1]);
......@@ -351,7 +353,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
};
}
}
ImageDtt.startAndJoin(threads);
}
......@@ -366,7 +368,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
use_sqrt,
weighted); // final boolean weighted)
}
public double [][][] blurMixTones(
final double [][][] tone_diffs,
final double sigma,
......@@ -383,6 +385,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int dir = ai.getAndIncrement(); dir < 4; dir = ai.getAndIncrement()) {
for (int nSurfTile = 0; nSurfTile < num_tiles; nSurfTile++){
......@@ -393,7 +396,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
dir_blur[dir][nSurfTile] = dw;
dir_weight[dir][nSurfTile] = w;
}
DoubleGaussianBlur gb =new DoubleGaussianBlur();
DoubleGaussianBlur gb =new DoubleGaussianBlur();
gb.blurDouble(dir_blur[dir], surfTilesX, surfTilesY, sigma, sigma, 0.01);
gb.blurDouble(dir_weight[dir], surfTilesX, surfTilesY, sigma, sigma, 0.01);
if (weighted){
......@@ -417,22 +420,22 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
mixed_diff_weight[nSurfTile][dir][1] = rfract * tone_diffs[nSurfTile][dir][1] + fraction * dir_weight[dir][nSurfTile];
mixed_diff_weight[nSurfTile1][rdir][0] = mixed_diff_weight[nSurfTile][dir][0];
mixed_diff_weight[nSurfTile1][rdir][1] = mixed_diff_weight[nSurfTile][dir][1];
}
}
}
}
}
};
}
}
ImageDtt.startAndJoin(threads);
return mixed_diff_weight;
}
public void showToneDiffWeights3(String prefix){
String [] titles = {"diffs","sqrt","centers","weights"};
double [][] img_data = new double[titles.length][9 * surfTilesX * surfTilesY];
TileNeibs tnSurface3 = new TileNeibs( 3 * surfTilesX, 3 * surfTilesY);
TileNeibs tnSurface3 = new TileNeibs( 3 * surfTilesX, 3 * surfTilesY);
for (int nSurfTile = 0; nSurfTile < tone_diff_weight.length; nSurfTile++){
int [] txy = tnSurface.getXY(nSurfTile);
int [] txy3 = {3 * txy[0] + 1, 3 * txy[1] + 1};
......@@ -442,8 +445,8 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
sw += tone_diff_weight[nSurfTile][dir][1];
sdw += tone_diff_weight[nSurfTile][dir][0] * tone_diff_weight[nSurfTile][dir][1];
int nSurfTile3 = tnSurface3.getNeibIndex(tnSurface3.getIndex(txy3[0],txy3[1]),dir);
img_data[0][nSurfTile3] = tone_diff_weight[nSurfTile][dir][0];
img_data[1][nSurfTile3] = Math.sqrt(tone_diff_weight[nSurfTile][dir][0]);
img_data[0][nSurfTile3] = tone_diff_weight[nSurfTile][dir][0];
img_data[1][nSurfTile3] = Math.sqrt(tone_diff_weight[nSurfTile][dir][0]);
img_data[3][nSurfTile3] = tone_diff_weight[nSurfTile][dir][1];
if (tone_diff_weight[nSurfTile][dir][1] > 0.0) num_neibs ++;
}
......@@ -454,9 +457,9 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
sw /= num_neibs;
}
int nSurfTile3 = tnSurface3.getIndex(txy3[0],txy3[1]);
img_data[0][nSurfTile3] = sdw;
img_data[1][nSurfTile3] = Math.sqrt(sdw);
img_data[2][nSurfTile3] = sdw;
img_data[0][nSurfTile3] = sdw;
img_data[1][nSurfTile3] = Math.sqrt(sdw);
img_data[2][nSurfTile3] = sdw;
img_data[3][nSurfTile3] = sw;
}
(new showDoubleFloatArrays()).showArrays(img_data, 3 * surfTilesX, 3 * surfTilesY, true, prefix+"tone_diffs3", titles);
......@@ -478,15 +481,15 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (num_neibs > 0){
sw /= num_neibs;
}
img_data[0][nSurfTile] = sdw;
img_data[0][nSurfTile] = sdw;
img_data[1][nSurfTile] = sw;
}
String [] titles = {"diffs","weights"};
(new showDoubleFloatArrays()).showArrays(img_data, surfTilesX, surfTilesY, true, prefix+"tone_diffs1", titles);
}
private double [] getDiffWeight(
double [] tone1,
double [] tone2)
......@@ -524,12 +527,12 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
}
/**
* limit layer options for assigned cells to a single (selected) option, disable all negative ones
* @param tileLayers
*/
public void restrictSingle (
final int [][] tileLayers)
{
......@@ -547,7 +550,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
* Limit layer options for assigned cells to a multiple options per tile cell
* @param options
*/
public void restrictMulti (
final int [][][] options)
{
......@@ -595,9 +598,9 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
return diff;
}
/**
* Get absolute value of the normalized disparity difference from the measured value to the nearest surface
* Get absolute value of the normalized disparity difference from the measured value to the nearest surface
* @param ml measured layer (combo, quad, hor, vert)
* @param nSurfTile tile index in surface array (includes full supertiles)
* @return absolute value of the disparity error (scaled down for large disparities) to the nearest surface
......@@ -611,7 +614,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
// System.out.println("dispDiffBest("+ml+","+nSurfTile+")");
return best;
}
for (int ns = 0; ns < ts.getTileData()[nSurfTile].length; ns++){
double diff = dispDiff(ml, nSurfTile, ns);
double adiff = Math.abs(diff);
......@@ -621,10 +624,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
return best;
}
/**
* Get absolute value of the normalized disparity difference from the measured value to the farthest surface
* Used to estimate cost of un-assigned tiles
* Used to estimate cost of un-assigned tiles
* @param ml measured layer (combo, quad, hor, vert)
* @param nSurfTile tile index in surface array (includes full supertiles)
* @return absolute value of the disparity error (scaled down for large disparities) to the farthest surface
......@@ -647,7 +650,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
return worst;
}
public TACosts [] getTileCosts(
boolean all_tiles,
int [][] tileLayers)
......@@ -672,7 +675,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
null); // HashMap<Point,Integer> replacements)
}
} //for (int nSurfTile)
return ta_costs;
}
......@@ -698,12 +701,12 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
tileLayers, // int [][] tileLayers,
null); // HashMap<Point,Integer> replacements)
costs[nSurfTile] = cost_coeff.dotProd(ta_cost);
}
}
return costs;
}
public void showTileCost(
String prefix,
int [][] tileLayers)
......@@ -740,7 +743,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
tileLayers, // int [][] tileLayers,
null); // HashMap<Point,Integer> replacements)
ta_cost.mul(cost_coeff);
costs = ta_cost.toArray();
costs = ta_cost.toArray();
}
for (int i =0; i < cost_components.length; i++){
cost_components[i][nSurfTile] = costs[i];
......@@ -748,8 +751,8 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
(new showDoubleFloatArrays()).showArrays(cost_components, surfTilesX, surfTilesY, true, prefix+"cost_components", titles);
}
public TACosts [] statTileCosts(
int [][] tileLayers)
{
......@@ -760,7 +763,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (nSurfTile == 47459){
System.out.println("statTileCosts() nSurfTile="+nSurfTile);
}
boolean has_tile = false;
boolean has_block = false;
for (int ml = 0; ml < tileLayers.length; ml++) if(tileLayers[ml] != null) {
......@@ -780,7 +783,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
ta_stats[0].max(ta_cost);
ta_stats[1].add(ta_cost);
num_tiles++;
}
}
if (num_tiles > 0){
......@@ -788,7 +791,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
return ta_stats;
}
/**
* Get costs (not scaled) for the particular tile, add for all defined layers
* @param nSurfTile tile index in surface array (includes full supertiles)
......@@ -803,44 +806,44 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
{
TACosts costs = new TACosts();
int debugLevel = 0;
if (nSurfTile == 51360) { // 44831) { // 47459){
if (nSurfTile == -51360) { // 44831) { // 47459){
System.out.println("getTileCosts() nSurfTile="+nSurfTile);
debugLevel = 1;
}
int [][] around = new int [valid_ml.length][]; // contains layer + 1
for (int ml = 0; ml < valid_ml.length; ml++) if(valid_ml[ml]) {
around[ml] = new int [9];
around[ml] = new int [9];
}
int [] nSurfTiles = new int[9];
for (int dir = 0; dir < 9; dir++){
nSurfTiles[dir] = tnSurface.getNeibIndex(nSurfTile, dir);
if (nSurfTiles[dir] < 0) {
for (int ml = 0; ml < around.length; ml++) if (around[ml] != null){
around[ml][dir] = TileSurface.PROHOBITED;
around[ml][dir] = TileSurface.PROHOBITED;
}
} else {
for (int ml = 0; ml < around.length; ml++) if (around[ml] != null){
around[ml][dir] = tileLayers[ml][nSurfTiles[dir]];
around[ml][dir] = tileLayers[ml][nSurfTiles[dir]];
if (replacements != null){
Integer isurf = replacements.get(new Point(ml, nSurfTiles[dir]));
if (isurf != null) {
around[ml][dir] = isurf; // substitute
}
}
}
}
}
}
//
//
// public double empty; // Cost of a tile that is not assigned
for (int ml = 0; ml < around.length; ml++) if (around[ml] != null){
if (around[ml][8] == 0) costs.empty +=1.0; // Cost of a tile that is not assigned
}
// public double nolink; // Cost of a tile not having any neighbor in particular direction
int num_weak_fgnd = 0; // to reduce multiple for teh same tile
int num_color_sep = 0; // to reduce multiple for teh same tile
for (int ml = 0; ml < around.length; ml++) if ((around[ml] != null) && (around[ml][8] > 0)){
if ((around[ml][8] - 1) >= ts.getTileData()[nSurfTile].length){
System.out.println("getTileCosts() BUG: nSurfTile="+nSurfTile);
......@@ -854,7 +857,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (around[ml][dir] > 0) {
if (around[ml][dir] == neibp1) {
link_this = true;
} else {
link_other = true;
}
......@@ -870,9 +873,9 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
continue;
}
if (!link_this && !link_other){
costs.nolink +=1.0;
costs.nolink +=1.0;
} else if (link_other) {
costs.swtch += 1.0; // cost for any switch
costs.swtch += 1.0; // cost for any switch
// check if it is fb->bg transition and fg is weak
double d_this = ts.getTileData()[nSurfTiles[dir]][neibs[dir]].getDisparity();
double d_other = ts.getTileData()[nSurfTiles[dir]][around[ml][dir] -1].getDisparity();
......@@ -885,13 +888,13 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (disp_diff > minFgBg) {
double strength = dispStrength[ml][nSurfTile][1];
strength = Math.max(strength, minFgEdge);
costs.weak_fgnd += minFgEdge / strength;
costs.weak_fgnd += minFgEdge / strength;
num_weak_fgnd++;
} else if (mutual_weak_fgnd && (disp_diff < -minFgBg)) {
double [] dsmeas_other = dispStrength[ml][nSurfTiles[dir]];
double strength = (dsmeas_other != null)? dsmeas_other[1]: 0.0; // measured strength on the other end or 0.0 if nothing there
strength = Math.max(strength, minFgEdge);
costs.weak_fgnd += minFgEdge / strength;
costs.weak_fgnd += minFgEdge / strength;
num_weak_fgnd++;
}
if (Math.abs(disp_diff) > minColSep){
......@@ -900,15 +903,15 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
costs.color += tone_diff_weight[nSurfTile][dir][1] * minColSep/col_diff;
num_color_sep++;
}
} else { // v, both can not coexist
// Anything to cost here?
}
}
// if (around[ml][8] == 0) costs.empty +=1.0; // each existing measurement layer that is not assigned
} //for (int ml = 0; ml < around.length; ml++) if ((around[ml] != null) && (around[ml][8] > 0))
// using /4.0 to maintain same value (==1.0) for half neighbors (straight edge)
if ((num_weak_fgnd > 0) && (shrinkWeakFgnd > 0.0)){
costs.weak_fgnd /= Math.pow(num_weak_fgnd/4.0, shrinkWeakFgnd);
......@@ -917,10 +920,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if ((num_color_sep > 0) && (shrinkColor > 0.0)){
costs.color /= Math.pow(num_color_sep/4.0, shrinkColor);
}
double disp_diff_lpf = 0.0, disp_diff_weight = 0.0; // calculate LPF of the disparity signed error over all ML and 9 cells
double disp_diff2 = 0.0, disp_weight = 0.0; // calculate disparity error in the center, weighted
double disp_diff_over_best = 0.0; // , disp_weight_best = 0.0; // calculate disparity error in the center, weighted
double disp_diff_lpf = 0.0, disp_diff_weight = 0.0; // calculate LPF of the disparity signed error over all ML and 9 cells
double disp_diff2 = 0.0, disp_weight = 0.0; // calculate disparity error in the center, weighted
double disp_diff_over_best = 0.0; // , disp_weight_best = 0.0; // calculate disparity error in the center, weighted
for (int ml = 0; ml < around.length; ml++) if (around[ml] != null){
double diff=0.0, weight=0.0;
for (int dir = 0; dir < 9; dir++){
......@@ -968,7 +971,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
disp_diff2 += diff * diff * weight;
disp_weight += weight;
// and once more for the disparity over best
if (strengthBestPwr > 0.0) {
weight = dispStrength[ml][nSurfTile][1];
......@@ -979,7 +982,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
weight = 1.0;
}
disp_diff_over_best += (Math.abs(diff) - dispDiffBest( ml, nSurfTiles[8])) * weight; // this one - not squared
}
if (disp_diff_weight > 0.0) {
disp_diff_lpf /= disp_diff_weight;
......@@ -993,7 +996,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
costs.diff += disp_diff2 / disp_weight;
costs.diff_best += disp_diff_over_best / disp_weight;
}
int [] txy = tnSurface.getXY(nSurfTile);
int nSTile = (txy[0] / ts.getSuperTileSize()) + (txy[1] / ts.getSuperTileSize()) * ts.getSTilesX();
for (int ml = 0; ml < around.length; ml++) if ((around[ml] != null) && (around[ml][8] > 0)){
......@@ -1001,7 +1004,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (parentSTile != nSTile){
costs.flaps += 1.0;
}
}
}
return costs;
}
......@@ -1023,7 +1026,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
return tileLayersSurf;
}
public int [][] surfToImg (
int [][] tileLayersSurf)
{
......@@ -1042,9 +1045,9 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
return tileLayersImg;
}
public void optimizeAssignment9(
final boolean noEdge,
final boolean noEdge,
final int [][] tileLayers,
final int debugLevel,
final int dbg_X,
......@@ -1067,7 +1070,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
int indx2 = 0;
for (int y = 0; y < num_y; y++){
for (int x = 0; x < num_x; x++){
tile_indices[indx1][indx2++] = (sty + step * y) * surfTilesX + (stx + step * x);
tile_indices[indx1][indx2++] = (sty + step * y) * surfTilesX + (stx + step * x);
}
}
}
......@@ -1087,12 +1090,13 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
if (valid_tile) dirty[nSurfTile] = new AtomicBoolean(true);
}
final boolean [][] bad_surface = new boolean[num_tiles][];
final TileSurface.TileData [][] tileData = ts.getTileData();
if (noEdge) {
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int nSurfTile = ai.getAndIncrement(); nSurfTile < num_tiles; nSurfTile = ai.getAndIncrement()) {
if (tileData[nSurfTile] != null){
......@@ -1109,10 +1113,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
};
}
}
ImageDtt.startAndJoin(threads);
}
for (int nTry = 0 ; nTry < tries; nTry++) {
for (int i = 0; i < improved.length; i++) improved[i] = 0;
int this_improved = 0;
......@@ -1122,6 +1126,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
ai_numThread.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int iTile = ai.getAndIncrement(); iTile < tile_indices[fnSeries].length; iTile = ai.getAndIncrement()) {
......@@ -1170,8 +1175,8 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
for (surfaces[max_reset]++; surfaces[max_reset] < num_surf; surfaces[max_reset]++) {
if ((bad_surface[nSurfTile] == null) || !bad_surface[nSurfTile][surfaces[max_reset]]) {
break;
}
}
}
if (surfaces[max_reset] < num_surf) break;
}
......@@ -1184,14 +1189,14 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
surfaces[ml] = lowest_surf;
}
// now surfaces[] contain next combination of surfaces to try
// tileLayers[nSurfTile] = surfaces;
for (int ml = 0; ml < valid_ml.length; ml ++ ){
if (tileLayers[ml] != null) {
tileLayers[ml][nSurfTile] = surfaces[ml] + 1; // 1-based from 0-based
}
}
double cost = cost_coeff.dotProd(getTileCosts( //
nSurfTile, // int nSurfTile,
tileLayers, // int [][] tileLayers,
......@@ -1200,17 +1205,17 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
best_cost = cost;
best_surf = surfaces.clone();
}
} // while (true)
if (best_surf != null){ // update
// tileLayers[nSurfTile] = best_surf;
for (int ml = 0; ml < valid_ml.length; ml ++ ){
if (tileLayers[ml] != null) {
tileLayers[ml][nSurfTile] = best_surf[ml] + 1; // 1-based from 0-based
tileLayers[ml][nSurfTile] = best_surf[ml] + 1; // 1-based from 0-based
}
}
for (int dir = 0; dir <8; dir++) {
int nSurfTile1 = tnSurface.getNeibIndex(nSurfTile, dir);
if ((nSurfTile1 >= 0) && (dirty[nSurfTile1] != null)){
......@@ -1230,7 +1235,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
};
}
}
ImageDtt.startAndJoin(threads);
if (debugLevel > -1){
int num_better = 0;
......@@ -1240,7 +1245,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
System.out.println("optimizeAssignment9(): pass = "+nTry+ ":"+nSeries+" improved:" + (num_better - this_improved));
this_improved = num_better;
}
} // for (int nSeries = 0; nSeries < tile_indices.length; nSeries++) {
} // for (int nSeries = 0; nSeries < tile_indices.length; nSeries++) {
// should be checked only after all series (now 9 passes) are finished - if anything was added - continue
int num_improved = 0;
for (int i = 0; i < improved.length; i++){
......@@ -1249,14 +1254,14 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (debugLevel > -1){
System.out.println("optimizeAssignment9(): pass = "+nTry+ " improved:"+num_improved);
}
if (num_improved == 0) break;
}
}
public void optimizeAssignment25(
final boolean noEdge,
final boolean noEdge,
final int [][] tileLayers,
final int debugLevel,
final int dbg_X,
......@@ -1279,7 +1284,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
int indx2 = 0;
for (int y = 0; y < num_y; y++){
for (int x = 0; x < num_x; x++){
tile_indices[indx1][indx2++] = (sty + step * y) * surfTilesX + (stx + step * x);
tile_indices[indx1][indx2++] = (sty + step * y) * surfTilesX + (stx + step * x);
}
}
}
......@@ -1299,12 +1304,13 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
if (valid_tile) dirty[nSurfTile] = new AtomicBoolean(true);
}
final boolean [][] bad_surface = new boolean[num_tiles][];
final TileSurface.TileData [][] tileData = ts.getTileData();
if (noEdge) {
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
for (int nSurfTile = ai.getAndIncrement(); nSurfTile < num_tiles; nSurfTile = ai.getAndIncrement()) {
if (tileData[nSurfTile] != null){
......@@ -1321,10 +1327,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
};
}
}
ImageDtt.startAndJoin(threads);
}
for (int nTry = 0 ; nTry < tries; nTry++) {
for (int i = 0; i < improved.length; i++) improved[i] = 0;
int this_improved = 0;
......@@ -1334,6 +1340,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
ai_numThread.set(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
@Override
public void run() {
int numThread = ai_numThread.getAndIncrement(); // unique number of thread to write to rslt_diffs[numThread]
for (int iTile = ai.getAndIncrement(); iTile < tile_indices[fnSeries].length; iTile = ai.getAndIncrement()) {
......@@ -1407,8 +1414,8 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
for (surfaces[max_reset]++; surfaces[max_reset] < num_surf; surfaces[max_reset]++) {
if ((bad_surface[nSurfTile] == null) || !bad_surface[nSurfTile][surfaces[max_reset]]) {
break;
}
}
}
if (surfaces[max_reset] < num_surf) break;
}
......@@ -1421,7 +1428,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
surfaces[ml] = lowest_surf;
}
// now surfaces[] contain next combination of surfaces to try
// tileLayers[nSurfTile] = surfaces;
for (int ml = 0; ml < valid_ml.length; ml ++ ){
if (tileLayers[ml] != null) {
......@@ -1452,17 +1459,17 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
best_cost = cost;
best_surf = surfaces.clone();
}
} // while (true)
if (best_surf != null){ // update
// tileLayers[nSurfTile] = best_surf;
for (int ml = 0; ml < valid_ml.length; ml ++ ){
if (tileLayers[ml] != null) {
tileLayers[ml][nSurfTile] = best_surf[ml] + 1; // 1-based from 0-based
tileLayers[ml][nSurfTile] = best_surf[ml] + 1; // 1-based from 0-based
}
}
for (int dir = 0; dir <8; dir++) {
int nSurfTile1 = tnSurface.getNeibIndex(nSurfTile, dir);
if ((nSurfTile1 >= 0) && (dirty[nSurfTile1] != null)){
......@@ -1482,7 +1489,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
}
}
};
}
}
ImageDtt.startAndJoin(threads);
if (debugLevel > -1){
int num_better = 0;
......@@ -1492,7 +1499,7 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
System.out.println("optimizeAssignment25(): pass = "+nTry+ ":"+nSeries+" improved:" + (num_better - this_improved));
this_improved = num_better;
}
} // for (int nSeries = 0; nSeries < tile_indices.length; nSeries++) {
} // for (int nSeries = 0; nSeries < tile_indices.length; nSeries++) {
// should be checked only after all series (now 9 passes) are finished - if anything was added - continue
int num_improved = 0;
for (int i = 0; i < improved.length; i++){
......@@ -1501,10 +1508,10 @@ diff_best= 0.06731 diff9= 1.09087 weak_fgnd= 0.22250 flaps= 0.07229 ml_mismatch
if (debugLevel > -1){
System.out.println("optimizeAssignment25(): pass = "+nTry+ " improved:"+num_improved);
}
if (num_improved == 0) break;
}
}
}
......@@ -3504,12 +3504,14 @@ public class TilePlanes {
System.out.println("mergePlaneToThisWorld()");
}
if (wvalues == null ) {
System.out.println("mergePlaneToThisWorld(): wvalues=null:\n"+toString());
if (debugLevel > -2) {
System.out.println("mergePlaneToThisWorld(): wvalues=null:\n"+toString());
}
return null;
}
if (otherPd.wvalues == null ) {
System.out.println("mergePlaneToThisWorld(): otherPd.wvalues=null:\n"+otherPd.toString());
if (debugLevel > -1) System.out.println("mergePlaneToThisWorld(): otherPd.wvalues=null:\n"+otherPd.toString());
return null;
}
double [][] this_eig_avals = {
......@@ -4036,6 +4038,9 @@ public class TilePlanes {
if (debugLevel > 2) {
debugLevel += 0; // +=1 // no show all eigen stuff (debugLevel > 3)
}
if (debugLevel > 0) {
System.out.println("Debug debugLevel"); // +=1 // no show all eigen stuff (debugLevel > 3)
}
// first make a plane from all tiles
ArrayList<PlaneData> st_planes = new ArrayList<PlaneData>();
......
......@@ -4572,9 +4572,10 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
// final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run;
final int debugLevelInner = batch_mode ? -5: debugLevel;
trimCLTPasses(); // make possible to run this method multiple times - remove extra passes added by it last time
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
......@@ -5140,9 +5141,9 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
trimCLTPasses(); // make possible to run this method multiple time - remove extra passes added by it last time
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
......@@ -5311,7 +5312,7 @@ public class TileProcessor {
clt_parameters.stHighMix, // stHighMix = 0.4; // Consider merging initial planes if jumps between ratio above
world_hor, // final double [] world_hor, // horizontal plane normal (default [0.0, 1.0, 0.0])
clt_parameters.show_histograms, // final boolean show_histograms,
1, // -1, // debugLevel, // final int debugLevel)
clt_parameters.batch_run?-1:1, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileY);
// showDoubleFloatArrays sdfa_instance = null;
......@@ -5334,7 +5335,7 @@ public class TileProcessor {
lp.conditionSuperTiles(
st.planes, // final TilePlanes.PlaneData [][] planes,
10, // final int max_num_merge_try,
0); // 1); // debugLevel); // final int debugLevel);
clt_parameters.batch_run?-2:0); // 1); // debugLevel); // final int debugLevel);
// Used only by conflicts (not processed currently)
lp.calcStarValueStrength(
true, // boolean set_start_planes,
......@@ -5398,7 +5399,7 @@ public class TileProcessor {
clt_parameters.plDiscrXMedian, // final double plDiscrXMedian, // = 1.5; // Remove outliers from the final selection that have distance more than scaled median
debugLevel, // -1, // debugLevel, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.batch_run ? -1 : clt_parameters.tileX, // clt_parameters.tileX,
clt_parameters.tileY);
// condition the redefined planes
......@@ -6064,9 +6065,9 @@ public class TileProcessor {
GeometryCorrection geometryCorrection,
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
final boolean batch_mode,
final int debugLevel)
{
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
int debugLevelInner = batch_mode ? -5: debugLevel;
CLTPass3d scan_bg = clt_3d_passes.get(bg_scan_index); //
CLTPass3d scan_prev = clt_3d_passes.get(clt_3d_passes.size() -1); // get last one
......@@ -6146,7 +6147,7 @@ public class TileProcessor {
true, // final boolean keep_raw_fg, // do not replace raw tiles by the plates, if raw is closer (like poles)
0.0, // final double scale_filtered_strength_pre, // scale plate_ds[1] before comparing to raw strength
0.0,// final double scale_filtered_strength_post,// scale plate_ds[1] when replacing raw (generally plate_ds is more reliable if it exists)
true, // clt_parameters.show_filter_scan,
batch_mode, // true, // clt_parameters.show_filter_scan,
clt_parameters.min_clstr_seed, // clt_parameters.min_clstr_seed
clt_parameters.min_clstr_weight, // double min_weight // minimal total weight of the cluster
clt_parameters.min_clstr_max, // double min_max_weight // minimal value of the maximal strengh in the cluster
......
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