Commit 182ed7f3 authored by Andrey Filippov's avatar Andrey Filippov

implementing non-quad 2D correlation (CPU)

parent 5bdb59ce
......@@ -158,6 +158,9 @@ public class CLTParameters {
public double fine_corr_y_2 = 0.0; // additionally shift image in port 2 in y direction
public double fine_corr_x_3 = 0.0; // additionally shift image in port 3 in x direction
public double fine_corr_y_3 = 0.0; // additionally shift image in port 3 in y direction
// public double [][] fine_corr_xy;
public boolean fine_corr_ignore = false; // Ignore manual pixel correction
public boolean fine_corr_apply = true; // Apply and set to ignore manual pixel correction after extrinsics correction
......
......@@ -1221,7 +1221,9 @@ public class EyesisDCT {
if (this.correctionsParameters.deconvolve) { // process with DCT, otherwise use simple debayer
ImageDtt image_dtt = new ImageDtt(
4, // 4 sensors, will not be used here
dctParameters.dct_size,
null, // FIXME: needs ImageDttParameters (clt_parameters.img_dtt),
false, // mono
false, // lwir
1.0); // Bayer( not monochrome), scale correlation strengths
......
......@@ -3113,7 +3113,9 @@ private Panel panel1,
}
ImageDtt image_dtt = new ImageDtt(
4, // number of sensors - not used here ?
DCT_PARAMETERS.dct_size,
null, // FIXME: needs ImageDttParameters (clt_parameters.img_dtt),
false, // mono
false, // lwir
1.0); // Bayer( not monochrome), scale correlation strengths
......@@ -3215,7 +3217,9 @@ private Panel panel1,
}
ImageDtt image_dtt = new ImageDtt(
4, // number of sensors - not used here ?
DCT_PARAMETERS.dct_size,
null, // FIXME: needs ImageDttParameters (clt_parameters.img_dtt),
false, // mono
false, // lwir
1.0); // Bayer( not monochrome), scale correlation strengths
......@@ -3309,7 +3313,7 @@ private Panel panel1,
EYESIS_DCT.showKernels(); // show restored kernels
}
}
EYESIS_DCT.processDCTChannelImages(
EYESIS_DCT.processDCTChannelImages( // hard-wired 4 sensors!
DCT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS, //EyesisCorrectionParameters.NonlinParameters nonlinParameters,
......@@ -4729,7 +4733,8 @@ private Panel panel1,
}
///========================================
System.out.println("***** QUAD_CLT.cltDisparityScans() is removed");
/*
QUAD_CLT.cltDisparityScans(
CLT_PARAMETERS, // EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS, //EyesisCorrectionParameters.DebayerParameters debayerParameters,
......@@ -4740,7 +4745,7 @@ private Panel panel1,
THREADS_MAX, //final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS, //final boolean updateStatus,
DEBUG_LEVEL); //final int debugLevel);
*/
if (configPath!=null) {
saveTimestampedProperties( // save config again
configPath, // full path or null
......@@ -8074,7 +8079,9 @@ private Panel panel1,
}
ImageDtt image_dtt = new ImageDtt(
4, // number of sensors - not used here ?
CLT_PARAMETERS.transform_size,
CLT_PARAMETERS.img_dtt,
false, // mono
false, // lwir
1.0); // Bayer( not monochrome), scale correlation strengths
......@@ -8208,7 +8215,9 @@ private Panel panel1,
}
String suffix = "-dx_"+(CLT_PARAMETERS.ishift_x+CLT_PARAMETERS.shift_x)+"_dy_"+(CLT_PARAMETERS.ishift_y+CLT_PARAMETERS.shift_y);
ImageDtt image_dtt = new ImageDtt(
4, // number of sensors
CLT_PARAMETERS.transform_size,
CLT_PARAMETERS.img_dtt,
COLOR_PROC_PARAMETERS.isMonochrome(),
COLOR_PROC_PARAMETERS.isLwir(),
CLT_PARAMETERS.getScaleStrength(false)); // Bayer, not monochrome
......
......@@ -35,6 +35,7 @@ public class Clt1d {
public int transform_size = 8;
int transform_len = 64;
int nSens = 4;
DttRad2 dtt;
ImageDtt image_dtt;
Correlation2d corr2d;
......@@ -46,11 +47,14 @@ public class Clt1d {
dtt = new DttRad2(transform_size);
dtt.set_window(1);
image_dtt = new ImageDtt(
nSens,
transform_size,
null, // FIXME: needs ImageDttParameters (clt_parameters.img_dtt),
false,
false,
1.0);
corr2d = new Correlation2d(
nSens,
transform_size, // int transform_size,
false, // boolean monochrome,
false); // boolean debug)
......
package com.elphel.imagej.tileprocessor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import com.elphel.imagej.common.DoubleGaussianBlur;
import com.elphel.imagej.common.PolynomialApproximation;
import com.elphel.imagej.common.ShowDoubleFloatArrays;
import com.elphel.imagej.tileprocessor.Corr2dLMA.Sample;
import Jama.Matrix;
/**
**
** Correlation2d - Handle 2-d (phase) correlations, combining multiple-pair data
......@@ -48,6 +54,7 @@ public class Correlation2d {
private final boolean monochrome;
// configuration for 8-lens and 4-lens cameras. 8-lens has baseline = 1 for 1..4 and 1/2 for 4..7
/*0 1
4 5
......@@ -93,6 +100,10 @@ public class Correlation2d {
{-2, -3, 0, 1},
{ 3, -2, -1, 0}};
public final int numSensors;
public final boolean top_is_0;
public boolean isMonochrome() {return monochrome;} // not used in lwir
// for 8 cameras and 16 pairs. Following data moved from ImageDtt
// which images to use (0..3 - external, 4..7 - internal)
......@@ -126,14 +137,360 @@ public class Correlation2d {
return bm;
}
private final int [][] pair_start_end; // start_index, end_index
private final int [][] pair_orient; // second pair parallel to first pair - 0, CW90 - 1, 180 - 2, CW270 - 3, other - -1
private final int [] pair_length; // number of sensors from first to second
private boolean [] corr_pairs; // Which pairs to calculate
private boolean [] corr_pairs_filter; // Remove pairs that do not have measurement
public static enum MCORR_COMB {ALL, DIA, SQ, NEIB, HOR, VERT}; // MCORR_COMB.SQ.ordinal() == 2
private static String [] CORR_TITLES_EXTRA={"*all","*dia","*sq","*neib","*hor","*vert"};
public final String [] cor_titles; // per-pair correlation slices titles
public final String [] cor_titles_combo; // combo correlation slices titles
private int mcorr_comb_width; // combined correlation tile width
private int mcorr_comb_height; // combined correlation tile full height
private int mcorr_comb_offset; // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
private double mcorr_comb_disp; // Combined tile per-pixel disparity for baseline == side of a square
// private double [][][][] resample; // [num_pair][out_index]<null or variable number of {source_index, weight} pairs>
private int [][][] resample_indices; // should have the same length as number of pairs
private double [][][] resample_weights; // should have the same length as number of pairs
private static int SUB_SAMPLE = 16; // subsample source pixel in each direction when generating
public static int THREADS_MAX = 100;
private void setupPairs() {
int indx = 0;
for (int i = 1; i <= numSensors/2; i++) { // CW length
for (int j = 0; j < ((i < (numSensors/2))? numSensors : (numSensors/2) ); j++) {
pair_length[indx] = i;
pair_start_end[indx][0] = j;
pair_start_end[indx][1] = (i + j) % numSensors;
indx++;
// if (indx >= pair_length.length) {
// break; // BUG
// }
}
}
for (int i = 0; i < pair_start_end.length; i++ ) {
int n1 = (2 * pair_start_end[i][0] + pair_length[i]) % (2 * numSensors);
for (int j = 0; j < pair_start_end.length; j++ ) {
int n2 = (2 * pair_start_end[j][0] + pair_length[j]) % (2 * numSensors);
// if ((i >= 116) && (j >= 112)) {
// System.out.println ("i="+i+", j="+j);
// System.out.println ("(n2 - n1) % (numSensors / 2)="+((n2 - n1) % (numSensors / 2)));
// System.out.println ("((n2 - n1) / (numSensors / 2)) % 4 = "+(((n2 - n1) / (numSensors / 2)) % 4));
// }
if ((n2 - n1) % (numSensors / 2) != 0) {
pair_orient[i][j] = -1; // non-ortho
} else {
pair_orient[i][j] = Math.floorMod(((n2 - n1) / (numSensors / 2)) , 4);
}
}
}
// cor_titles = new String[num_pairs + CORR_TITLES_EXTRA.length];
for (int i = 0; i < pair_start_end.length; i++ ) {
cor_titles[i] = getPair(i)[0]+"-"+getPair(i)[1]; //getPair(i) to correct sensor numbers for quad (Z-order)
}
for (int i = 0; i < CORR_TITLES_EXTRA.length; i++ ) {
cor_titles_combo[i] = CORR_TITLES_EXTRA[i];
}
return;
}
public boolean [] selectLength(boolean [] cur_sel, int l) {
boolean [] sel = (cur_sel == null) ? (new boolean[pair_length.length]) : cur_sel;
for (int i = 0; i < pair_length.length; i++) {
sel[i] |= pair_length[i] == l;
}
return sel;
}
public boolean [] selectDiameters(boolean [] cur_sel) {
return selectLength(cur_sel, numSensors / 2);
}
public boolean [] selectSquares(boolean [] cur_sel) {
return selectLength(cur_sel, numSensors / 4);
}
public boolean [] selectNeibs(boolean [] cur_sel) {
return selectLength(cur_sel, 1);
}
public boolean [] selectParallel(boolean [] cur_sel, int start, int end) {
boolean [] sel = (cur_sel == null) ? (new boolean[pair_length.length]) : cur_sel;
int n1 = (2 * start + end) % (2 * numSensors);
for (int j = 0; j < pair_start_end.length; j++ ) {
int n2 = (2 * pair_start_end[j][0] + pair_length[j]) % (2 * numSensors);
if ((n2 - n1) % numSensors == 0) { // only parallel or anti-parallel
sel[j] = true;
}
}
return sel;
}
public boolean [] selectHorizontal(boolean [] cur_sel) {
if (top_is_0) {
return selectParallel(cur_sel, numSensors - 1, 1);
} else {
return selectParallel(cur_sel, numSensors - 1, 0);
}
}
public boolean [] selectVertical(boolean [] cur_sel) {
if (top_is_0) {
return selectParallel(cur_sel, 0 , numSensors/2);
} else {
return selectParallel(cur_sel, 0, numSensors/2 - 1);
}
}
// combine with available correlation results
public boolean [] selectAll() {
boolean [] sel = new boolean[pair_length.length];
Arrays.fill(sel, true);
return sel;
}
public int [] getPair(int indx) {
int [] quad_indx = {1,3,2,0}; // CW to EO numbers
if (numSensors > 4) {
return pair_start_end[indx];
} else {
return new int [] {quad_indx[pair_start_end[indx][0]], quad_indx[pair_start_end[indx][1]]};
}
}
public int getNumPairs() {
return pair_start_end.length;
}
public void setCorrPairs(boolean [] sel) { // these pairs will be correlated
corr_pairs = sel.clone();
}
public void setCorrPairsFilter(double [][][][][][] clt_data, int tileY, int tileX ) { // these pairs will be correlated
corr_pairs_filter = new boolean [pair_start_end.length];
boolean [] en = new boolean [numSensors];
if (clt_data != null) {
for (int i = 0; i < numSensors; i++) if (clt_data[i] != null){
for (int ncol = 0; ncol < clt_data[i].length; ncol++) {
if ((clt_data[i][ncol] != null) && (clt_data[i][ncol][tileY] != null) && (clt_data[i][ncol][tileY][tileX] != null)) {
en[i] = true;
break;
}
}
}
for (int i = 0; i < pair_start_end.length; i++) {
corr_pairs_filter[i] = en[pair_start_end[i][0]] && en[pair_start_end[i][1]];
}
}
}
/**
* Filter sel array by removing unavailable sensors and pairs that are not calculated
* @param sel selection to be filtered
* @return number of remaining selected pairs
*/
public int numRemainingPairs(boolean [] sel ) {
int num_sel = 0;
for (int i = 0; i < sel.length; i++) {
sel[i] &= corr_pairs[i] && corr_pairs_filter[i];
if (sel[i]) num_sel++;
}
return num_sel;
}
public boolean [] getCorrPairs() { // these pairs will be correlated
return corr_pairs;
}
public String[] getCorrTitles() {
return cor_titles;
}
public String[] getComboTitles() {
return cor_titles_combo;
}
/**
* Add 2D correlation for a pair to the combined correlation tile, applying rotation/scaling
* @param accum_tile tile for accumulation in line-scan order, same dimension as during generateResample()
* @param corr_tile correlation tile (currently 15x15)
* @param num_pair number of correlation pair for which resamplind data exists
* @param weight multiply added tile data by this coefficient before accumulation
*/
public void accummulatePair(
double [] accum_tile,
double [] corr_tile,
int num_pair,
double weight) {
if ((resample_indices == null) || (resample_indices[num_pair] == null)) {
throw new IllegalArgumentException ("No resample data for num_pair = "+num_pair);
}
for (int i = 0; i < accum_tile.length; i++) if (resample_indices[num_pair][i] != null) {
for (int j = 0; j < resample_indices[num_pair][i].length; j++) {
accum_tile[i] += weight * corr_tile[resample_indices[num_pair][i][j]] * resample_weights[num_pair][i][j];
}
}
}
/**
* Add multiple 2D correlation tiles to a combined correlation tile, applying rotation/scaling
* @param corr_tiles (sparse) array of correlation tile, some tiles may be null
* @param selection boolean selection array that specifies which (of existing) correlation tiles to add
* @param weight multiply added tile data by this coefficient before accumulation, common for all added tiles
*/
public void accummulatePairs(
double [] accum_tile,
double [][] corr_tiles,
boolean [] selection,
double weight) { // same weights
for (int num_pair = 0; num_pair < selection.length; num_pair++) {
if (selection[num_pair] && (corr_tiles[num_pair] != null)) {
accummulatePair(
accum_tile,
corr_tiles[num_pair],
num_pair,
weight);
}
}
}
public double [] accumulateInit() {return new double [mcorr_comb_width * mcorr_comb_height]; }
public int getCombWidth() {return mcorr_comb_width;}
public int getCombHeight() {return mcorr_comb_height;}
public int getCombOffset() {return mcorr_comb_offset;}
public double getCombDisp() {return mcorr_comb_disp;}
public void generateResample( // should be called before
final int mcorr_comb_width, // combined correlation tile width
final int mcorr_comb_height, // combined correlation tile full height
final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
final double mcorr_comb_disp){ // Combined tile per-pixel disparity for baseline == side of a square
this.mcorr_comb_width = mcorr_comb_width; // combined correlation tile width
this.mcorr_comb_height = mcorr_comb_height; // combined correlation tile full height
this.mcorr_comb_offset = mcorr_comb_offset; // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
this.mcorr_comb_disp = mcorr_comb_disp; // Combined tile per-pixel disparity for baseline == side of a square
resample_indices = new int [corr_pairs.length][][];
resample_weights = new double [corr_pairs.length][][];
final int weights_size = 2*SUB_SAMPLE-1;
final double [] weights1 = new double [weights_size];
final double [] weights = new double [weights_size * weights_size];
for (int i = 0; i < weights1.length; i++) {
double w = Math.sin(Math.PI*(i+1)/(2*SUB_SAMPLE));
weights1[i] = w * w;
}
double s = 0.0;
int indx = 0;
for (int i = 0; i < weights1.length; i++) {
for (int j = 0; j < weights1.length; j++) {
double w = weights1[i] * weights1[j];
s+=w;
weights[indx++] = w;
}
}
// normalize sum == 1.0;
double k = 1.0/s;
for (int i = 0; i < weights.length; i++) {
weights[i] *= k;
}
// final double [][][][] resample = new double [pair_start_end.length][mcorr_comb_width * mcorr_comb_height][][];
// use multithreading?
final Thread[] threads = ImageDtt.newThreadArray(THREADS_MAX);
final AtomicInteger ai = new AtomicInteger(0);
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
double [] contrib = new double [corr_size*corr_size];
HashSet<Integer> contrib_set = new HashSet<Integer>();
Iterator<Integer> contrib_itr;
for (int num_pair = ai.getAndIncrement(); num_pair < corr_pairs.length; num_pair = ai.getAndIncrement()) {
if (corr_pairs[num_pair]) {
resample_indices[num_pair] = new int [mcorr_comb_width * mcorr_comb_height][];
resample_weights[num_pair] = new double [mcorr_comb_width * mcorr_comb_height][];
// scale and angle
int istart = pair_start_end[num_pair][0];
int iend = pair_start_end[num_pair][1];
double cwrot = (((istart+iend) % numSensors) + (top_is_0 ? 0.0 : 0.5)) * Math.PI/numSensors; // +(top_is_0 ? 0.0 : 0.5)
if ((iend > istart) ^ ((iend + istart) <16)) {
cwrot += Math.PI;
}
double pl = 2 * Math.sin(Math.PI* pair_length[num_pair] / numSensors); // length for R=1
double scale = pl/Math.sqrt(2.0)* mcorr_comb_disp; // Math.sqrt(2.0) - relative to side of a square - may be change later?
Matrix toPair = new Matrix(new double[][] {
{scale * Math.cos(cwrot), -scale*Math.sin(cwrot)},
{scale * Math.sin(cwrot), scale*Math.cos(cwrot)}});
// scale - to get pair (source) radius from combo (destination) radius
double ksub = 1.0/SUB_SAMPLE;
Matrix mxy = new Matrix(2,1);
for (int i = 0; i < mcorr_comb_height; i++) {
int iy = i + mcorr_comb_offset - mcorr_comb_height/2;
for (int j = 0; j < mcorr_comb_width; j++) {
int ix = j - mcorr_comb_width/2;
Arrays.fill(contrib, 0.0);
contrib_set.clear();
for (int idy = 0; idy <= 2*SUB_SAMPLE; idy++) {
mxy.set(1, 0, iy+ (idy - SUB_SAMPLE + 1) * ksub); //idy == (SUB_SAMPLE -1) - no fractional pixel
for (int idx = 0; idx <= 2*SUB_SAMPLE; idx++) {
mxy.set(0, 0, ix+ (idx - SUB_SAMPLE + 1) * ksub); // idy == (SUB_SAMPLE -1) - no fractional pixel
double [] pxy = toPair.times(mxy).getColumnPackedCopy();
int ipx = (int) Math.round(pxy[0]+transform_size -1);
int ipy = (int) Math.round(pxy[1]+transform_size -1);
if ((ipx >= 0) && (ipy >= 0) && (ipx < corr_size) && (ipy < corr_size)) {
int indx_src = ipy * corr_size + ipx;
contrib_set.add(indx_src);
contrib[indx_src] += weights[idy * weights_size + idx];
}
}
}
if (!contrib_set.isEmpty()) {
int indx = i * mcorr_comb_width + j;
resample_indices[num_pair][indx] = new int [contrib_set.size()];
resample_weights[num_pair][indx] = new double [contrib_set.size()];
contrib_itr = contrib_set.iterator();
int contrib_num = 0;
while(contrib_itr.hasNext()) {
int indx_src = contrib_itr.next();
resample_indices[num_pair][indx][contrib_num] = indx_src;
resample_weights[num_pair][indx][contrib_num] = contrib[indx_src];
}
}
}
}
} else {
resample_indices[num_pair] = null;
resample_weights[num_pair] = null;
}
}
}
};
}
ImageDtt.startAndJoin(threads);
}
public Correlation2d ( // USED in lwir
int numSensors,
ImageDttParameters imgdtt_params,
int transform_size,
double wndx_scale, // (wndy scale is always 1.0)
boolean monochrome,
boolean debug) {
this.numSensors = numSensors;
this.monochrome = monochrome;
this.dtt = new DttRad2(transform_size);
this.transform_size = transform_size;
......@@ -164,12 +521,22 @@ public class Correlation2d {
true, // boolean normalize,
true, // boolean notch,
wndx_scale); // double scale);
int num_pairs = numSensors * (numSensors-1) /2;
pair_start_end = new int [num_pairs][2];
pair_orient = new int [num_pairs][num_pairs];
pair_length = new int [num_pairs];
top_is_0 = numSensors > 4; // sensor 0 is straight up, false half-rotated
cor_titles = new String[num_pairs];
cor_titles_combo = new String[CORR_TITLES_EXTRA.length];
setupPairs();
}
public Correlation2d ( // USED in lwir
int numSensors,
int transform_size,
boolean monochrome,
boolean debug) {
this.numSensors = numSensors;
this.monochrome = monochrome;
this.dtt = new DttRad2(transform_size);
this.transform_size = transform_size;
......@@ -182,6 +549,14 @@ public class Correlation2d {
this.corr_wndy = null; // will not be used
this.corr_wndx = null; // will not be used
this.corr_wndy_notch = null; // will not be used
int num_pairs = numSensors * (numSensors-1) /2;
pair_start_end = new int [num_pairs][2];
pair_orient = new int [num_pairs][num_pairs];
pair_length = new int [num_pairs];
top_is_0 = numSensors > 4; // sensor 0 is straight up, false half-rotated
cor_titles = new String[num_pairs];
cor_titles_combo = new String[CORR_TITLES_EXTRA.length];
setupPairs();
}
public int [] getTransposeAll(boolean diagonal){ // USED in lwir
......@@ -781,6 +1156,7 @@ public class Correlation2d {
* @param clt_data aberration-corrected FD CLT data [camera][color][tileY][tileX][quadrant][index]
* @param tileX tile to extract X index
* @param tileY tile to extract Y index
* @param pairs_mask bimask of required pairs
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
......@@ -812,6 +1188,44 @@ public class Correlation2d {
fat_zero);
}
/**
* Calculate all required image pairs phase correlation
* @param clt_data aberration-corrected FD CLT data [camera][color][tileY][tileX][quadrant][index]
* @param tileX tile to extract X index
* @param tileY tile to extract Y index
* @param pairs_mask boolean array of required pairs
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
* @param fat_zero fat zero for phase correlations
* @return [pair][corr_index]
*/
public double [][] correlateCompositeFD( // USED in lwir
double [][][][][][] clt_data,
int tileX,
int tileY,
boolean[] pairs_mask,
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights,
double fat_zero) {
double [][][][] clt_data_tile = new double[clt_data.length][][][]; // [camera][color][quadrant][index]
for (int ncam = 0; ncam < clt_data.length; ncam++) if (clt_data[ncam] != null){
clt_data_tile[ncam] = new double[clt_data[ncam].length][][];
for (int ncol = 0; ncol < clt_data[ncam].length; ncol++) if ((clt_data[ncam][ncol] != null) && (clt_data[ncam][ncol][tileY] != null)){
clt_data_tile[ncam][ncol] = clt_data[ncam][ncol][tileY][tileX];
}
}
return correlateCompositeFD(
clt_data_tile,
pairs_mask,
lpf,
scale_value,
col_weights,
fat_zero);
}
/**
* Calculate all required image pairs phase correlation
* @param clt_data_tile aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
......@@ -847,6 +1261,44 @@ public class Correlation2d {
return pairs_corr;
}
/**
* Calculate all required image pairs phase correlation
* @param clt_data_tile aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
* @param pairs_mask boolean array of required pairs
* @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors
* @param col_weights RBG color weights
* @param fat_zero fat zero for phase correlations
* @return [pair][corr_index]
*/
public double [][] correlateCompositeFD( // USED in lwir
double [][][][] clt_data_tile,
boolean [] pairs_mask,
double [] lpf,
double scale_value, // scale correlation value
double [] col_weights,
double fat_zero) {
if (clt_data_tile == null) return null;
double [][] pairs_corr = new double [getNumPairs()][];
for (int npair = 0; npair < pairs_corr.length; npair++) if (pairs_mask[npair]) {
int [] pair = getPair(npair);
int ncam1 = pair[0]; // start
int ncam2 = pair[1]; // end
if ((ncam1 < clt_data_tile.length) && (clt_data_tile[ncam1] != null) && (ncam2 < clt_data_tile.length) && (clt_data_tile[ncam2] != null)) {
pairs_corr[npair] = correlateCompositeFD(
clt_data_tile[ncam1], // double [][][] clt_data1,
clt_data_tile[ncam2], // double [][][] clt_data2,
lpf, // double [] lpf,
scale_value,
col_weights, // double [] col_weights,
fat_zero); // double fat_zero)
}
}
return pairs_corr;
}
/**
* Calculate FD phase correlation between averaged FD data from two quad (or octal/mixed)
* cameras, each should be pre-shifted the same disparity
......@@ -1251,15 +1703,14 @@ public class Correlation2d {
}
//isDiagonalPair
/**
* Find maximum correlation on the grid
* Find maximum correlation on the grid (before 08/28/2021)
* @param data correlation data - full square or just a combined strip with axis at row 0
* @param axis_only look for the maximum on the disparity axis only. For the rectangular strips and symmetrical forced to be true.
* @param minMax minimal value of the maximum to be considered valid
* @param debug print debug data
* @return a pair of {x,y} or null. x, y are 0 in the center, disparity is -x
*/
@Deprecated
public int [] getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
double [] data, // [data_size * data_size]
boolean axis_only,
......@@ -1275,6 +1726,46 @@ public class Correlation2d {
} else {
axis_only = true;
}
return getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
data, // [data_size * data_size]
data_width,
center_row,
axis_only,
minMax, // minimal value to consider (at integer location, not interpolated)
debug);
}
/**
* Find maximum correlation on the grid (before 08/28/2021)
* @param data correlation data - full square or just a combined strip with axis at row 0
* @param data_width width of the data array
* @param center_row for axis-only row0 is center, for square arrays - center row
* @param axis_only look for the maximum on the disparity axis only. For the rectangular strips and symmetrical forced to be true.
* @param minMax minimal value of the maximum to be considered valid
* @param debug print debug data
* @return a pair of {x,y} or null. x, y are 0 in the center, disparity is -x
*/
public int [] getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
double [] data, // [data_size * data_size]
int data_width,
int center_row,
boolean axis_only,
double minMax, // minimal value to consider (at integer location, not interpolated)
boolean debug)
{
// int data_width = 2 * transform_size - 1;
// int data_height = data.length / data_width;
int center = data_width / 2; // transform_size - 1;
/*
int center_row = 0;
if (data_height == data_width) {
center_row = center; // not used in lwir
} else {
axis_only = true;
}
*/
int imx = 0;
if (debug){
System.out.println("getMaxXYInt(): axis_only="+axis_only+", minMax="+minMax);
......@@ -1304,6 +1795,7 @@ public class Correlation2d {
}
/**
* Get fractional center as a "center of mass" inside circle/square from the integer max. Works on the square 2d phase
* correlation results to provide data for channel x/y offset
......@@ -1382,6 +1874,7 @@ public class Correlation2d {
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
debug);// boolean debug);
}
public double [] getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max // not used in lwir
double [] data, // [data_size * data_size]
int ixcenter, // integer center x
......@@ -1393,6 +1886,8 @@ public class Correlation2d {
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
debug); // boolean debug);
}
// No shift by 0.5 for 2021
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // rectangular strip of 1/2 of the correlation are with odd rows shifted by 1/2 pixels
int ixcenter, // integer center x
......@@ -1491,6 +1986,110 @@ public class Correlation2d {
return rslt;
}
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // rectangular strip of 1/2 of the correlation are with odd rows shifted by 1/2 pixels
int center, // = transform_size - 1;
int data_width, // = 2 * transform_size - 1;
int ixcenter, // integer center x
double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
double [] window_x, // half of a window function in x (disparity) direction
boolean debug) {
// int center = transform_size - 1;
// int data_width = 2 * transform_size - 1;
int data_height = data.length/data_width;
double wy_scale = 1.0;
if (data_height > window_y.length) {
data_height = window_y.length;
} else if (data_height < window_y.length) { // re- // not used in lwir
double swy = window_y[0];
for (int i = 1; i < data_height; i++) swy += window_y[i];
wy_scale = 1.0/swy;
}
double [][]dbg_data = null;
if (debug) {
String [] dbg_titles = {"strip","*wnd_y"};
dbg_data = new double [2][];
dbg_data[0] = debugStrip3(data);
double [] data_0 = data.clone();
for (int i = 0; i < data_height; i++) {
for (int j = 0; j < data_width; j++) {
data_0[i * data_width + j] *= (i < window_y.length) ? (wy_scale * window_y[i]): 0.0;
}
}
dbg_data[1] = debugStrip3(data_0);
int long_width = 2 * data_width; // (2 * transform_size-1);
if (dbg_data[0] != null) {
(new ShowDoubleFloatArrays()).showArrays(
dbg_data,
long_width,
dbg_data[0].length/long_width,
true,
"Strip",
dbg_titles);
}
System.out.println("getMaxXCm(), ixcenter = "+ixcenter);
for (int dy = 0; dy < data_height; dy++) {
if ((dy & 1) != 0) System.out.print(" ");
for (int dx = 0; dx < data_width; dx++) {
System.out.print(String.format(" %8.5f", data[dy * data_width + dx]));
}
System.out.println();
}
System.out.println();
}
double s0=0.0, sx=0.0, sx2 = 0.0;
int x0 = center + ixcenter; // index of the argmax, starting with 0
for (int dy = 0; dy < data_height; dy++) {
int odd = dy & 1;
double wy = ((dy == 0)? wy_scale: (2.0 * wy_scale))*window_y[dy];
int indx0 = data_width * dy;
for (int adx = odd; adx < window_x.length; adx+=2) { // index in window_x
for (int dir = (adx == 0)?1:-1; dir <= 1; dir+=2) {
// calculate data index
int idx = (adx * dir) >> 1;
int x = 2 * idx + odd;
int x1 = x0 + idx; // correct
if (debug) System.out.print(String.format(" %2d:%2d:%d %3d", dy,adx,dir,x));
if ((x1 >= 0 ) && (x1 < data_width)) {
double d = data[indx0+x1];
/// if (!Double.isNaN(d)) {
if (!Double.isNaN(d) && (d > 0.0)) { // with negative d s0 can get very low value (or even negative)
d*= wy*window_x[adx];
s0+= d;
sx += d * x; // result x is twice larger (corresponds to window_x)
sx2 += d * x * x;
if (debug) System.out.print(String.format("%8.5f", data[indx0+x1])); //d));
}
} else {
if (debug) System.out.print("********");
}
}
}
if (debug) System.out.println();
}
if (debug){
System.out.println("getMaxXCm() -> s0="+s0+", sx="+sx+", sx2="+sx2+", ixcenter="+ixcenter);
}
if (s0 == 0.0) return null;
double [] rslt = {
ixcenter + sx/s0/2, // new center in disparity units, relative to the correlation center
s0, // total "weight"
Math.sqrt(s0*sx2 - sx*sx)/s0/2}; // standard deviation in disparity units (divide weight by the standard deviation for quality?)
if (debug){
System.out.println("getMaxXCm() -> "+rslt[0]+"/"+rslt[1]+"/"+rslt[2]);
}
return rslt;
}
/**
* Generate a half-window for correlation center of mass calculation. Window has a flat top,
* then half-cosine fade to zero
......
......@@ -13,13 +13,16 @@ public class ImageDtt extends ImageDttCPU {
private final GPUTileProcessor.GpuQuad gpuQuad;
public ImageDtt(
int numSensors,
int transform_size,
ImageDttParameters imgdtt_params,
boolean mono,
boolean lwir,
double scale_strengths,
GPUTileProcessor.GpuQuad gpuQuadIn){
super (
super ( numSensors,
transform_size,
imgdtt_params,
mono,
lwir,
scale_strengths);
......@@ -27,17 +30,19 @@ public class ImageDtt extends ImageDttCPU {
}
public ImageDtt(
int numSensors,
int transform_size,
ImageDttParameters imgdtt_params,
boolean mono,
boolean lwir,
double scale_strengths){
super (
super ( numSensors,
transform_size,
imgdtt_params,
mono,
lwir,
scale_strengths);
gpuQuad = null;
}
public GPUTileProcessor.GpuQuad getGPU() {
......@@ -500,24 +505,6 @@ public class ImageDtt extends ImageDttCPU {
if (corr_indices.length > 0) {
/*
if (true) { // debugging only
int [] wh = new int[2];
double [][] dbg_corr = GPUTileProcessor.getCorr2DView(
tilesX,
tilesY,
corr_indices,
fcorr2D,
wh);
(new ShowDoubleFloatArrays()).showArrays(
dbg_corr,
wh[0],
wh[1],
true,
"dbg-corr2D-initial", // name+"-CORR2D-D"+clt_parameters.disparity,
GPUTileProcessor.getCorrTitles());
}
*/
final int corr_length = fcorr2D[0].length;// all correlation tiles have the same size
// assuming that the correlation pairs sets are the same for each tile that has correlations
// find this number
......@@ -538,6 +525,7 @@ public class ImageDtt extends ImageDttCPU {
// double [][] corrs = new double [GPUTileProcessor.NUM_PAIRS][corr_length]; // 225-long (15x15)
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -1379,6 +1367,7 @@ public class ImageDtt extends ImageDttCPU {
// double [][] corrs = new double [GPUTileProcessor.NUM_PAIRS][corr_length]; // 225-long (15x15)
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -1762,6 +1751,7 @@ public class ImageDtt extends ImageDttCPU {
public void run() {
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -2111,6 +2101,7 @@ public class ImageDtt extends ImageDttCPU {
public void run() {
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -3165,6 +3156,7 @@ public class ImageDtt extends ImageDttCPU {
@Override
public void run() {
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -3480,6 +3472,7 @@ public class ImageDtt extends ImageDttCPU {
@Override
public void run() {
Correlation2d corr2d = new Correlation2d(
numSensors,
imgdtt_params, // ImageDttParameters imgdtt_params,
transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -85,7 +85,27 @@ public class ImageDttParameters {
public boolean cnvx_non_coll = true; // require non-collinear samples in a valid correlation pair
public int cnvx_min_pairs = 5; // minimal number 2D correlation pairs per tile
public int mcorr_multi = 4; // apply *_multi if number of sensors >= mcorr_multi
public boolean mcorr_all = true; // correlate all N*(N-1)/2 pairs
public boolean mcorr_all_multi = false; // correlate all N*(N-1)/2 pairs for multi
public boolean mcorr_dia = true; // all diameters (2 pairs for quad, 8 - for lwir16)
public boolean mcorr_dia_multi = true; // all diameters
public boolean mcorr_sq = true; // all squares (4 pairs for quad, 16 - for lwir16)
public boolean mcorr_sq_multi = true; // all squares
public boolean mcorr_neib = true; // all neighbors (4 pairs for quad, 16 - for lwir16)
public boolean mcorr_neib_multi = true; // all neighbors
public boolean mcorr_cons_all = true; // consolidate all available pairs
public boolean mcorr_cons_dia = true; // consolidate all having length of a diameter
public boolean mcorr_cons_sq = true; // consolidate all having length of a square side
public boolean mcorr_cons_neib = true; // consolidate all having shortest length
public boolean mcorr_cons_hor = true; // consolidate all horizontal pairs
public boolean mcorr_cons_vert = true; // consolidate all vertical pairs
/// these are just for testing, actual will be generated specifically for different applications (LY will use closest pairs)
public int mcorr_comb_width = 15;
public int mcorr_comb_height = 15;
public int mcorr_comb_offset = 0;
public double mcorr_comb_disp = 1.0; // per-pixel disparity relative to a side of a square
// pole window will be inverted
public int corr_strip_notch = 11; // number of rows to calculate for vertical poles
......@@ -104,7 +124,7 @@ public class ImageDttParameters {
public boolean pcorr_use = false; // use group phase correlation for disparity calculation in existing code
public boolean pcorr_use_hv = true; // use group phase correlation to combine hor and vert pairs
public double pcorr_sigma_mono = 0.15; // correlation sigma for monochrome images (after normalization)
public double pcorr_sigma = 0.8; // correlation sigma for Bayder images (after normalization)
public double pcorr_sigma = 0.8; // correlation sigma for Bayer images (after normalization)
public double pcorr_sigma_rb = 0.5; // correlation sigma extra for R and B (before normalization)
public double pcorr_fat_zero = 0.05; // correlation relative fat zero for Bayer images
public double pcorr_fat_zero_mono = 0.03; // correlation relative fat zero for monochrome images
......@@ -183,6 +203,7 @@ public class ImageDttParameters {
public int lma_debug_level = 0; //
public int lma_debug_level1 = 0; //
public boolean lma_debug_graphic = false; //
@Deprecated
public boolean corr_var_cam = true; // New correlation mode compatible with 8 subcameras
public double cm_max_normalization = 0.55; // fraction of correlation maximum radius, being squared multiplied by maximum to have the same total mass
public double lma_dbg_scale = 0.0; // scale lma_dbg_offset
......@@ -212,6 +233,22 @@ public class ImageDttParameters {
}
public boolean getMcorrAll(int numSens) {
return (numSens > mcorr_multi) ? mcorr_all_multi : mcorr_all;
}
public boolean getMcorrDia(int numSens) {
return (numSens > mcorr_multi) ? mcorr_dia_multi : mcorr_dia;
}
public boolean getMcorrSq(int numSens) {
return (numSens > mcorr_multi) ? mcorr_sq_multi : mcorr_sq;
}
public boolean getMcorrNeib(int numSens) {
return (numSens > mcorr_multi) ? mcorr_neib_multi : mcorr_neib;
}
public void dialogQuestions(GenericJTabbedDialog gd) {
gd.addCheckbox ("Debug CPU->GPU matching", this.gpu_mode_debug,
......@@ -311,8 +348,52 @@ public class ImageDttParameters {
gd.addNumericField("Minimal correlation pairs per tile", this.cnvx_min_pairs, 0, 3, "",
"Minimal number 2D correlation pairs per tile");
gd.addMessage("Correlation pairs selection for multicamera confifurations");
gd.addNumericField("Min number of sensors for \"multi\"", this.mcorr_multi, 0, 3, "sensors",
"Cameras with this or larger number of sensor will use a \"_multi\" version of parameters (when available)");
gd.addCheckbox ("Calculate all correlation pairs for small cameras", this.mcorr_all,
"N*(N-1)/2: 6 for quad, 120 for lwir16 ");
gd.addCheckbox ("Calculate all correlation pairs for multi cameras", this.mcorr_all_multi,
"N*(N-1)/2: 6 for quad, 120 for lwir16");
gd.addCheckbox ("Calculate correlation pairs - diameters for small cameras", this.mcorr_dia,
"All diameter pairs. N/2: 2 for quad, 8 for lwir16");
gd.addCheckbox ("Calculate correlation pairs - diameters for multi cameras", this.mcorr_dia_multi,
"All diameter pairs. N/2: 2 for quad, 8 for lwir16");
gd.addCheckbox ("Calculate correlation pairs of squares for small cameras", this.mcorr_sq,
"All pairs with the lengths equal to side of a square. N: 4 for quad, 16 for lwir16");
gd.addCheckbox ("Calculate correlation pairs of squares for multi cameras", this.mcorr_sq_multi,
"All pairs with the lengths equal to side of a square. N: 4 for quad, 16 for lwir16");
gd.addCheckbox ("Calculate neighbor pairs for small cameras", this.mcorr_neib,
"All neighbor pairs. N: 4 for quad, 16 for lwir16");
gd.addCheckbox ("Calculate neighbor pairs for multi cameras", this.mcorr_neib_multi,
"All neighbor pairs. N: 4 for quad, 16 for lwir16");
gd.addCheckbox ("Combine all pairs", this.mcorr_cons_all,
"Combine all calculated correlation pairs");
gd.addCheckbox ("Combine diameters", this.mcorr_cons_dia,
"Combine all pairs with the length of a diameter");
gd.addCheckbox ("Combine squares", this.mcorr_cons_sq,
"Combine all pairs with the length of a side of an inscribed square");
gd.addCheckbox ("Combine neighbors", this.mcorr_cons_neib,
"Combine all neighbor pairs ");
gd.addCheckbox ("Combine horizontal pairs", this.mcorr_cons_hor,
"Combine all calculated horizontal pairs regardless of length");
gd.addCheckbox ("Combine vertical pairs", this.mcorr_cons_vert,
"Combine all calculated vertical pairs regardless of length");
gd.addMessage("Generating grid for combining visualization, actual will be provided programmatically");
gd.addNumericField("Width of a combined correlation tile", this.mcorr_comb_width, 0, 3, "pix",
"Width of a tile to combine correlations after rotation/scaling");
gd.addNumericField("Height of a combined correlation tile", this.mcorr_comb_height, 0, 3, "pix",
"Full height of a tile to combine correlations after rotation/scaling");
gd.addNumericField("Height offset of a combined correlation tile", this.mcorr_comb_offset, 0, 3, "pix",
"0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)");
gd.addNumericField("Relative per-pixel disparity", this.mcorr_comb_disp, 3,6,"pix",
"Combined tile per-pixel disparity for baseline == side of a square");
gd.addMessage("Window for pole detection mode");
gd.addNumericField("Strip height for pole detection", this.corr_strip_notch, 0, 3, "half-pix",
......@@ -576,6 +657,27 @@ public class ImageDttParameters {
this.cnvx_non_coll = gd.getNextBoolean();
this.cnvx_min_pairs= (int) gd.getNextNumber();
this.mcorr_multi= (int) gd.getNextNumber();
this.mcorr_all = gd.getNextBoolean();
this.mcorr_all_multi = gd.getNextBoolean();
this.mcorr_dia = gd.getNextBoolean();
this.mcorr_dia_multi = gd.getNextBoolean();
this.mcorr_sq = gd.getNextBoolean();
this.mcorr_sq_multi = gd.getNextBoolean();
this.mcorr_neib = gd.getNextBoolean();
this.mcorr_neib_multi = gd.getNextBoolean();
this.mcorr_cons_all = gd.getNextBoolean();
this.mcorr_cons_dia = gd.getNextBoolean();
this.mcorr_cons_sq = gd.getNextBoolean();
this.mcorr_cons_neib = gd.getNextBoolean();
this.mcorr_cons_hor = gd.getNextBoolean();
this.mcorr_cons_vert = gd.getNextBoolean();
this.mcorr_comb_width= (int) gd.getNextNumber();
this.mcorr_comb_height=(int) gd.getNextNumber();
this.mcorr_comb_offset=(int) gd.getNextNumber();
this.mcorr_comb_disp= gd.getNextNumber();
this.corr_strip_notch= (int) gd.getNextNumber();
this.corr_notch_hwidth= gd.getNextNumber();
this.corr_notch_blur= gd.getNextNumber();
......@@ -729,6 +831,27 @@ public class ImageDttParameters {
properties.setProperty(prefix+"cnvx_non_coll", this.cnvx_non_coll +"");
properties.setProperty(prefix+"cnvx_min_pairs", this.cnvx_min_pairs +"");
properties.setProperty(prefix+"mcorr_multi", this.mcorr_multi +"");
properties.setProperty(prefix+"mcorr_all", this.mcorr_all +"");
properties.setProperty(prefix+"mcorr_all_multi", this.mcorr_all_multi +"");
properties.setProperty(prefix+"mcorr_dia", this.mcorr_dia +"");
properties.setProperty(prefix+"mcorr_dia_multi", this.mcorr_dia_multi +"");
properties.setProperty(prefix+"mcorr_sq", this.mcorr_sq +"");
properties.setProperty(prefix+"mcorr_sq_multi", this.mcorr_sq_multi +"");
properties.setProperty(prefix+"mcorr_neib", this.mcorr_neib +"");
properties.setProperty(prefix+"mcorr_neib_multi", this.mcorr_neib_multi +"");
properties.setProperty(prefix+"mcorr_cons_all", this.mcorr_cons_all +"");
properties.setProperty(prefix+"mcorr_cons_dia", this.mcorr_cons_dia +"");
properties.setProperty(prefix+"mcorr_cons_sq", this.mcorr_cons_sq +"");
properties.setProperty(prefix+"mcorr_cons_neib", this.mcorr_cons_neib +"");
properties.setProperty(prefix+"mcorr_cons_hor", this.mcorr_cons_hor +"");
properties.setProperty(prefix+"mcorr_cons_vert", this.mcorr_cons_vert +"");
properties.setProperty(prefix+"mcorr_comb_width", this.mcorr_comb_width +"");
properties.setProperty(prefix+"mcorr_comb_height", this.mcorr_comb_height +"");
properties.setProperty(prefix+"mcorr_comb_offset", this.mcorr_comb_offset +"");
properties.setProperty(prefix+"mcorr_comb_disp", this.mcorr_comb_disp +"");
properties.setProperty(prefix+"corr_strip_notch", this.corr_strip_notch +"");
properties.setProperty(prefix+"corr_notch_hwidth", this.corr_notch_hwidth +"");
properties.setProperty(prefix+"corr_notch_blur", this.corr_notch_blur +"");
......@@ -886,6 +1009,27 @@ public class ImageDttParameters {
if (properties.getProperty(prefix+"cnvx_non_coll")!=null) this.cnvx_non_coll=Boolean.parseBoolean(properties.getProperty(prefix+"cnvx_non_coll"));
if (properties.getProperty(prefix+"cnvx_min_pairs")!=null) this.cnvx_min_pairs=Integer.parseInt(properties.getProperty(prefix+"cnvx_min_pairs"));
if (properties.getProperty(prefix+"mcorr_multi")!=null) this.mcorr_multi=Integer.parseInt(properties.getProperty(prefix+"mcorr_multi"));
if (properties.getProperty(prefix+"mcorr_all")!=null) this.mcorr_all=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_all"));
if (properties.getProperty(prefix+"mcorr_all_multi")!=null) this.mcorr_all_multi=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_all_multi"));
if (properties.getProperty(prefix+"mcorr_dia")!=null) this.mcorr_dia=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_dia"));
if (properties.getProperty(prefix+"mcorr_dia_multi")!=null) this.mcorr_dia_multi=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_dia_multi"));
if (properties.getProperty(prefix+"mcorr_sq")!=null) this.mcorr_sq=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_sq"));
if (properties.getProperty(prefix+"mcorr_sq_multi")!=null) this.mcorr_sq_multi=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_sq_multi"));
if (properties.getProperty(prefix+"mcorr_neib")!=null) this.mcorr_neib=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_neib"));
if (properties.getProperty(prefix+"mcorr_neib_multi")!=null) this.mcorr_neib_multi=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_neib_multi"));
if (properties.getProperty(prefix+"mcorr_cons_all")!=null) this.mcorr_cons_all=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_all"));
if (properties.getProperty(prefix+"mcorr_cons_dia")!=null) this.mcorr_cons_dia=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_dia"));
if (properties.getProperty(prefix+"mcorr_cons_sq")!=null) this.mcorr_cons_sq=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_sq"));
if (properties.getProperty(prefix+"mcorr_cons_neib")!=null) this.mcorr_cons_neib=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_neib"));
if (properties.getProperty(prefix+"mcorr_cons_hor")!=null) this.mcorr_cons_hor=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_hor"));
if (properties.getProperty(prefix+"mcorr_cons_vert")!=null) this.mcorr_cons_vert=Boolean.parseBoolean(properties.getProperty(prefix+"mcorr_cons_vert"));
if (properties.getProperty(prefix+"mcorr_comb_width")!=null) this.mcorr_comb_width=Integer.parseInt(properties.getProperty(prefix+"mcorr_comb_width"));
if (properties.getProperty(prefix+"mcorr_comb_height")!=null) this.mcorr_comb_height=Integer.parseInt(properties.getProperty(prefix+"mcorr_comb_height"));
if (properties.getProperty(prefix+"mcorr_comb_offset")!=null) this.mcorr_comb_offset=Integer.parseInt(properties.getProperty(prefix+"mcorr_comb_offset"));
if (properties.getProperty(prefix+"mcorr_comb_disp")!=null) this.mcorr_comb_disp=Double.parseDouble(properties.getProperty(prefix+"mcorr_comb_disp"));
if (properties.getProperty(prefix+"corr_strip_notch")!=null) this.corr_strip_notch=Integer.parseInt(properties.getProperty(prefix+"corr_strip_notch"));
if (properties.getProperty(prefix+"corr_notch_hwidth")!=null) this.corr_notch_hwidth=Double.parseDouble(properties.getProperty(prefix+"corr_notch_hwidth"));
if (properties.getProperty(prefix+"corr_notch_blur")!=null) this.corr_notch_blur=Double.parseDouble(properties.getProperty(prefix+"corr_notch_blur"));
......@@ -1039,6 +1183,27 @@ public class ImageDttParameters {
idp.cnvx_non_coll= this.cnvx_non_coll;
idp.cnvx_min_pairs= this.cnvx_min_pairs;
idp.mcorr_multi= this.mcorr_multi;
idp.mcorr_all= this.mcorr_all;
idp.mcorr_all_multi= this.mcorr_all_multi;
idp.mcorr_dia= this.mcorr_dia;
idp.mcorr_dia_multi= this.mcorr_dia_multi;
idp.mcorr_sq= this.mcorr_sq;
idp.mcorr_sq_multi= this.mcorr_sq_multi;
idp.mcorr_neib= this.mcorr_neib;
idp.mcorr_neib_multi= this.mcorr_neib_multi;
idp.mcorr_cons_all= this.mcorr_cons_all;
idp.mcorr_cons_dia= this.mcorr_cons_dia;
idp.mcorr_cons_sq= this.mcorr_cons_sq;
idp.mcorr_cons_neib= this.mcorr_cons_neib;
idp.mcorr_cons_hor= this.mcorr_cons_hor;
idp.mcorr_cons_vert= this.mcorr_cons_vert;
idp.mcorr_comb_width= this.mcorr_comb_width;
idp.mcorr_comb_height= this.mcorr_comb_height;
idp.mcorr_comb_offset= this.mcorr_comb_offset;
idp.mcorr_comb_disp= this.mcorr_comb_disp;
idp.corr_strip_notch= this.corr_strip_notch;
idp.corr_notch_hwidth= this.corr_notch_hwidth;
idp.corr_notch_blur= this.corr_notch_blur;
......
......@@ -309,7 +309,9 @@ public class MacroCorrelation {
*/
ImageDtt image_dtt = new ImageDtt(
geometryCorrection.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
this.mtp.isMonochrome(),
this.mtp.isLwir(),
clt_parameters.getScaleStrength(this.mtp.isAux()));
......
......@@ -42,13 +42,15 @@ public class OpticalFlow {
public static double LINE_ERR = 0.1;
public int threadsMax = 100; // maximal number of threads to launch
public boolean updateStatus = true;
public int numSens;
public OpticalFlow (
int numSens,
int threadsMax, // maximal number of threads to launch
boolean updateStatus) {
this.numSens = numSens;
this.threadsMax = threadsMax;
this.updateStatus = updateStatus;
}
/**
......@@ -1019,7 +1021,9 @@ public class OpticalFlow {
final int chn_offset = QuadCLT.DSRBG_STRENGTH; // start scene_tiles, reference tiles with this 2-nd index
final ImageDtt image_dtt = new ImageDtt(
numSens,
transform_size,
null, // FIXME: Needs ImageDttParameters (clt_parameters.img_dtt),
false,
false,
1.0);
......@@ -1046,6 +1050,7 @@ public class OpticalFlow {
double [][][] clt_tiles_scene = new double [num_channels][4][];
Correlation2d corr2d = new Correlation2d(
numSens,
transform_size, // int transform_size,
false, // boolean monochrome,
false); // boolean debug)
......@@ -1140,6 +1145,7 @@ public class OpticalFlow {
double [][] corr_tile_2D = new double [4][tile_length];
Correlation2d corr2d = new Correlation2d(
numSens,
transform_size, // int transform_size,
false, // boolean monochrome,
false); // boolean debug)
......@@ -3894,7 +3900,9 @@ public class OpticalFlow {
}
ImageDtt image_dtt = new ImageDtt(
numSens,
clt_parameters.transform_size,
clt_parameters.img_dtt,
ref_scene.isMonochrome(),
ref_scene.isLwir(),
clt_parameters.getScaleStrength(ref_scene.isAux()),
......@@ -4803,7 +4811,9 @@ public class OpticalFlow {
float [][][][][] fcorrs_combo_td = new float[num_scenes][4][tilesY][tilesX][];
ImageDtt image_dtt = new ImageDtt(
numSens,
clt_parameters.transform_size,
clt_parameters.img_dtt,
ref_scene.isMonochrome(),
ref_scene.isLwir(),
clt_parameters.getScaleStrength(ref_scene.isAux()),
......
......@@ -65,7 +65,7 @@ public class QuadCLT extends QuadCLTCPU {
*/
public QuadCLT(
public QuadCLT( // creates AUX, does not know numSensors?
String prefix,
Properties properties,
EyesisCorrections eyesisCorrections,
......@@ -2041,7 +2041,9 @@ public class QuadCLT extends QuadCLTCPU {
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
is_mono,
is_lwir,
clt_parameters.getScaleStrength(isAux())); // 1.0);
......@@ -2304,7 +2306,9 @@ public class QuadCLT extends QuadCLTCPU {
cwgreen});
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
is_mono,
is_lwir,
1.0);
......@@ -3023,7 +3027,9 @@ public class QuadCLT extends QuadCLTCPU {
double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -3277,7 +3283,9 @@ public class QuadCLT extends QuadCLTCPU {
}
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -3415,7 +3423,9 @@ public class QuadCLT extends QuadCLTCPU {
}
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -3541,7 +3551,9 @@ public class QuadCLT extends QuadCLTCPU {
final double gpu_sigma_rb_corr = isMonochrome()? 1.0 : clt_parameters.gpu_sigma_rb_corr;
final double gpu_sigma_log_corr = clt_parameters.getGpuCorrLoGSigma(isMonochrome());
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -4136,7 +4148,9 @@ public class QuadCLT extends QuadCLTCPU {
}
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -4594,7 +4608,9 @@ public class QuadCLT extends QuadCLTCPU {
}
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -4712,7 +4728,9 @@ public class QuadCLT extends QuadCLTCPU {
}
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......@@ -4919,7 +4937,9 @@ public class QuadCLT extends QuadCLTCPU {
}
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()),
......
......@@ -145,6 +145,13 @@ public class QuadCLTCPU {
return tp;
}
public int getNumSensors() {
if (geometryCorrection == null) {
System.out.println("*** BUG! geometryCorrection is not set, number of sensors is unknown! Will use 4 sensors ****");
return 4;
}
return geometryCorrection.getNumSensors();
}
public QuadCLTCPU(
QuadCLTCPU qParent,
String name
......@@ -1018,7 +1025,9 @@ public class QuadCLTCPU {
int centered_len = (2*dtt_size-1) * (2*dtt_size-1);
double [] kernel_centered = new double [centered_len + extra_items];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -1198,7 +1207,9 @@ public class QuadCLTCPU {
System.out.println("1.Threads done at "+IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
// Calculate differential offsets to interpolate for tiles between kernel centers
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -2161,7 +2172,9 @@ public class QuadCLTCPU {
}
if (this.correctionsParameters.deconvolve) { // process with DCT, otherwise use simple debayer
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -2767,7 +2780,9 @@ public class QuadCLTCPU {
}
if (this.correctionsParameters.deconvolve) { // process with DCT, otherwise use simple debayer
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -3336,7 +3351,9 @@ public class QuadCLTCPU {
ImageStack stack;
// =================
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -4606,8 +4623,6 @@ public class QuadCLTCPU {
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
// may use this.StartTime to report intermediate steps execution times
/// String name=this.correctionsParameters.getModelName((String) imp_quad[0].getProperty("name"));
/// String path= (String) imp_quad[0].getProperty("path");
ImagePlus [] results = new ImagePlus[imp_quad.length];
for (int i = 0; i < results.length; i++) {
......@@ -4615,33 +4630,10 @@ public class QuadCLTCPU {
results[i].setTitle(results[i].getTitle()+"RAW");
}
if (debugLevel>1) System.out.println("processing: "+image_path);
/* // Moved to condifuinImageSet
double [][][] double_stacks = new double [imp_quad.length][][];
for (int i = 0; i < double_stacks.length; i++){
double_stacks[i] = eyesisCorrections.bayerToDoubleStack(
imp_quad[i], // source Bayer image, linearized, 32-bit (float))
null, // no margins, no oversample
this.is_mono);
}
for (int i = 0; i < double_stacks.length; i++){
if ( double_stacks[i].length > 2) {
for (int j =0 ; j < double_stacks[i][0].length; j++){
double_stacks[i][2][j]*=0.5; // Scale green 0.5 to compensate more pixels than R,B
}
} else {
for (int j =0 ; j < double_stacks[i][0].length; j++){
double_stacks[i][0][j]*=1.0; // Scale mono by 1/4 - to have the same overall "gain" as for bayer
}
}
}
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
clt_parameters,
threadsMax);
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -4655,49 +4647,54 @@ public class QuadCLTCPU {
//TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles
double [][][][] clt_corr_combo = null;
double [][][][][] clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
double [][] clt_mismatch = null; // [3*4][tp.tilesY * tp.tilesX] // transpose unapplied
// double [][][][][] clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
double [][][][] clt_corr_out = null; // will be used instead of clt_corr_partial
double [][][][] clt_combo_out = null; // will be used instead of clt_corr_combo
double [][][][] texture_tiles = null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualization mode full 16 or overlapped
double [][] disparity_map = null;
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (clt_parameters.correlate){ // true
clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will it work???
Correlation2d correlation2d = image_dtt.getCorrelation2d();
texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
for (int k = 0; k<clt_corr_combo.length; k++){
clt_corr_combo[k][i][j] = null;
}
texture_tiles[i][j] = null;
}
}
if (!infinity_corr && clt_parameters.corr_keep){ // true
int num_pairs = correlation2d.getCorrTitles().length;
int num_combo = correlation2d.getComboTitles().length;
clt_corr_out = new double [num_pairs][][][];
clt_combo_out = new double [num_combo][][][];
/*
clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
clt_corr_partial[i][j] = null;
}
}
*/
} // clt_parameters.corr_mismatch = false
if (clt_parameters.corr_mismatch || apply_corr || infinity_corr){ // added infinity_corr
clt_mismatch = new double [12][]; // What is 12?// not used in lwir
}
disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
}
// Includes all 3 colors - will have zeros in unused
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
double min_corr_selected = clt_parameters.min_corr;
double [][] shiftXY = new double [4][2];
if (!clt_parameters.fine_corr_ignore) {
double [][] shiftXY = new double [getNumSensors()][2];
if (!clt_parameters.fine_corr_ignore) {// invalid for AUX!
double [][] shiftXY0 = {
{clt_parameters.fine_corr_x_0,clt_parameters.fine_corr_y_0},
{clt_parameters.fine_corr_x_1,clt_parameters.fine_corr_y_1},
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
shiftXY = shiftXY0;
// FIXME - only first 4 sensors have correction. And is it the same for aux and main?
for (int i = 0; i < shiftXY0.length;i++) {
shiftXY[i] = shiftXY0[i];
}
// shiftXY = shiftXY0;
}
double z_correction = clt_parameters.z_correction;
......@@ -4705,6 +4702,19 @@ public class QuadCLTCPU {
z_correction +=clt_parameters.z_corr_map.get(image_name);// not used in lwir
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
// fix this.fine_corr
if (this.fine_corr.length != getNumSensors()) {
System.out.println ("**** this.fine_corr.length != getNumSensors(), fixing");
double [][][] fine_corr0 = this.fine_corr;
this.fine_corr = new double [getNumSensors()][2][6];
for (int i = 0; i < fine_corr0.length; i++) {
this.fine_corr[i] = fine_corr0[i];
}
}
if (debugLevel > -1000) texture_tiles = null; // FIXME: until texture generation for multi-cam is fixed
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
......@@ -4712,10 +4722,9 @@ public class QuadCLTCPU {
disparity_array, // final double disparity,
image_data, // double_stacks, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_corr_partial, // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_mismatch, // [12][tp.tilesY * tp.tilesX] // transpose unapplied. null - do not calculate
// correlation results
clt_corr_out, // final double [][][][] clt_corr_out, // sparse (by the first index) [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] or null
clt_combo_out, // final double [][][][] clt_combo_out, // sparse (by the first index) [type][tilesY][tilesX][(combo_tile_size] or null
disparity_map, // [2][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
imp_quad[0].getWidth(), // final int width,
......@@ -4725,13 +4734,10 @@ public class QuadCLTCPU {
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
// clt_parameters.corr_mask,
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
// clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
// clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
......@@ -4746,16 +4752,19 @@ public class QuadCLTCPU {
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
/// image_dtt.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
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)
clt_parameters.img_dtt.mcorr_comb_width, // final int mcorr_comb_width, // combined correlation tile width
clt_parameters.img_dtt.mcorr_comb_height, // final int mcorr_comb_height, // combined correlation tile full height
clt_parameters.img_dtt.mcorr_comb_offset, // final int mcorr_comb_offset, // combined correlation tile height offset: 0 - centered (-height/2 to height/2), height/2 - only positive (0 to height)
clt_parameters.img_dtt.mcorr_comb_disp, // final double mcorr_comb_disp, // Combined tile per-pixel disparity for baseline == side of a square
clt_parameters.tileX, // -1234, // clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY, -1234 will cause port coordinates debug images
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
......@@ -4779,7 +4788,6 @@ public class QuadCLTCPU {
if (clt_parameters.show_nonoverlap){// not used in lwir
texture_nonoverlap = image_dtt.combineRBGATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
/// image_dtt.transform_size,
false, // when false - output each tile as 16x16, true - overlap to make 8x8
clt_parameters.sharp_alpha, // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
threadsMax, // maximal number of threads to launch
......@@ -4797,7 +4805,6 @@ public class QuadCLTCPU {
int alpha_index = 3;
texture_overlap = image_dtt.combineRBGATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
/// image_dtt.transform_size,
true, // when false - output each tile as 16x16, true - overlap to make 8x8
clt_parameters.sharp_alpha, // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
threadsMax, // maximal number of threads to launch
......@@ -4845,6 +4852,9 @@ public class QuadCLTCPU {
}
}
}
/*
// visualize correlation results
// bo-b3 non-zero, r*, g* - zero
if (clt_corr_combo!=null){
......@@ -5011,47 +5021,60 @@ public class QuadCLTCPU {
titles );
}
if (!batch_mode && !infinity_corr && (clt_corr_partial!=null)){ // not used in lwir FALSE
if (debugLevel > -1){ // -1
String [] allColorNames = {"red","blue","green","combo"};
String [] titles = new String[clt_corr_partial.length];
for (int i = 0; i < titles.length; i++){
titles[i]=allColorNames[i % allColorNames.length]+"_"+(i / allColorNames.length);
}
double [][] corr_rslt_partial = image_dtt.corr_partial_dbg(
clt_corr_partial,
2*image_dtt.transform_size - 1, //final int corr_size,
4, // final int pairs,
4, // final int colors,
clt_parameters.corr_border_contrast,
*/
// pairwise 2D correlations
if (!batch_mode && !infinity_corr && (clt_corr_out != null)){
if (debugLevel > -1){ // -1
String [] titles = image_dtt.correlation2d.getCorrTitles();
double [][] corr_rslt = ImageDtt.corr_partial_dbg(
clt_corr_out, // final double [][][][] corr_data,
2 * image_dtt.transform_size - 1, //final int corr_width,
2 * image_dtt.transform_size - 1, //final int corr_height,
threadsMax,
debugLevel);
// titles.length = 15, corr_rslt_partial.length=16!
System.out.println("corr_rslt_partial.length = "+corr_rslt_partial.length+", titles.length = "+titles.length);
System.out.println("corr_rslt.length = "+corr_rslt.length+", titles.length = "+titles.length);
sdfa_instance.showArrays( // out of boundary 15
corr_rslt_partial,
corr_rslt,
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
image_name+sAux()+"-PART_CORR-D"+clt_parameters.disparity);
// titles);
image_name+sAux()+"-CORR-D"+clt_parameters.disparity,
titles);
}
}
if (!batch_mode && !infinity_corr && (clt_combo_out != null)){
if (debugLevel > -1){ // -1
String [] titles = image_dtt.correlation2d.getComboTitles();
double [][] combo_rslt = ImageDtt.corr_partial_dbg(
clt_combo_out, // final double [][][][] corr_data,
clt_parameters.img_dtt.mcorr_comb_width, // final int corr_width,
clt_parameters.img_dtt.mcorr_comb_height, // final int corr_height
threadsMax,
debugLevel);
System.out.println("combo_rslt.length = "+combo_rslt.length+", titles.length = "+titles.length);
sdfa_instance.showArrays(
combo_rslt,
tilesX * clt_parameters.img_dtt.mcorr_comb_width,
tilesY * clt_parameters.img_dtt.mcorr_comb_height,
true,
image_name+sAux()+"-COMBO-D"+clt_parameters.disparity,
titles);
}
}
double [][][] iclt_data = new double [clt_data.length][][];
if (!infinity_corr && (clt_parameters.gen_chn_img || clt_parameters.gen_4_img || clt_parameters.gen_chn_stacks)) {
// ImagePlus [] imps_RGB = new ImagePlus[clt_data.length];
for (int iQuad = 0; iQuad < clt_data.length; iQuad++){
// String title=name+"-"+String.format("%02d", iQuad);
// String titleFull=title+"-SPLIT-D"+clt_parameters.disparity;
if (clt_parameters.getCorrSigma(image_dtt.isMonochrome()) > 0){ // no filter at all
for (int chn = 0; chn < clt_data[iQuad].length; chn++) if (clt_data[iQuad][chn] != null){
image_dtt.clt_lpf(
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_data[iQuad][chn],
/// image_dtt.transform_size,
threadsMax,
debugLevel);
}
......@@ -5084,7 +5107,6 @@ public class QuadCLTCPU {
for (int ncol=0; ncol<iclt_data[iQuad].length;ncol++) if (clt_data[iQuad][ncol] != null) {
iclt_data[iQuad][ncol] = image_dtt.iclt_2d(
clt_data[iQuad][ncol], // scanline representation of dcd data, organized as dct_size x dct_size tiles
/// image_dtt.transform_size, // final int
clt_parameters.clt_window, // window_type
15, // clt_parameters.iclt_mask, //which of 4 to transform back
0, // clt_parameters.dbg_mode, //which of 4 to transform back
......@@ -5093,7 +5115,6 @@ public class QuadCLTCPU {
}
if (clt_parameters.gen_chn_stacks) sdfa_instance.showArrays(
// if (clt_parameters.gen_chn_stacks || true) sdfa_instance.showArrays(
iclt_data[iQuad],
(tilesX + 0) * image_dtt.transform_size,
(tilesY + 0) * image_dtt.transform_size,
......@@ -5125,7 +5146,7 @@ public class QuadCLTCPU {
}
setColdHot(cold_hot); // will be used for shifted images and for texture tiles
}
ImagePlus [] imps_RGB = new ImagePlus[clt_data.length];
ImagePlus [] imps_RGB = new ImagePlus[clt_data.length]; // all 16 here
for (int iQuad = 0; iQuad < clt_data.length; iQuad++){
if (!clt_parameters.gen_chn_img) continue;
String title=String.format("%s%s-%02d",image_name, sAux(), iQuad);
......@@ -5150,6 +5171,12 @@ public class QuadCLTCPU {
if (clt_parameters.gen_chn_img) {
// combine to a sliced color image
int [] slice_seq = {0,1,3,2}; //clockwise
if (imps_RGB.length > 4) {
slice_seq = new int [imps_RGB.length];
for (int i = 0; i < slice_seq.length; i++) {
slice_seq[i] = i;
}
}
int width = imps_RGB[0].getWidth();
int height = imps_RGB[0].getHeight();
ImageStack array_stack=new ImageStack(width,height);
......@@ -5181,7 +5208,7 @@ public class QuadCLTCPU {
correctionsParameters.x3dModelVersion,
true, // smart,
true); //newAllowed, // save
for (int sub_img = 0; sub_img < 4; sub_img++){
for (int sub_img = 0; sub_img < imps_RGB.length; sub_img++){
EyesisCorrections.saveAndShow(
imps_RGB[sub_img],
x3d_path,
......@@ -5209,138 +5236,750 @@ public class QuadCLTCPU {
return results;
}
public ImagePlus [] processCLTQuadCorrTestERS(
@Deprecated
public ImagePlus [] processCLTQuadCorrCPU_old( // USED in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
boolean [][] saturation_imp, // (near) saturated pixels or null
boolean [][] saturation_imp, // (near) saturated pixels or null // Not needed use this.saturation_imp
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
// int convolveFFTSize, // 128 - fft size, kernel size should be size/2
double [] scaleExposures, // probably not needed here
final boolean apply_corr, // calculate and apply additional fine geometry correction
final boolean infinity_corr, // calculate and apply geometry correction at infinity
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
int debugLevel){
if (debugLevel > -2) { // -1
debugLevel = clt_parameters.ly_debug_level;
}
final int debugLevel){
final boolean batch_mode = clt_parameters.batch_run; //disable any debug images
boolean advanced= this.correctionsParameters.zcorrect || this.correctionsParameters.equirectangular;
boolean toRGB= advanced? true: this.correctionsParameters.toRGB;
ShowDoubleFloatArrays sdfa_instance = new ShowDoubleFloatArrays(); // just for debugging?
String path= (String) imp_quad[0].getProperty("path");
// may use this.StartTime to report intermediate steps execution times
ImagePlus [] results = new ImagePlus[imp_quad.length];
for (int i = 0; i < results.length; i++) {
results[i] = imp_quad[i];
results[i].setTitle(results[i].getTitle()+"RAW");
}
if (debugLevel>1) System.out.println("processing: "+path);
// 08/12/2020 Moved to condifuinImageSet - remove setTiles?
/*
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
clt_parameters,
threadsMax);
*/
final int tilesX=tp.getTilesX(); // imp_quad[0].getWidth()/clt_parameters.transform_size;
final int tilesY=tp.getTilesY(); // imp_quad[0].getHeight()/clt_parameters.transform_size;
if (debugLevel>1) System.out.println("processing: "+image_path);
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
final int clustersX= (tilesX + clt_parameters.tileStep - 1) / clt_parameters.tileStep;
final int clustersY= (tilesY + clt_parameters.tileStep - 1) / clt_parameters.tileStep;
double [][] dsxy = new double[clustersX * clustersY][];
ImagePlus imp_sel = WindowManager.getCurrentImage();
if ((imp_sel == null) || (imp_sel.getStackSize() != ExtrinsicAdjustment.INDX_LENGTH)) {
System.out.println("No image / wrong image selected, bailing out");
return null;
} else {
System.out.println("Image: "+imp_sel.getTitle());
int width = imp_sel.getWidth();
int height = imp_sel.getHeight();
if ((width != clustersX) || (height != clustersY)) {
System.out.println(String.format("Image size mismatch: width=%d (%d), height=%d(%d)",
width, clustersX, height, clustersY));
return null;
}
ImageStack stack_sel = imp_sel.getStack();
float [][] fpixels = new float [ExtrinsicAdjustment.INDX_LENGTH][];
for (int i = 0; i < fpixels.length; i++) {
fpixels[i] = (float[]) stack_sel.getPixels(i+1);
// temporary setting up tile task file (one integer per tile, bitmask
// for testing defined for a window, later the tiles to process will be calculated based on previous passes results
int [][] tile_op = tp.setSameTileOp(clt_parameters, clt_parameters.tile_task_op, debugLevel);
double [][] disparity_array = tp.setSameDisparity(clt_parameters.disparity); // 0.0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
//TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles
double [][][][][] clt_corr_partial = null; // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)]
double [][][][] clt_corr_out = null; // will be used instead of clt_corr_partial
double [][][][] texture_tiles = null; // [tp.tilesY][tp.tilesX]["RGBA".length()][]; // tiles will be 16x16, 2 visualization mode full 16 or overlapped
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY();
if (clt_parameters.correlate){ // true
texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
texture_tiles[i][j] = null;
}
for (int tile = 0; tile < dsxy.length; tile ++) {
if (fpixels[1][tile] > 0.0) {
dsxy[tile] = new double[fpixels.length];
for (int i = 0; i < fpixels.length; i++) {
dsxy[tile][i] = fpixels[i][tile];
}
if (!infinity_corr && clt_parameters.corr_keep){ // true
clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
clt_corr_partial[i][j] = null;
}
}
} // clt_parameters.corr_mismatch = false
}
ExtrinsicAdjustment ea = new ExtrinsicAdjustment(
geometryCorrection, // GeometryCorrection gc,
clt_parameters.tileStep, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY);
double [] old_new_rms = new double[2];
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
double inf_min_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_min_narrow :clt_parameters.ly_inf_min_broad;
double inf_max_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_max_narrow :clt_parameters.ly_inf_max_broad;
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
inf_min_disparity, // -0.5, // -1.0, //double inf_min_disparity, // minimal disparity for infinity
inf_max_disparity, // 0.05, // 1.0, // double inf_max_disparity, // minimal disparity for infinity
clt_parameters.ly_inf_min_broad, // inf_min_disp_abs, // minimal disparity for infinity (absolute)
clt_parameters.ly_inf_max_broad, // maximal disparity for infinity (absolute)
clt_parameters.ly_inf_tilt, // boolean en_infinity_tilt, // select infinity tiles form right/left tilted (false - from average)
clt_parameters.ly_right_left, // boolean infinity_right_left, // balance weights between right and left halves of infinity
clt_parameters.ly_aztilt_en, // boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.ly_diff_roll_en,//boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
clt_parameters.ly_min_forced, // int min_num_forced, // minimal number of clusters with forced disparity to use it
// data, using just radial distortions
clt_parameters.ly_com_roll, //boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength, //boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
clt_parameters.ly_weight_disparity, //0.0, // double weight_disparity, // 0.0 disparity weight relative to the sum of 8 lazy eye values of the same tile
clt_parameters.ly_weight_disparity_inf,//0.5, // double weight_disparity_inf,// 0.5 disparity weight relative to the sum of 8 lazy eye values of the same tile for infinity
clt_parameters.ly_max_disparity_far, //5.0, // double max_disparity_far, // 5.0 reduce weights of near tiles proportional to sqrt(max_disparity_far/disparity)
clt_parameters.ly_max_disparity_use, //5.0, // double max_disparity_use, // 5.0 (default 1000)disable near objects completely - use to avoid ERS
// Includes all 3 colors - will have zeros in unused
double [][] disparity_map = new double [ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
clt_parameters.ly_inf_min_dfe, //1.75,// double min_dfe, // = 1.75;
clt_parameters.ly_inf_max_dfe, //5.0, // double max_dfe, // = 5.0; // <=0 - disable feature
double min_corr_selected = clt_parameters.min_corr;
double [][] shiftXY = new double [getNumSensors()][2];
if (!clt_parameters.fine_corr_ignore) {// invalid for AUX!
double [][] shiftXY0 = {
{clt_parameters.fine_corr_x_0,clt_parameters.fine_corr_y_0},
{clt_parameters.fine_corr_x_1,clt_parameters.fine_corr_y_1},
{clt_parameters.fine_corr_x_2,clt_parameters.fine_corr_y_2},
{clt_parameters.fine_corr_x_3,clt_parameters.fine_corr_y_3}};
// FIXME - only first 4 sensors have correction. And is it the same for aux and main?
for (int i = 0; i < shiftXY0.length;i++) {
shiftXY[i] = shiftXY0[i];
}
// shiftXY = shiftXY0;
}
// moving objects filtering
clt_parameters.ly_moving_en, // boolean moving_en, // enable filtering areas with potentially moving objects
clt_parameters.ly_moving_apply, // boolean moving_apply, // apply filtering areas with potentially moving objects
clt_parameters.ly_moving_sigma, // double moving_sigma, // blurring sigma for moving objects = 1.0;
clt_parameters.ly_max_mov_disparity, // double max_mov_disparity, // disparity limit for moving objects detection = 75.0;
clt_parameters.ly_rad_to_hdiag_mov, // double rad_to_hdiag_mov, // radius to half-diagonal ratio to remove high-distortion corners = 0.7 ; // 0.8
clt_parameters.ly_max_mov_average, // double max_mov_average, // do not attempt to detect moving objects if ERS is not accurate for terrain = .25;
clt_parameters.ly_mov_min_L2, // double mov_min_L2, // threshold for moving objects = 0.75;
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);// not used in lwir
}
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
dsxy, // double [][] measured_dsxy,
null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel)
// fix this.fine_corr
if (this.fine_corr.length != getNumSensors()) {
System.out.println ("**** this.fine_corr.length != getNumSensors(), fixing");
double [][][] fine_corr0 = this.fine_corr;
this.fine_corr = new double [getNumSensors()][2][6];
for (int i = 0; i < fine_corr0.length; i++) {
this.fine_corr[i] = fine_corr0[i];
}
if (debugLevel > -2){
System.out.println("Old extrinsic corrections:");
System.out.println(geometryCorrection.getCorrVector().toString());
}
if (corr_vector != null) {
CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
if (debugLevel > -2){
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // per-tile operation bit codes
disparity_array, // final double disparity,
image_data, // double_stacks, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_corr_partial, // [tp.tilesY][tp.tilesX][pair][color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_mismatch, // [12][tp.tilesY * tp.tilesX] // transpose unapplied. null - do not calculate
disparity_map, // [2][tp.tilesY * tp.tilesX]
texture_tiles, // [tp.tilesY][tp.tilesX]["RGBA".length()][];
imp_quad[0].getWidth(), // final int width,
clt_parameters.getFatZero(isMonochrome()), // add to denominator to modify phase correlation (same units as data1, data2). <0 - pure sum
clt_parameters.corr_sym,
clt_parameters.corr_offset,
clt_parameters.corr_red,
clt_parameters.corr_blue,
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
// clt_parameters.corr_mask,
clt_parameters.corr_normalize, // normalize correlation results by rms
min_corr_selected, // 0.0001; // minimal correlation value to consider valid
clt_parameters.max_corr_sigma,// 1.5; // weights of points around global max to find fractional
clt_parameters.max_corr_radius,
// clt_parameters.enhortho_width, // 2; // reduce weight of center correlation pixels from center (0 - none, 1 - center, 2 +/-1 from center)
// clt_parameters.enhortho_scale, // 0.2; // multiply center correlation pixels (inside enhortho_width)
clt_parameters.max_corr_double, // Double pass when masking center of mass to reduce preference for integer values
clt_parameters.corr_mode, // Correlation mode: 0 - integer max, 1 - center of mass, 2 - polynomial
clt_parameters.min_shot, // 10.0; // Do not adjust for shot noise if lower than
clt_parameters.scale_shot, // 3.0; // scale when dividing by sqrt ( <0 - disable correction)
clt_parameters.diff_sigma, // 5.0;//RMS difference from average to reduce weights (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_threshold, // 5.0; // RMS difference from average to discard channel (~ 1.0 - 1/255 full scale image)
clt_parameters.diff_gauss, // true; // when averaging images, use gaussian around average as weight (false - sharp all/nothing)
clt_parameters.min_agree, // 3.0; // minimal number of channels to agree on a point (real number to work with fuzzy averages)
clt_parameters.dust_remove, // Do not reduce average weight when only one image differes much from the average
clt_parameters.keep_weights, // Add port weights to RGBA stack (debug feature)
geometryCorrection, // final GeometryCorrection geometryCorrection,
null, // final GeometryCorrection geometryCorrection_main, // if not null correct this camera (aux) to the coordinates of the main
clt_kernels, // final double [][][][][][] clt_kernels, // [channel_in_quad][color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
clt_parameters.kernel_step,
/// image_dtt.transform_size,
clt_parameters.clt_window,
shiftXY, //
disparity_corr, // final double disparity_corr, // disparity at infinity
(clt_parameters.fcorr_ignore? null: this.fine_corr),
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)
clt_parameters.tileX, // -1234, // clt_parameters.tileX, // final int debug_tileX,
clt_parameters.tileY, // final int debug_tileY, -1234 will cause port coordinates debug images
(clt_parameters.dbg_mode & 64) != 0, // no fract shift
(clt_parameters.dbg_mode & 128) != 0, // no convolve
// (clt_parameters.dbg_mode & 256) != 0, // transpose convolve
threadsMax,
debugLevel);
int first_color = isMonochrome()? ImageDtt.MONO_CHN:0;
if (debugLevel > -1){
System.out.println("clt_data.length="+clt_data.length+" clt_data[0].length="+clt_data[0].length
+" clt_data[0]["+first_color+"].length="+clt_data[0][first_color].length+" clt_data[0]["+first_color+"][0].length="+
clt_data[0][first_color][0].length);
}
// visualize texture tiles as RGBA slices
double [][] texture_nonoverlap = null;
double [][] texture_overlap = null;
String [] rbga_titles = {"red","blue","green","alpha"};
String [] rbga_weights_titles = {"red","blue","green","alpha","port0","port1","port2","port3","r-rms","b-rms","g-rms","w-rms"};
// In monochrome mode only G is used ImageDtt.MONO_CHN(==2), others are null
if (texture_tiles != null){
if (clt_parameters.show_nonoverlap){// not used in lwir
texture_nonoverlap = image_dtt.combineRBGATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
/// image_dtt.transform_size,
false, // when false - output each tile as 16x16, true - overlap to make 8x8
clt_parameters.sharp_alpha, // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
threadsMax, // maximal number of threads to launch
debugLevel);
sdfa_instance.showArrays(
texture_nonoverlap,
tilesX * (2 * image_dtt.transform_size),
tilesY * (2 * image_dtt.transform_size),
true,
image_name+sAux() + "-TXTNOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rbga_weights_titles:rbga_titles));
}
if (!infinity_corr && (clt_parameters.show_overlap || clt_parameters.show_rgba_color)){
int alpha_index = 3;
texture_overlap = image_dtt.combineRBGATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
/// image_dtt.transform_size,
true, // when false - output each tile as 16x16, true - overlap to make 8x8
clt_parameters.sharp_alpha, // combining mode for alpha channel: false - treat as RGB, true - apply center 8x8 only
threadsMax, // maximal number of threads to launch
debugLevel);
if (clt_parameters.alpha1 > 0){ // negative or 0 - keep alpha as it was
double scale = (clt_parameters.alpha1 > clt_parameters.alpha0) ? (1.0/(clt_parameters.alpha1 - clt_parameters.alpha0)) : 0.0;
for (int i = 0; i < texture_overlap[alpha_index].length; i++){
double d = texture_overlap[alpha_index][i];
if (d >=clt_parameters.alpha1) d = 1.0;
else if (d <=clt_parameters.alpha0) d = 0.0;
else d = scale * (d- clt_parameters.alpha0);
texture_overlap[alpha_index][i] = d;
}
}
if (!batch_mode && clt_parameters.show_overlap) {// not used in lwir
sdfa_instance.showArrays( // all but r-rms, b-rms
texture_overlap,
tilesX * image_dtt.transform_size,
tilesY * image_dtt.transform_size,
true,
image_name+sAux() + "-TXTOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rbga_weights_titles:rbga_titles));
}
if (!batch_mode && clt_parameters.show_rgba_color) {// not used in lwir
// for now - use just RGB. Later add option for RGBA
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]};
double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]};
// ImagePlus img_texture =
linearStackToColor(
clt_parameters,
colorProcParameters,
rgbParameters,
image_name+sAux()+"-texture", // String name,
"-D"+clt_parameters.disparity, //String suffix, // such as disparity=...
toRGB,
!this.correctionsParameters.jpeg, // boolean bpp16, // 16-bit per channel color mode for result
true, // boolean saveShowIntermediate, // save/show if set globally
true, // boolean saveShowFinal, // save/show result (color image?)
((clt_parameters.alpha1 > 0)? texture_rgba: texture_rgb),
tilesX * image_dtt.transform_size,
tilesY * image_dtt.transform_size,
1.0, // double scaleExposure, // is it needed?
debugLevel );
}
}
}
/*
// visualize correlation results
// bo-b3 non-zero, r*, g* - zero
if (clt_corr_combo!=null){
if (disparity_map != null){
if (!batch_mode && clt_parameters.show_map && (debugLevel > -1)){
sdfa_instance.showArrays(
disparity_map,
tilesX,
tilesY,
true,
image_name+sAux()+"-DISP_MAP-D"+clt_parameters.disparity,
ImageDtt.DISPARITY_TITLES);
}
}
if (infinity_corr && (disparity_map != null)){// not used in lwir
System.out.println("=== applying geometry correction coefficients to correct disparity at infinity ===");
System.out.println("=== Set inf_repeat =0 to disable automatic correction and just generate a data image to correct in offline mode ===");
double [] mismatch_strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
int [] strength_indices = {2,5,8,11};
for (int nt = 0; nt < mismatch_strength.length; nt++) {
if (Double.isNaN(mismatch_strength[nt])) {
mismatch_strength[nt] = 0.0;
} else {
if (mismatch_strength[nt] > 0) {
for (int i = 0; i < strength_indices.length; i++) {
if (!(mismatch_strength[nt] < clt_mismatch[strength_indices[i]][nt])) {
mismatch_strength[nt] = clt_mismatch[strength_indices[i]][nt];
}
// if (nt == 37005) {
// System.out.println("breakpoint in processCLTQuadCorr()");
// }
}
}
}
}
double [][] inf_ds = { // when using with disparity, programmed disparity should be 0
disparity_map[ImageDtt.DISPARITY_INDEX_CM],
mismatch_strength}; // disparity_map[ ImageDtt.DISPARITY_STRENGTH_INDEX]};
String [] titles = {"disp_cm", "strength"};
if (!batch_mode && (clt_mismatch != null)){
double [][] inf_ds1 = {
disparity_map[ImageDtt.DISPARITY_INDEX_CM],
mismatch_strength, //disparity_map[ ImageDtt.DISPARITY_STRENGTH_INDEX],
clt_mismatch[0].clone(), // dx0
clt_mismatch[1].clone(), // dy0 +
clt_mismatch[3].clone(), // dx1
clt_mismatch[4].clone(), // dy1 +
clt_mismatch[6].clone(), // dx2 +
clt_mismatch[7].clone(), // dy2
clt_mismatch[9].clone(), // dx3 +
clt_mismatch[10].clone()};// dy3
// restore full d{xy}[i] with subtracted disparity - debugging (otherwise clone() above is not neded)
// Add disparity to dx0, dx1, dy2, dy3 pairs
if (clt_parameters.inf_restore_disp) {
if (debugLevel > -2) {
System.out.println("---- Adding disparity to d{xy}[i] ---");
}
for (int nTile = 0; nTile < inf_ds1[0].length; nTile++) if (inf_ds1[1][nTile] > 0){ // strength
for (int i = 0; i < AlignmentCorrection.INDICES_10_DISP.length; i++) {
inf_ds1[AlignmentCorrection.INDICES_10_DISP[i]][nTile] += inf_ds1[AlignmentCorrection.INDEX_10_DISPARITY][nTile];
}
}
} else {
if (debugLevel > -2) {
System.out.println("---- d{xy}[i] have disparity canceled, xy_mismatch will only reflect residual values---");
}
}
String [] titles1 = {"disp_cm", "strength", "dx0", "dy0", "dx1", "dy1", "dx2", "dy2", "dx3", "dy3"};
inf_ds = inf_ds1;
titles = titles1;
}
if (clt_parameters.inf_repeat < 1) {
System.out.println("=== Generating image to be saved and then used for correction with 'CLT ext infinity corr'===");
// This image can be saved and re-read with "CLT ext infinity corr" command
if (!batch_mode && (sdfa_instance != null)){
sdfa_instance.showArrays(
inf_ds,
tilesX,
tilesY,
true,
image_name+sAux() + "-inf_corr",
titles );
}
} else { // calculate/apply coefficients
if (debugLevel + (clt_parameters.fine_dbg ? 1:0) > 0){
// still show image, even as it is not needed
if (!batch_mode && (sdfa_instance != null)) {
sdfa_instance.showArrays(
inf_ds,
tilesX,
tilesY,
true,
image_name+sAux() + "-inf_corr",
titles );
}
}
AlignmentCorrection ac = new AlignmentCorrection(this);
// includes both infinity correction and mismatch correction for the same infinity tiles
double [][][] new_corr = ac.infinityCorrection(
clt_parameters.ly_poly, // final boolean use_poly,
clt_parameters.fcorr_inf_strength, // final double min_strenth,
clt_parameters.fcorr_inf_diff, // final double max_diff,
clt_parameters.inf_iters, // 20, // 0, // final int max_iterations,
clt_parameters.inf_final_diff, // 0.0001, // final double max_coeff_diff,
clt_parameters.inf_far_pull, // 0.0, // 0.25, // final double far_pull, // = 0.2; // 1; // 0.5;
clt_parameters.inf_str_pow, // 1.0, // final double strength_pow,
clt_parameters.inf_smpl_side, // 3, // final int smplSide, // = 2; // Sample size (side of a square)
clt_parameters.inf_smpl_num, // 5, // final int smplNum, // = 3; // Number after removing worst (should be >1)
clt_parameters.inf_smpl_rms, // 0.1, // 0.05, // final double smplRms, // = 0.1; // Maximal RMS of the remaining tiles in a sample
// histogram parameters
clt_parameters.ih_smpl_step, // 8, // final int hist_smpl_side, // 8 x8 masked, 16x16 sampled
clt_parameters.ih_disp_min, // -1.0, // final double hist_disp_min,
clt_parameters.ih_disp_step, // 0.05, // final double hist_disp_step,
clt_parameters.ih_num_bins, // 40, // final int hist_num_bins,
clt_parameters.ih_sigma, // 0.1, // final double hist_sigma,
clt_parameters.ih_max_diff, // 0.1, // final double hist_max_diff,
clt_parameters.ih_min_samples, // 10, // final int hist_min_samples,
clt_parameters.ih_norm_center, // true, // final boolean hist_norm_center, // if there are more tiles that fit than min_samples, replace with
clt_parameters, // EyesisCorrectionParameters.CLTParameters clt_parameters,
inf_ds, // double [][] disp_strength,
tilesX, // int tilesX,
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevel + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
if ((new_corr != null) && (debugLevel > -1)){
System.out.println("process_infinity_corr(): ready to apply infinity correction");
show_fine_corr(
new_corr, // double [][][] corr,
"");// String prefix)
}
if (clt_parameters.inf_disp_apply){
apply_fine_corr(
new_corr,
debugLevel + 2);
}
}
}
if (!batch_mode && !infinity_corr && clt_parameters.corr_show && (debugLevel > -1)){ // not used in lwir FALSE
double [][] corr_rslt = new double [clt_corr_combo.length][];
String [] titles = new String[clt_corr_combo.length]; // {"combo","sum"};
for (int i = 0; i< titles.length; i++) titles[i] = ImageDtt.TCORR_TITLES[i];
for (int i = 0; i<corr_rslt.length; i++) {
corr_rslt[i] = image_dtt.corr_dbg(
clt_corr_combo[i],
2*image_dtt.transform_size - 1,
clt_parameters.corr_border_contrast,
threadsMax,
debugLevel);
}
// all zeros
sdfa_instance.showArrays(
corr_rslt,
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
image_name+sAux()+"-CORR-D"+clt_parameters.disparity,
titles );
}
}
*/
// So far - keep clt_corr_partial, then replace clt_corr_debug
if (!batch_mode && !infinity_corr && (clt_corr_partial!=null)){ // not used in lwir FALSE
if (debugLevel > -1){ // -1
String [] allColorNames = {"red","blue","green","combo"};
String [] titles = new String[clt_corr_partial.length];
for (int i = 0; i < titles.length; i++){
titles[i]=allColorNames[i % allColorNames.length]+"_"+(i / allColorNames.length);
}
double [][] corr_rslt_partial = ImageDtt.corr_partial_dbg(
clt_corr_partial,
2*image_dtt.transform_size - 1, //final int corr_size,
4, // final int pairs,
4, // final int colors,
clt_parameters.corr_border_contrast,
threadsMax,
debugLevel);
// titles.length = 15, corr_rslt_partial.length=16!
System.out.println("corr_rslt_partial.length = "+corr_rslt_partial.length+", titles.length = "+titles.length);
sdfa_instance.showArrays( // out of boundary 15
corr_rslt_partial,
tilesX*(2*image_dtt.transform_size),
tilesY*(2*image_dtt.transform_size),
true,
image_name+sAux()+"-PART_CORR-D"+clt_parameters.disparity);
}
}
double [][][] iclt_data = new double [clt_data.length][][];
if (!infinity_corr && (clt_parameters.gen_chn_img || clt_parameters.gen_4_img || clt_parameters.gen_chn_stacks)) {
for (int iQuad = 0; iQuad < clt_data.length; iQuad++){
if (clt_parameters.getCorrSigma(image_dtt.isMonochrome()) > 0){ // no filter at all
for (int chn = 0; chn < clt_data[iQuad].length; chn++) if (clt_data[iQuad][chn] != null){
image_dtt.clt_lpf(
clt_parameters.getCorrSigma(image_dtt.isMonochrome()),
clt_data[iQuad][chn],
threadsMax,
debugLevel);
}
}
if (debugLevel > 0){
System.out.println("--tilesX="+tilesX);
System.out.println("--tilesY="+tilesY);
}
if (!batch_mode && (debugLevel > 0)){ // FALSE
double [][] clt = new double [clt_data[iQuad].length*4][];
for (int chn = 0; chn < clt_data[iQuad].length; chn++) if (clt_data[iQuad][chn] != null){
double [][] clt_set = image_dtt.clt_dbg(
clt_data [iQuad][chn],
threadsMax,
debugLevel);
for (int ii = 0; ii < clt_set.length; ii++) clt[chn*4+ii] = clt_set[ii];
}
if (debugLevel > 0){
sdfa_instance.showArrays(clt,
tilesX*image_dtt.transform_size,
tilesY*image_dtt.transform_size,
true,
results[iQuad].getTitle()+"-CLT-D"+clt_parameters.disparity);
}
}
iclt_data[iQuad] = new double [clt_data[iQuad].length][];
for (int ncol=0; ncol<iclt_data[iQuad].length;ncol++) if (clt_data[iQuad][ncol] != null) {
iclt_data[iQuad][ncol] = image_dtt.iclt_2d(
clt_data[iQuad][ncol], // scanline representation of dcd data, organized as dct_size x dct_size tiles
clt_parameters.clt_window, // window_type
15, // clt_parameters.iclt_mask, //which of 4 to transform back
0, // clt_parameters.dbg_mode, //which of 4 to transform back
threadsMax,
debugLevel);
}
if (clt_parameters.gen_chn_stacks) sdfa_instance.showArrays(
iclt_data[iQuad],
(tilesX + 0) * image_dtt.transform_size,
(tilesY + 0) * image_dtt.transform_size,
true,
results[iQuad].getTitle()+"-ICLT-RGB-D"+clt_parameters.disparity);
} // end of generating shifted channel images
// Use iclt_data here for LWIR autorange
if (colorProcParameters.isLwir() && colorProcParameters.lwir_autorange) {
double rel_low = colorProcParameters.lwir_low;
double rel_high = colorProcParameters.lwir_high;
if (!Double.isNaN(getLwirOffset())) {
rel_low -= getLwirOffset();
rel_high -= getLwirOffset();
}
double [] cold_hot = autorange(
iclt_data, // double [][][] iclt_data, // [iQuad][ncol][i] - normally only [][2][] is non-null
rel_low, // double hard_cold,// matches data, DC (this.lwir_offset) subtracted
rel_high, // double hard_hot, // matches data, DC (this.lwir_offset) subtracted
colorProcParameters.lwir_too_cold, // double too_cold, // pixels per image
colorProcParameters.lwir_too_hot, // double too_hot, // pixels per image
1024); // int num_bins)
if (cold_hot != null) {
if (!Double.isNaN(getLwirOffset())) {
cold_hot[0] += getLwirOffset();
cold_hot[1] += getLwirOffset();
}
}
setColdHot(cold_hot); // will be used for shifted images and for texture tiles
}
ImagePlus [] imps_RGB = new ImagePlus[clt_data.length]; // all 16 here
for (int iQuad = 0; iQuad < clt_data.length; iQuad++){
if (!clt_parameters.gen_chn_img) continue;
String title=String.format("%s%s-%02d",image_name, sAux(), iQuad);
imps_RGB[iQuad] = linearStackToColor(
clt_parameters,
colorProcParameters,
rgbParameters,
title, // String name,
"-D"+clt_parameters.disparity, //String suffix, // such as disparity=...
toRGB,
!this.correctionsParameters.jpeg, // boolean bpp16, // 16-bit per channel color mode for result
!batch_mode, // true, // boolean saveShowIntermediate, // save/show if set globally
false, // boolean saveShowFinal, // save/show result (color image?)
iclt_data[iQuad],
tilesX * image_dtt.transform_size,
tilesY * image_dtt.transform_size,
scaleExposures[iQuad], // double scaleExposure, // is it needed?
debugLevel );
}
if (clt_parameters.gen_chn_img) {
// combine to a sliced color image
int [] slice_seq = {0,1,3,2}; //clockwise
if (imps_RGB.length > 4) {
slice_seq = new int [imps_RGB.length];
for (int i = 0; i < slice_seq.length; i++) {
slice_seq[i] = i;
}
}
int width = imps_RGB[0].getWidth();
int height = imps_RGB[0].getHeight();
ImageStack array_stack=new ImageStack(width,height);
for (int i = 0; i<slice_seq.length; i++){
if (imps_RGB[slice_seq[i]] != null) {
array_stack.addSlice("port_"+slice_seq[i], imps_RGB[slice_seq[i]].getProcessor().getPixels());
} else { // not used in lwir
array_stack.addSlice("port_"+slice_seq[i], results[slice_seq[i]].getProcessor().getPixels());
}
}
ImagePlus imp_stack = new ImagePlus(image_name+sAux()+"-SHIFTED-D"+clt_parameters.disparity, array_stack);
imp_stack.getProcessor().resetMinAndMax();
if (!batch_mode) {
imp_stack.updateAndDraw(); // not used in lwir
}
//imp_stack.getProcessor().resetMinAndMax();
//imp_stack.show();
// eyesisCorrections.saveAndShow(imp_stack, this.correctionsParameters);
eyesisCorrections.saveAndShowEnable(
imp_stack, // ImagePlus imp,
this.correctionsParameters, // EyesisCorrectionParameters.CorrectionParameters correctionsParameters,
true, // boolean enableSave,
!batch_mode) ;// boolean enableShow);
}
if (clt_parameters.gen_4_img) {
// Save as individual JPEG images in the model directory
String x3d_path= correctionsParameters.selectX3dDirectory(
image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
correctionsParameters.x3dModelVersion,
true, // smart,
true); //newAllowed, // save
for (int sub_img = 0; sub_img < imps_RGB.length; sub_img++){
EyesisCorrections.saveAndShow(
imps_RGB[sub_img],
x3d_path,
correctionsParameters.png && !clt_parameters.black_back,
!batch_mode && clt_parameters.show_textures,
correctionsParameters.JPEG_quality, // jpegQuality); // jpegQuality){// <0 - keep current, 0 - force Tiff, >0 use for JPEG
(debugLevel > 0) ? debugLevel : 1); // int debugLevel (print what it saves)
}
String model_path= correctionsParameters.selectX3dDirectory(
image_name, // quad timestamp. Will be ignored if correctionsParameters.use_x3d_subdirs is false
null,
true, // smart,
true); //newAllowed, // save
createThumbNailImage(
imps_RGB[0],
model_path,
"thumb"+sAux(),
debugLevel);
}
}
return results;
}
public ImagePlus [] processCLTQuadCorrTestERS(
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
// int convolveFFTSize, // 128 - fft size, kernel size should be size/2
double [] scaleExposures, // probably not needed here
final boolean apply_corr, // calculate and apply additional fine geometry correction
final boolean infinity_corr, // calculate and apply geometry correction at infinity
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
int debugLevel){
if (debugLevel > -2) { // -1
debugLevel = clt_parameters.ly_debug_level;
}
String path= (String) imp_quad[0].getProperty("path");
ImagePlus [] results = new ImagePlus[imp_quad.length];
for (int i = 0; i < results.length; i++) {
results[i] = imp_quad[i];
results[i].setTitle(results[i].getTitle()+"RAW");
}
if (debugLevel>1) System.out.println("processing: "+path);
// 08/12/2020 Moved to condifuinImageSet - remove setTiles?
/*
setTiles (imp_quad[0], // set global tp.tilesX, tp.tilesY
clt_parameters,
threadsMax);
*/
final int tilesX=tp.getTilesX(); // imp_quad[0].getWidth()/clt_parameters.transform_size;
final int tilesY=tp.getTilesY(); // imp_quad[0].getHeight()/clt_parameters.transform_size;
final int clustersX= (tilesX + clt_parameters.tileStep - 1) / clt_parameters.tileStep;
final int clustersY= (tilesY + clt_parameters.tileStep - 1) / clt_parameters.tileStep;
double [][] dsxy = new double[clustersX * clustersY][];
ImagePlus imp_sel = WindowManager.getCurrentImage();
if ((imp_sel == null) || (imp_sel.getStackSize() != ExtrinsicAdjustment.INDX_LENGTH)) {
System.out.println("No image / wrong image selected, bailing out");
return null;
} else {
System.out.println("Image: "+imp_sel.getTitle());
int width = imp_sel.getWidth();
int height = imp_sel.getHeight();
if ((width != clustersX) || (height != clustersY)) {
System.out.println(String.format("Image size mismatch: width=%d (%d), height=%d(%d)",
width, clustersX, height, clustersY));
return null;
}
ImageStack stack_sel = imp_sel.getStack();
float [][] fpixels = new float [ExtrinsicAdjustment.INDX_LENGTH][];
for (int i = 0; i < fpixels.length; i++) {
fpixels[i] = (float[]) stack_sel.getPixels(i+1);
}
for (int tile = 0; tile < dsxy.length; tile ++) {
if (fpixels[1][tile] > 0.0) {
dsxy[tile] = new double[fpixels.length];
for (int i = 0; i < fpixels.length; i++) {
dsxy[tile][i] = fpixels[i][tile];
}
}
}
}
ExtrinsicAdjustment ea = new ExtrinsicAdjustment(
geometryCorrection, // GeometryCorrection gc,
clt_parameters.tileStep, // int clusterSize,
clustersX, // int clustersX,
clustersY); // int clustersY);
double [] old_new_rms = new double[2];
boolean apply_extrinsic = (clt_parameters.ly_corr_scale != 0.0);
double inf_min_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_min_narrow :clt_parameters.ly_inf_min_broad;
double inf_max_disparity = clt_parameters.ly_inf_force_fine? clt_parameters.ly_inf_max_narrow :clt_parameters.ly_inf_max_broad;
CorrVector corr_vector = ea.solveCorr (
clt_parameters.ly_marg_fract, // double marg_fract, // part of half-width, and half-height to reduce weights
clt_parameters.ly_inf_en, // boolean use_disparity, // adjust disparity-related extrinsics
// 1.0 - to skip filtering infinity
inf_min_disparity, // -0.5, // -1.0, //double inf_min_disparity, // minimal disparity for infinity
inf_max_disparity, // 0.05, // 1.0, // double inf_max_disparity, // minimal disparity for infinity
clt_parameters.ly_inf_min_broad, // inf_min_disp_abs, // minimal disparity for infinity (absolute)
clt_parameters.ly_inf_max_broad, // maximal disparity for infinity (absolute)
clt_parameters.ly_inf_tilt, // boolean en_infinity_tilt, // select infinity tiles form right/left tilted (false - from average)
clt_parameters.ly_right_left, // boolean infinity_right_left, // balance weights between right and left halves of infinity
clt_parameters.ly_aztilt_en, // boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
clt_parameters.ly_diff_roll_en,//boolean use_diff_rolls, // Adjust differential rolls (3 of 4 angles)
clt_parameters.ly_min_forced, // int min_num_forced, // minimal number of clusters with forced disparity to use it
// data, using just radial distortions
clt_parameters.ly_com_roll, //boolean common_roll, // Enable common roll (valid for high disparity range only)
clt_parameters.ly_focalLength, //boolean corr_focalLength, // Correct scales (focal length temperature? variations)
clt_parameters.ly_ers_rot, // boolean ers_rot, // Enable ERS correction of the camera rotation
clt_parameters.ly_ers_forw, // boolean ers_forw, // Enable ERS correction of the camera linear movement in z direction
clt_parameters.ly_ers_side, // boolean ers_side, // Enable ERS correction of the camera linear movement in x direction
clt_parameters.ly_ers_vert, // boolean ers_vert, // Enable ERS correction of the camera linear movement in y direction
// add balancing-related here?
clt_parameters.ly_par_sel, // int manual_par_sel, // Manually select the parameter mask bit 0 - sym0, bit1 - sym1, ... (0 - use boolean flags, != 0 - ignore boolean flags)
clt_parameters.ly_weight_infinity, //0.3, // double weight_infinity, // 0.3, total weight of infinity tiles fraction (0.0 - 1.0)
clt_parameters.ly_weight_disparity, //0.0, // double weight_disparity, // 0.0 disparity weight relative to the sum of 8 lazy eye values of the same tile
clt_parameters.ly_weight_disparity_inf,//0.5, // double weight_disparity_inf,// 0.5 disparity weight relative to the sum of 8 lazy eye values of the same tile for infinity
clt_parameters.ly_max_disparity_far, //5.0, // double max_disparity_far, // 5.0 reduce weights of near tiles proportional to sqrt(max_disparity_far/disparity)
clt_parameters.ly_max_disparity_use, //5.0, // double max_disparity_use, // 5.0 (default 1000)disable near objects completely - use to avoid ERS
clt_parameters.ly_inf_min_dfe, //1.75,// double min_dfe, // = 1.75;
clt_parameters.ly_inf_max_dfe, //5.0, // double max_dfe, // = 5.0; // <=0 - disable feature
// moving objects filtering
clt_parameters.ly_moving_en, // boolean moving_en, // enable filtering areas with potentially moving objects
clt_parameters.ly_moving_apply, // boolean moving_apply, // apply filtering areas with potentially moving objects
clt_parameters.ly_moving_sigma, // double moving_sigma, // blurring sigma for moving objects = 1.0;
clt_parameters.ly_max_mov_disparity, // double max_mov_disparity, // disparity limit for moving objects detection = 75.0;
clt_parameters.ly_rad_to_hdiag_mov, // double rad_to_hdiag_mov, // radius to half-diagonal ratio to remove high-distortion corners = 0.7 ; // 0.8
clt_parameters.ly_max_mov_average, // double max_mov_average, // do not attempt to detect moving objects if ERS is not accurate for terrain = .25;
clt_parameters.ly_mov_min_L2, // double mov_min_L2, // threshold for moving objects = 0.75;
dsxy, // double [][] measured_dsxy,
null, // boolean [] force_disparity, // boolean [] force_disparity,
false, // boolean use_main, // corr_rots_aux != null;
geometryCorrection.getCorrVector(), // CorrVector corr_vector,
old_new_rms, // double [] old_new_rms, // should be double[2]
debugLevel); // + 5);// int debugLevel)
if (debugLevel > -2){
System.out.println("Old extrinsic corrections:");
System.out.println(geometryCorrection.getCorrVector().toString());
}
if (corr_vector != null) {
CorrVector diff_corr = corr_vector.diffFromVector(geometryCorrection.getCorrVector());
if (debugLevel > -2){
System.out.println("New extrinsic corrections:");
System.out.println(corr_vector.toString());
......@@ -5426,7 +6065,9 @@ public class QuadCLTCPU {
threadsMax);
*/
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -6386,6 +7027,7 @@ public class QuadCLTCPU {
gpuResetCorrVector();
}
/*
public void cltDisparityScans( // not used in lwir
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
......@@ -6545,8 +7187,6 @@ public class QuadCLTCPU {
pixels[i]*=d;
}
// Scale here, combine with vignetting later?
/// int width = imp_srcs[srcChannel].getWidth();
/// int height = imp_srcs[srcChannel].getHeight();
for (int y = 0; y < height-1; y+=2){
for (int x = 0; x < width-1; x+=2){
pixels[y*width+x ] *= clt_parameters.scale_g;
......@@ -6559,9 +7199,6 @@ public class QuadCLTCPU {
} else { // assuming GR/BG pattern
System.out.println("Applying fixed color gain correction parameters: Gr="+
clt_parameters.novignetting_r+", Gg="+clt_parameters.novignetting_g+", Gb="+clt_parameters.novignetting_b);
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
/// int width = imp_srcs[srcChannel].getWidth();
/// int height = imp_srcs[srcChannel].getHeight();
double kr = clt_parameters.scale_r/clt_parameters.novignetting_r;
double kg = clt_parameters.scale_g/clt_parameters.novignetting_g;
double kb = clt_parameters.scale_b/clt_parameters.novignetting_b;
......@@ -6622,18 +7259,16 @@ public class QuadCLTCPU {
System.out.println("cltDisparityScans(): processing "+fileIndices.length+" files finished at "+
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
}
*/
public ImagePlus [] cltDisparityScan( // not used in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters,
// EyesisCorrectionParameters.NonlinParameters nonlinParameters,
ColorProcParameters colorProcParameters,
CorrectionColorProc.ColorGainsParameters channelGainParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters,
// int convolveFFTSize, // 128 - fft size, kernel size should be size/2
double [] scaleExposures, // probably not needed here
final int threadsMax, // maximal number of threads to launch
final boolean updateStatus,
......@@ -6660,7 +7295,9 @@ public class QuadCLTCPU {
}
// =================
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -6683,9 +7320,7 @@ public class QuadCLTCPU {
//TODO: Add array of default disparity - use for combining images in force disparity mode (no correlation), when disparity is predicted from other tiles
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
double min_corr_selected = clt_parameters.min_corr;
double [][][] disparity_maps = new double [clt_parameters.disp_scan_count][ImageDtt.DISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging)
double [][][] clt_mismatches = new double [clt_parameters.disp_scan_count][12][];
for (int scan_step = 0; scan_step < clt_parameters.disp_scan_count; scan_step++) {
......@@ -6702,7 +7337,6 @@ public class QuadCLTCPU {
shiftXY = shiftXY0;
}
// final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction);
double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){
z_correction +=clt_parameters.z_corr_map.get(image_name);
......@@ -6717,7 +7351,7 @@ public class QuadCLTCPU {
double_stacks, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_mismatches[scan_step], // null, [12][tilesY * tilesX] // transpose unapplied. null - do not calculate
......@@ -6879,6 +7513,7 @@ public class QuadCLTCPU {
}
}
}
int [] disp_indices = {
ImageDtt.DISPARITY_INDEX_INT,
ImageDtt.DISPARITY_INDEX_CM,
......@@ -9141,40 +9776,6 @@ public class QuadCLTCPU {
int max_tries = clt_parameters.lym_iter; // 25;
double min_sym_update = clt_parameters.getLymChange(is_aux); // 4e-6; // stop iterations if no angle changes more than this
double min_poly_update = clt_parameters.lym_poly_change; // Parameter vector difference to exit from polynomial correction
/*
if ((twoQuadCLT == null) || (twoQuadCLT.getBiScan(0) == null)){
System.out.println("Rig data is not available, aborting");
return false;
}
BiScan scan = twoQuadCLT.getBiScan(0);
double [][] rig_disp_strength = scan.getDisparityStrength(
true, // final boolean only_strong,
true, // final boolean only_trusted,
true) ; // final boolean only_enabled);
if (debugLevel > 20) {
boolean tmp_exit = true;
System.out.println("extrinsicsCLTfromGT()");
if (tmp_exit) {
System.out.println("will now exit. To continue - change variable tmp_exit in debugger" );
if (tmp_exit) {
return false;
}
}
}
GeometryCorrection geometryCorrection_main = null;
if (geometryCorrection.getRotMatrix(true) != null) {
geometryCorrection_main = twoQuadCLT.quadCLT_main.getGeometryCorrection();
double disparityScale = geometryCorrection.getDisparityRadius()/geometryCorrection_main.getDisparityRadius();
for (int i = 0; i < rig_disp_strength[0].length; i++) {
rig_disp_strength[0][i] *= disparityScale;
}
if (debugLevel > -2) {
System.out.println("This is an AUX camera, using MAIN camera coordinates");
}
}
*/
if (debugLevel > 20) {
boolean tmp_exit = true;
System.out.println("extrinsicsCLTfromGT()");
......@@ -10602,7 +11203,9 @@ public class QuadCLTCPU {
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -10716,7 +11319,9 @@ public class QuadCLTCPU {
return null;
}
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -10974,7 +11579,7 @@ public class QuadCLTCPU {
int [][] tile_op = tp.setSameTileOp(clt_parameters, d, debugLevel);
double [][] disparity_array = tp.setSameDisparity(0.0); // [tp.tilesY][tp.tilesX] - individual per-tile expected disparity
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
// double [][][][] clt_corr_combo = new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
double min_corr_selected = clt_parameters.min_corr; // 0.02
......@@ -10992,7 +11597,9 @@ public class QuadCLTCPU {
double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -11004,7 +11611,7 @@ public class QuadCLTCPU {
double [][][][][] clt_corr_partial = null;
if (clt_parameters.img_dtt.gpu_mode_debug) {
clt_corr_combo = null;
// clt_corr_combo = null;
clt_corr_partial = new double [tilesY][tilesX][][][];
for (int i = 0; i < tilesY; i++){
for (int j = 0; j < tilesX; j++){
......@@ -11012,7 +11619,7 @@ public class QuadCLTCPU {
}
}
}
clt_corr_combo = null; // Something is broke in old code, tries to use color==3 ==colors.weights.length
// clt_corr_combo = null; // Something is broke in old code, tries to use color==3 ==colors.weights.length
image_dtt.clt_aberrations_quad_corr(
clt_parameters.img_dtt, // final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
1, // final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
......@@ -11021,8 +11628,8 @@ public class QuadCLTCPU {
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
clt_corr_partial, // null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
disparity_map, // [12][tp.tilesY * tp.tilesX]
......@@ -11082,7 +11689,7 @@ public class QuadCLTCPU {
for (int i = 0; i < titles.length; i++){
titles[i]=allColorNames[i % allColorNames.length]+"_"+(i / allColorNames.length);
}
double [][] corr_rslt_partial = image_dtt.corr_partial_dbg(
double [][] corr_rslt_partial = ImageDtt.corr_partial_dbg(
clt_corr_partial,
2*image_dtt.transform_size - 1, //final int corr_size,
4, // final int pairs,
......@@ -11200,7 +11807,7 @@ public class QuadCLTCPU {
}
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = null; // new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
// double [][][][] clt_corr_combo = null; // new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
// broken clt_aberrations_quad_corr_new
if (debugLevel > -1){
int numTiles = 0;
......@@ -11228,7 +11835,9 @@ public class QuadCLTCPU {
double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -11245,7 +11854,7 @@ public class QuadCLTCPU {
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
mismatch, // null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
......@@ -11337,7 +11946,7 @@ public class QuadCLTCPU {
int [][] tile_op = scan.tile_op;
double [][] disparity_array = scan.disparity;
// undecided, so 2 modes of combining alpha - same as rgb, or use center tile only
double [][][][] clt_corr_combo = null; // new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
// double [][][][] clt_corr_combo = null; // new double [ImageDtt.TCORR_TITLES.length][tilesY][tilesX][]; // will only be used inside?
if (debugLevel > -1){
int numTiles = 0;
for (int ty = 0; ty < tile_op.length; ty ++) for (int tx = 0; tx < tile_op[ty].length; tx ++){
......@@ -11362,7 +11971,9 @@ public class QuadCLTCPU {
double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......@@ -11380,7 +11991,7 @@ public class QuadCLTCPU {
image_data, // final double [][][] imade_data, // first index - number of image in a quad
saturation_imp, // boolean [][] saturation_imp, // (near) saturated pixels or null
// correlation results - final and partial
clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_combo, // [tp.tilesY][tp.tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
null, // clt_corr_partial, // [tp.tilesY][tp.tilesX][quad]color][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
mismatch, // null, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
// Use it with disparity_maps[scan_step]? clt_mismatch, // [tp.tilesY][tp.tilesX][pair]{dx,dy,weight}[(2*transform_size-1)*(2*transform_size-1)] // transpose unapplied. null - do not calculate
......@@ -11536,7 +12147,9 @@ public class QuadCLTCPU {
}
ImageDtt image_dtt = new ImageDtt(
getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(isAux()));
......
......@@ -6217,7 +6217,9 @@ ImageDtt.startAndJoin(threads);
double [][][][] texture_tiles = scan_prev.getTextureTiles(); // each is null, manually set texture_tiles - null
ImageDtt image_dtt = new ImageDtt(
geometryCorrection.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
isMonochrome(),
isLwir(),
clt_parameters.getScaleStrength(is_aux));
......
......@@ -655,7 +655,9 @@ public class TwoQuadCLT {
double [][] disparity_bimap = new double [ImageDtt.BIDISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_main.isMonochrome(),
quadCLT_main.isLwir(),
clt_parameters.getScaleStrength(false));
......@@ -1380,7 +1382,9 @@ public class TwoQuadCLT {
}
double [][] disparity_bimap = new double [ImageDtt.BIDISPARITY_TITLES.length][]; //[0] -residual disparity, [1] - orthogonal (just for debugging) last 4 - max pixel differences
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_main.isMonochrome(),
quadCLT_main.isLwir(),
clt_parameters.getScaleStrength(false));
......@@ -2183,7 +2187,9 @@ public class TwoQuadCLT {
}
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_main.isMonochrome(),
quadCLT_main.isLwir(),
clt_parameters.getScaleStrength(false));
......@@ -3090,7 +3096,9 @@ if (debugLevel > -100) return true; // temporarily !
}
}
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_main.isMonochrome(),
quadCLT_main.isLwir(),
clt_parameters.getScaleStrength(false));
......@@ -3270,6 +3278,7 @@ if (debugLevel > -100) return true; // temporarily !
true, // smart,
true); //newAllowed, // save
Correlation2d corr2d = new Correlation2d(
quadCLT_main.getNumSensors(),
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
clt_parameters.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -3491,6 +3500,7 @@ if (debugLevel > -100) return true; // temporarily !
true, // smart,
true); //newAllowed, // save
Correlation2d corr2d = new Correlation2d(
quadCLT_main.getNumSensors(),
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
clt_parameters.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -7171,7 +7181,9 @@ if (debugLevel > -100) return true; // temporarily !
final boolean updateStatus,
final int debugLevel){
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_main.isMonochrome(),
quadCLT_main.isLwir(),
clt_parameters.getScaleStrength(false));
......@@ -7265,6 +7277,7 @@ if (debugLevel > -100) return true; // temporarily !
}
Random rnd = new Random(System.nanoTime());
Correlation2d corr2d = new Correlation2d(
quadCLT_main.getNumSensors(),
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
clt_parameters.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -7340,7 +7353,9 @@ if (debugLevel > -100) return true; // temporarily !
final boolean updateStatus,
final int debugLevel){
ImageDtt image_dtt = new ImageDtt(
quadCLT_main.getNumSensors(),
clt_parameters.transform_size,
clt_parameters.img_dtt,
quadCLT_aux.isMonochrome(),
quadCLT_aux.isLwir(),
clt_parameters.getScaleStrength(true));
......@@ -7404,6 +7419,7 @@ if (debugLevel > -100) return true; // temporarily !
int [][] tile_op = new int[tilesY][tilesX]; // common for both main and aux
double [][] disparity_array = new double[tilesY][tilesX];
Correlation2d corr2d = new Correlation2d(
quadCLT_main.getNumSensors(),
clt_parameters.img_dtt, // ImageDttParameters imgdtt_params,
clt_parameters.transform_size, // int transform_size,
2.0, // double wndx_scale, // (wndy scale is always 1.0)
......@@ -8262,6 +8278,7 @@ if (debugLevel > -100) return true; // temporarily !
/// double k_prev = 0.75;
/// double corr_scale = 0.75;
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
......@@ -8340,6 +8357,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
......@@ -8449,6 +8467,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
......@@ -8537,6 +8556,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
......@@ -8593,6 +8613,7 @@ if (debugLevel > -100) return true; // temporarily !
debugLevel); // int debugLevel)
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
......@@ -8743,6 +8764,7 @@ if (debugLevel > -100) return true; // temporarily !
OpticalFlow opticalFlow = new OpticalFlow(
quadCLT_main.getNumSensors(),
threadsMax, // int threadsMax, // maximal number of threads to launch
updateStatus); // boolean updateStatus);
if (bayer_artifacts_debug) {
......
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