Commit c14405c9 authored by Andrey Filippov's avatar Andrey Filippov

Working on new LMA correlation

parent 2fab35c1
package com.elphel.imagej.tileprocessor;
/**
**
** Corr2dLMA - Fit multi - baseline correlation pairs to the model
**
** Copyright (C) 2018 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** Corr2dLMA.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
/*
* Fitting parabola for multiple grids
* Difference between ortho and diagonals - just point coordinates and extra overall scale (weight account for number averaged)
* Each group of compatible is already averaged, so each group has a single individual variable - scale.
*
* Parabolas (1 for each group) are Ag * (1 - ((x-x0)/Wx) ^ 2 - (y/Wy)^2), where As is a per-group scale
* Wy = Wm * scale +Wyd
* Wx = Wm * scale +Wyd + Wxy
*
* Wm is a correlation measurement parameter, it does not depend on x/y and on particular pair, it depends on the LPF, so the
* total contribution is proportional to the baseline reduction (scale)
*
* Wyd is widening caused the image itself - probably noise and other factors of poor correlation contrast. When multiple
* orthogonal directions are combined it influences equally all directions (x,y) so Wx includes that term also
*
* Wxy widens maximum in disparity direction, it is caused by multiple overlapping maximums for different disparities and for
* strong enough matches can indicate mix of disparities in the same tile
*
* Fitting of a single scale groups (1 or 2) has to have Wm constant.
*
*
Each camera has the same scale and aligned parallel to all others
Each camera has a 2x2 matrix where d_disp - increment along disparity, d_ndisp - along rotated disparity:
Mi= | dx/d_disp , dx/d_ndisp|
| dy/d_disp , dy_d_ndisp|
For each pair matrices are subtracted (6 for 4 cameras)
Each correlation pair has the same shape, just shifted (add mask WXY that fades?)
ndisp - array of 4 values or all 0
disp - array of 4 symmetrized values, where the first is common disparity, 3 other may be forced to 0
A0 - common gain, A(i>0) = A0*Ai
W(x,y) window function for 2D correlation
x0j, y0j - individual for each pair, calculated from disp_i, ndisp_i, and Mi1-Mi2 (i1 - first channel in pair, i2 - second)
Fx=A(i)*W(x,y)*(pa*(x-x0j)^2+2*pb*(x-x0j)*(y-y0j)+pc*(y-y0j)^2)
*
*/
import java.util.ArrayList;
import java.util.HashMap;
import com.elphel.imagej.common.PolynomialApproximation;
import Jama.Matrix;
public class Corr2dLMA {
final static int NUM_CAMS = 4; // not all have to be used, so it is maximal number of cameras
final static int NUM_PAIRS = NUM_CAMS* (NUM_CAMS -1)/2; // number of possible pairs
final static int DISP_INDEX = 0; // common/average disparity
final static int A_INDEX = 1; // A*(x-x0)^2
final static int B_INDEX = 2; // 2*B*(x-x0)*(y-y0)
final static int CMA_INDEX = 3; // C*(y-y0)^2, encode C-A
final static int G0_INDEX = 4; // scale of correlation pair,
final static int DDISP_INDEX = G0_INDEX + NUM_PAIRS; // disparity offset per camera (at least 1 should be disabled)
final static int NDISP_INDEX = DDISP_INDEX + NUM_CAMS; // disparity offset per camera - none should be disable
final static int NUM_ALL_PARS = NDISP_INDEX+ NUM_CAMS; // maximal number of parameters
final int [] USED_CAMS_MAP = new int[NUM_CAMS]; // for each camera index return used index ???
final int [][] USED_PAIRS_MAP = new int[NUM_CAMS][NUM_CAMS]; // for each camera index return used index ??
@Deprecated
final static int X0_INDEX = 0;
@Deprecated
final static int WM_INDEX = 1; // may be frozen
@Deprecated
final static int WYD_INDEX = 2;
@Deprecated
final static int WXY_INDEX = 3;
@Deprecated
final static int AG_INDEX = 4; // and above
@Deprecated
final static String [] PAR_NAMES_OLD = {"X0","HALF-WIDTH","WIDTH-EXTRA","WIDTH_X/Y","AMPLITUDE"};
final static String [] PAR_NAMES = {"DISP","A","B","C-A"};
final static String PAR_NAME_SCALE = "SCALE";
final static String PAR_NAME_CORRDISP = "CORR-DISP";
final static String PAR_NAME_CORRNDISP = "CORR-NDISP";
double [] all_pars;
boolean [] par_mask;
double [] vector;
double [] scales = {1.0, 2.0, 4.0};
ArrayList<Sample> samples = new ArrayList<Sample>();
@Deprecated
HashMap<Integer,NumDiag> groups = new HashMap<Integer,NumDiag>();
@Deprecated
double [] group_weights = null; // per-group weights of samples sum == 1.0
double [] pair_weights = null; // per pair weights (sum == 1.0)
double [] weights; // normalized so sum is 1.0 for all - samples and extra regularization terms
double pure_weight; // weight of samples only
double [] values;
// next values are only updated after success
double [] last_rms = null; // {rms, rms_pure}, matching this.vector
double [] good_or_bad_rms = null; // just for diagnostics, to read last (failed) rms
double [] initial_rms = null; // {rms, rms_pure}, first-calcualted rms
double [] last_ymfx = null;
double [][] last_jt = null;
@Deprecated
boolean input_diag = false; // valid during adding samples, should be set before changing groups
double [] poly_coeff = null; // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
double [] poly_xyvwh = null; // result of 2-d polynomial approximation instead of the LMA - used for lazy eye correction
private final int transform_size;
private final double [][] corr_wnd;
private boolean [] used_cameras;
private final Matrix [] m_disp = new Matrix[NUM_CAMS];
private int last_cam; // index of the last camera (special treatment for disparity correction)
private boolean second_last; // there is a pair where the second camera is the last one (false: first in a pair is the last one)
private final Matrix [][] m_pairs = new Matrix[NUM_CAMS][NUM_CAMS];
private final Matrix [][] m_pairs_last = new Matrix[NUM_CAMS][NUM_CAMS];
private final int [][] pindx = new int [NUM_CAMS][NUM_CAMS];
@Deprecated
public class NumDiag{ // USED in lwir
int num;
boolean diag;
public NumDiag(int num, boolean diag) {
this.num = num;
this.diag = diag;
}
}
public class Sample{ // USED in lwir
int fcam; // first camera index
int scam; // second camera index
int ix; // x coordinate in 2D correlation (0.. 2*transform_size-2, center: (transform_size-1)
int iy; // y coordinate in 2D correlation (0.. 2*transform_size-2, center: (transform_size-1)
@Deprecated
double x; // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
@Deprecated
double y; // y coordinate (0 - disparity axis)
double v; // correlation value at that point
double w; // weight
@Deprecated
int si; // baseline scale index //
@Deprecated
int gi; // group index
@Deprecated
Sample (
double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double y, // y coordinate (0 - disparity axis)
double v, // correlation value at that point
double w,
int si, // baseline scale index
int gi) // baseline scale index
{
this.x = x;
this.y = y;
this.v = v;
this.w = w;
this.si = si;
this.gi = gi;
}
Sample (
int fcam, // first camera index
int scam, // second camera index
int x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
int y, // coordinate in 2D correlation (0.. 2*transform_size-2, center: (transform_size-1)
double v, // correlation value at that point
double w)
{
this.fcam = fcam;
this.scam = scam;
this.ix = x;
this.iy = y;
this.v = v;
this.w = w;
}
}
public Corr2dLMA (
int ts // null - use default table
) {
boolean sq = false;
this.transform_size = ts;
this.corr_wnd = new double[2 * transform_size - 1][2 * transform_size - 1];
int tsm1 = transform_size - 1; // 7
int dtsm1 = 2 * transform_size - 1; // 15
this.corr_wnd[tsm1][tsm1] = 1.0;
for (int i = 1; i < transform_size; i++) {
this.corr_wnd[tsm1 + i][tsm1 ] = Math.acos(Math.PI*i/(2 * transform_size));
this.corr_wnd[tsm1 - i][tsm1 ] = Math.acos(Math.PI*i/(2 * transform_size));
this.corr_wnd[tsm1 ][tsm1 + i] = Math.acos(Math.PI*i/(2 * transform_size));
this.corr_wnd[tsm1 ][tsm1 - i] = Math.acos(Math.PI*i/(2 * transform_size));
}
for (int i = 1; i < transform_size; i++) {
for (int j = 1; j < transform_size; j++) {
double d = this.corr_wnd[tsm1 + i][tsm1] * this.corr_wnd[tsm1 + j][tsm1];
this.corr_wnd[tsm1 + i][tsm1 + j] = d;
this.corr_wnd[tsm1 + i][tsm1 - j] = d;
this.corr_wnd[tsm1 - i][tsm1 + j] = d;
this.corr_wnd[tsm1 - i][tsm1 - j] = d;
}
}
if (sq) {
for (int i = 0; i < dtsm1; i++) {
for (int j = 0; j < dtsm1; j++) {
this.corr_wnd[i][j] *=this.corr_wnd[i][j];
}
}
}
}
public void addSample( // x = 0, y=0 - center
int fcam, // first camera index
int scam, // second camera index
int x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
int y, // y coordinate (0 - disparity axis)
double v, // correlation value at that point
double w){ // sample weight
if ((w > 0) && !Double.isNaN(v)) samples.add(new Sample(fcam,scam,x,y,v,w));
}
public int getPairIndex(int f, int s) {
if (f > s) {
int t = f;
f = s;
s = t;
}
return (NUM_CAMS * f) - (f + 1)*f/2 - f - 1 + s ; // return n*i - i*(i+1)//2 - i + j -1
}
public void setMatrices(double [][] am_disp) {
for (int n = 0; n < NUM_CAMS; n++) {
double [][] am = {
{am_disp[n][0],am_disp[n][1]},
{am_disp[n][2],am_disp[n][3]}};
m_disp[n] = new Matrix(am);
}
}
public void initVector( // USED in lwir
boolean adjust_width, // adjust width of the maximum
boolean adjust_scales, // adjust 2D correlation scales
boolean adjust_ellipse, // allow non-circular correlation maximums
boolean adjust_lazyeye, // adjust disparity corrections and orthogonal disparities
double disp0, // initial value of disparity
double half_width, // A=1/(half_widh)^2
double cost_lazyeye // cost for each of the non-zero disparity corrections and ortho disparity
) {
// int [][] pindx = new int [NUM_CAMS][NUM_CAMS];
for (int f = 0; f < NUM_CAMS; f++) {
pindx[f][f]=-1;
for (int s = f+1; s < NUM_CAMS; s++) {
pindx[f][s] = getPairIndex(f,s);
pindx[s][f] = pindx[f][s];
}
}
used_cameras = new boolean[NUM_CAMS];
boolean [] used_pairs = new boolean[NUM_PAIRS];
// 0-weight values and NaN-s should be filtered on input!
last_cam = -1;
for (int f = 0; f < NUM_CAMS; f++) for (int s = 0; s < NUM_CAMS; s++) USED_PAIRS_MAP[f][s] = -1;
boolean [][] used_pairs_dir = new boolean [NUM_CAMS][NUM_CAMS];
for (Sample s:samples) { // ignore zero-weight samples
used_cameras[s.fcam]=true;
used_cameras[s.scam]=true;
if (s.fcam > last_cam) {
second_last = false;
last_cam = s.fcam;
}
if (s.scam > last_cam) {
second_last = true;
last_cam = s.scam;
}
used_pairs[pindx[s.fcam][s.scam]]=true; // throws < 0 - wrong pair, f==s
used_pairs_dir[s.fcam][s.scam] = true;
}
int ncam = 0, npairs=0;
for (int i = 0; i < NUM_CAMS; i++) {
USED_CAMS_MAP[i] = ncam;
if (used_cameras[i]) {
last_cam = ncam;
ncam++;
}
}
int [] upmam = new int[NUM_PAIRS];
for (int i = 0; i < NUM_PAIRS; i++) {
upmam[i] = npairs;
if (used_pairs[i]) npairs++;
}
for (int f = 0; f < NUM_CAMS; f++) {
// USED_PAIRS_MAP[f][f] = -1;
for (int s = f+1; s < NUM_CAMS; s++) {
int npair = upmam[pindx[f][s]];
if (used_pairs_dir[f][s]) USED_PAIRS_MAP[f][s] = npair; // either or, can not be f,s and s,f pairs
else if (used_pairs_dir[s][f]) USED_PAIRS_MAP[s][f] = npair;
}
}
this.all_pars = new double[NUM_ALL_PARS];
this.all_pars[DISP_INDEX] = disp0;
this.all_pars[A_INDEX] = 1.0/(half_width * half_width);
this.all_pars[B_INDEX] = 0.0;
this.all_pars[CMA_INDEX] = 0.0; // C-A
this.par_mask = new boolean[NUM_ALL_PARS];
this.par_mask[DISP_INDEX] = true;
this.par_mask[A_INDEX] = adjust_width;
this.par_mask[B_INDEX] = adjust_ellipse;
this.par_mask[CMA_INDEX] = adjust_ellipse;
for (int i = 0; i <NUM_PAIRS; i++) {
this.par_mask[G0_INDEX + i] = used_pairs[i] & adjust_scales;
this.all_pars[G0_INDEX + i] = Double.NaN; // will be assigned later for used
}
for (int i = 0; i <NUM_CAMS; i++) {
this.all_pars[DDISP_INDEX + i] = 0.0; // C-A
this.par_mask[DDISP_INDEX + i] = used_cameras[i] & adjust_lazyeye & (i != last_cam);
this.all_pars[NDISP_INDEX + i] = 0.0; // C-A
this.par_mask[NDISP_INDEX + i] = used_cameras[i] & adjust_lazyeye;
}
int np = samples.size();
weights = new double [np + 2 * NUM_CAMS]; // npairs];
values = new double [np + 2 * NUM_CAMS]; // npairs];
for (int i = 0; i < NUM_CAMS; i++) {
weights[np + 2 * i + 0] = (used_cameras[i] & adjust_lazyeye)? cost_lazyeye : 0.0; // ddisp
weights[np + 2 * i + 1] = (used_cameras[i] & adjust_lazyeye)? cost_lazyeye : 0.0; // ndisp
values [np + 2 * i + 0] = 0.0;
values [np + 2 * i + 1] = 0.0;
}
double sw = 0;
this.pair_weights = new double[NUM_PAIRS];
for (int i = 0; i < np; i++) {
Sample s = samples.get(i);
weights[i] = s.w;
values[i] = s.v;
sw += weights[i];
int indx = pindx[s.fcam][s.scam];
pair_weights[indx] += s.w;
indx += G0_INDEX;
double d = s.v;
if (this.corr_wnd !=null) {
d /= this.corr_wnd[s.iy][s.ix];
}
if (d > this.all_pars[indx]) this.all_pars[indx] = d;
}
pure_weight = sw;
for (int i = 0; i < 2 * NUM_CAMS; i++) {
sw += weights[np + i];
}
if (sw != 0.0) {
double kw = 1.0/sw;
for (int i = 0; i < weights.length; i++) weights[i] *= kw;
pure_weight *= kw; // it is now fraction (0..1.0), and weigts are normalized
}
double spw = 0;
for (int i = 0; i < NUM_PAIRS; i++) {
spw += pair_weights[i];
}
if (spw > 0) {
double rspw = 1.0/spw;
for (int i = 0; i < NUM_PAIRS; i++) {
pair_weights[i]*=rspw;
}
}
toVector();
}
public void initMatrices() { // should be called after initVector and after setMatrices
// private final Matrix [][] m_pairs = new Matrix[NUM_CAMS][NUM_CAMS];
// private final Matrix [][] m_pairs_last = new Matrix[NUM_CAMS][NUM_CAMS];
for (int f = 0; f < NUM_CAMS; f++) for (int s = 0; s < NUM_CAMS; s++) {
m_pairs[f][s] = null;
m_pairs_last[f][s] = null;
if (USED_PAIRS_MAP[f][s] >= 0) {
m_pairs[f][s] = m_disp[f].minus(m_disp[s]);
}
if (f == last_cam) {
m_pairs_last[f][s] = m_disp[s].uminus();
for (int i = 0; i < NUM_CAMS; i++) if (used_cameras[i] && (i != last_cam) ){
m_pairs_last[f][s].minusEquals(m_disp[i]);
}
} else if (s == last_cam) {
m_pairs_last[f][s] = m_disp[f].copy();
for (int i = 0; i < NUM_CAMS; i++) if (used_cameras[i] && (i != last_cam) ){
m_pairs_last[f][s].plusEquals(m_disp[i]);
}
}
}
}
public double [] getFxJtNew( // USED in lwir
double [] vector,
double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
if (vector == null) return null;
double [] av = fromVector(vector);
// restore ddisp("x") offset for the last camera
// prepare parameters common for each camera/camera pair before calculating fx and derivatives
av[DDISP_INDEX + last_cam] = 0.0;
for (int i = 0; i < NUM_CAMS; i++) {
if (used_cameras[i] & (i != last_cam)) {
av[DDISP_INDEX + last_cam] -= av[DDISP_INDEX + i];
}
}
Matrix [] xcam_ycam = new Matrix[NUM_CAMS];
for (int i = 0; i < NUM_CAMS; i++) if (used_cameras[i]) {
double [] add_dnd = {av[DISP_INDEX]+ av[DDISP_INDEX + i], av[NDISP_INDEX + i]};
xcam_ycam[i] = m_disp[i].arrayTimes(new Matrix(add_dnd,2));
}
double [][][] xp_yp = new double[NUM_CAMS][NUM_CAMS][];
double [] axc_yc = {transform_size - 1.0, transform_size-1.0};
Matrix xc_yc = new Matrix(axc_yc, 2);
for (int f = 0; f < NUM_CAMS; f++) if (used_cameras[f]) {
for (int s = 0; s < NUM_CAMS; s++) if (used_cameras[s]) {
xp_yp[f][s] =xcam_ycam[f].minus(xcam_ycam[s]).plus(xc_yc).getColumnPackedCopy();
}
}
//USED_PAIRS_MAP
int num_samples = samples.size();
double [] fx= new double [num_samples + 2 * NUM_CAMS];
double sqrt2 = Math.sqrt(2.0);
double A = av[A_INDEX];
double B = av[B_INDEX];
double C = A + av[CMA_INDEX];
//corr_wnd
for (int ns = 0; ns < num_samples; ns++) {
Sample s = samples.get(ns);
int pair = pindx[s.fcam][s.scam];
double Gp = av[G0_INDEX + pair];
double Wp = corr_wnd[s.fcam][s.scam];
double WGp = Wp * Gp;
double xmxp = s.ix - xp_yp[s.fcam][s.scam][0];
double ymyp = s.iy - xp_yp[s.fcam][s.scam][1];
double xmxp2 = xmxp * xmxp;
double ymyp2 = ymyp * ymyp;
double xmxp_ymyp = xmxp * ymyp;
double d = Wp*(1.0 - (A*xmxp2 + 2 * B * xmxp_ymyp + C * ymyp2));
fx[ns] = d * Gp;
int np = 0;
if (jt != null) {
if (par_mask[DISP_INDEX]) jt[np++][ns] = d;
if (par_mask[A_INDEX]) jt[np++][ns] = -WGp*(xmxp2 + ymyp2);
if (par_mask[B_INDEX]) jt[np++][ns] = -WGp* 2 * xmxp_ymyp;
if (par_mask[CMA_INDEX]) jt[np++][ns] = -WGp* ymyp2;
}
}
// add 2 extra samples - damping cost_wy, cost_wxy
fx[num_samples] = av[WM_INDEX];
fx[num_samples + 1] = av[WXY_INDEX];
// and derivatives
if (jt != null) {
int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) {
jt[np][num_samples] = (i == WM_INDEX)? 1.0 : 0.0;
jt[np++][num_samples+1] = (i == WXY_INDEX)? 1.0 : 0.0;
}
}
return fx;
}
public void printParams() { // not used in lwir
for (int np = 0; np < all_pars.length; np++) {
String parname;
if (np < G0_INDEX) parname = PAR_NAMES[np];
else if (np < DDISP_INDEX) parname = PAR_NAME_SCALE;
else if (np < NDISP_INDEX) parname = PAR_NAME_CORRDISP;
else parname = PAR_NAME_CORRNDISP;
System.out.println(String.format("%2d%1s %22s %f",
np,
(par_mask[np]?"+":" "),
parname,
all_pars[np]));
}
}
public void printInputDataFx(boolean show_fx){ // not used in lwir
if (show_fx) {
Sample s = null;
double [] fx = getPolyFx();
if (fx == null) fx = getFx();
if (fx == null) return;
for (int i = 0; i < fx.length; i++) {
double fx_pos = (fx[i] >= 0)? fx[i]: Double.NaN;
if (i < samples.size()) {
s = samples.get(i);
System.out.println(String.format("%3d: x=%8.4f y=%8.4f v=%9.6f fx=%9.6f w=%9.7f fcam=%1d scam=%1d", i, s.x, s.y, s.v, fx_pos, s.w, s.fcam, s.scam));
}
else {
System.out.println(String.format("%3d: %10s %10s v=%9.6f fx=%9.6f w=%9.7f", i, "---", "---", this.values[i], fx_pos, this.weights[i]));
}
}
} else {
int ns =0;
for (Sample s:samples){
System.out.println(String.format("%3d: x=%8.4f y=%8.4f v=%9.6f w=%9.7f fcam=%1d scam=%1d", ns++, s.x, s.y, s.v, s.w, s.fcam, s.scam));
}
}
}
public double [] getRMS() { // USED in lwir
return last_rms;
}
public double [] getGoodOrBadRMS() { // not used in lwir
return good_or_bad_rms;
}
public double [] getAllPars() { // not used in lwir
return all_pars;
}
public double [] getDisparityStrength() { // USED in lwir
if (pair_weights == null) return null;
double disparity = -all_pars[DISP_INDEX];
double sum_amp = 0.0;
for (int i = 0; i < NUM_PAIRS; i++) {
sum_amp += pair_weights[i] * all_pars[G0_INDEX + i]; // group_weights is normalized
}
// protect from weird fitting results
double max_amp = 0.0;
for (Sample s: samples) if (s.v > max_amp) max_amp = s.v;
if (sum_amp > 1.25 * max_amp) sum_amp = max_amp;
double [] ds = {disparity, sum_amp};
return ds;
}
public double [] getDisparityStrengthABC() {// width = 1/sqrt(all_pars[A_INDEX])
double [] ds = getDisparityStrength();
if (ds == null) return null;
double [] dsw = {ds[0], ds[1], all_pars[A_INDEX], all_pars[B_INDEX],all_pars[CMA_INDEX]}; // asymmetry
return dsw;
}
@Deprecated
public double [] getDisparityStrengthWidth() { // USED in lwir
double [] ds = getDisparityStrength();
if (ds == null) return null;
double [] dsw = {ds[0], ds[1], all_pars[WM_INDEX], all_pars[WXY_INDEX]}; // asymmetry
return dsw;
}
@Deprecated
public Corr2dLMA ( // USED in lwir
double [] scales // null - use default table
) {
this.transform_size = 8;
this.corr_wnd = null;
if (scales != null) this.scales = scales.clone();
}
@Deprecated
public void setDiag(boolean diag_in) { // USED in lwir
this.input_diag = diag_in;
}
@Deprecated
public void addSample( // USED in lwir
double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double y, // y coordinate (0 - disparity axis)
double v, // correlation value at that point
double w,
int si, // baseline scale index
int gi){ // baseline scale index
samples.add(new Sample(x,y,v,w,si,gi));
if (!groups.containsKey(gi)) {
groups.put(gi,new NumDiag(groups.size(),this.input_diag));
}
}
//NumDiag
// TODO: add auto x0, half-width?
// should be called ater all samples are entered (to list groups)
@Deprecated
public void initVector( // USED in lwir
boolean adjust_wm, // 1
boolean adjust_wy, // 0
boolean adjust_wxy,// 1
boolean adjust_Ag, // 1
double x0,
double half_width, // 2.0
double cost_wm, // cost of non-zero this.all_pars[WM_INDEX] 0.0005
double cost_wxy // cost of non-zero this.all_pars[WXY_INDEX] 0.001
) {
// for (Sample s:samples) if (!groups.containsKey(s.gi)) groups.put(s.gi,groups.size());
int num_groups = groups.size();
this.all_pars = new double[AG_INDEX + num_groups];
this.all_pars[X0_INDEX] = x0;
this.all_pars[WM_INDEX] = half_width;
this.all_pars[WYD_INDEX] = 0.0;
this.all_pars[WXY_INDEX] = 0.0;
this.par_mask = new boolean[AG_INDEX + num_groups];
this.par_mask[X0_INDEX] = true;
this.par_mask[WM_INDEX] = adjust_wm;
this.par_mask[WYD_INDEX] = adjust_wy;
this.par_mask[WXY_INDEX] = adjust_wxy;
for (int i = 0; i <num_groups; i++) {
this.par_mask[AG_INDEX + i] = adjust_Ag;
}
setWeightsValues(half_width, cost_wm, cost_wxy);
int imx = 0;
int num_samples = samples.size();
for (int i = 1; i<num_samples; i++) if (values[i] > values[imx]) imx = i;
for (int i = 0; i < num_groups; i++) this.all_pars[AG_INDEX + i] = values[imx];
toVector();
}
@Deprecated
public void setWeightsValues( // USED in lwir
double half_width, // expected width
double cost_wm, // cost of non-zero this.all_pars[WYD_INDEX]
double cost_wxy) { // cost of non-zero this.all_pars[WXY_INDEX]
int np = samples.size();
group_weights = new double[groups.size()];
weights = new double [np+2];
values = new double [np+2];
weights[np] = cost_wm;
weights[np+1] = cost_wxy;
values[np] = half_width;
values[np+1] = 0.0;
double sw = 0;
for (int i = 0; i < np; i++) {
Sample s = samples.get(i);
weights[i] = s.w;
values[i] = s.v;
group_weights[groups.get(s.gi).num] += s.w;
if (Double.isNaN(values[i]) || Double.isNaN(weights[i])) { // not used in lwir
weights[i] = 0.0;
values[i] = 0.0;
}
sw += weights[i];
}
pure_weight = sw;
sw += weights[np] + weights[np+1];
if (sw != 0.0) {
sw = 1.0/sw;
for (int i = 0; i < weights.length; i++) weights[i] *= sw;
}
if (pure_weight > 0.0) for (int i = 0; i < group_weights.length; i++) group_weights[i] /= pure_weight;
pure_weight *= sw;
}
public void toVector() { // USED in lwir
int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) np++;
vector = new double[np];
np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) vector[np++] = all_pars[i];
}
public void updateFromVector() { // USED in lwir
int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) all_pars[i] = vector[np++];
}
public double [] fromVector(double [] vector) { // mix fixed and variable parameters // USED in lwir
if ( all_pars == null) return null;
double [] ap = all_pars.clone();
int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) ap[i] = vector[np++];
return ap;
}
////////////////////////////////////////////////////////////////////////
public void debugJt( // not used in lwir
double delta,
double [] vector) {
int num_points = this.values.length;
int num_pars = vector.length;
double [] max_diff = new double [num_pars];
// delta = 0.001;
double [][] jt = new double [num_pars][num_points];
double [][] jt_delta = new double [num_pars][num_points];
double [] fx = getFxJt( vector,jt);
getFxJt(delta, vector,jt_delta);
System.out.println("Test of jt-jt_delta difference, delta = "+delta);
System.out.print(String.format("%3s: %10s ", "#", "fx"));
for (int anp = 0; anp< all_pars.length; anp++) if(par_mask[anp]){
System.out.print(String.format("%17s ", ((anp < AG_INDEX)?PAR_NAMES_OLD[anp]:(PAR_NAMES_OLD[AG_INDEX]+(anp-AG_INDEX)))));
}
System.out.println();
for (int i = 0; i < num_points; i++) {
System.out.print(String.format("%3d: %10.7f ", i, fx[i]));
for (int np = 0; np < num_pars; np++) {
System.out.print(String.format("%8.5f %8.5f ", jt_delta[np][i], 1000*(jt[np][i] - jt_delta[np][i])));
double adiff = Math.abs(jt[np][i] - jt_delta[np][i]);
if (adiff > max_diff[np]) {
max_diff[np] = adiff;
}
}
System.out.println();
}
System.out.print(String.format("%15s ", "Maximal diff:"));
for (int np = 0; np < num_pars; np++) {
System.out.print(String.format("%8s %8.5f ", "1/1000×", 1000*max_diff[np]));
}
System.out.println();
}
public double [] getFxJt( // not used in lwir
double delta, // for testing derivatives: calculates as delta-F/delta_x
double [] vector,
double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
double [] fx0=getFxJt(vector,null);
for (int np = 0; np < vector.length; np++) {
double [] vector1 = vector.clone();
vector1[np]+= delta;
double [] fxp=getFxJt(vector1,null);
vector1 = vector.clone();
vector1[np]-= delta;
double [] fxm=getFxJt(vector1,null);
jt[np] = new double [fxp.length];
for (int i = 0; i < fxp.length; i++) {
jt[np][i] = (fxp[i] - fxm[i])/delta/2;
}
}
return fx0;
}
public double [] getFx() { // not used in lwir
return getFxJt(this.vector, null);
}
public double [] getFxJt( // USED in lwir
double [] vector,
double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
if (vector == null) return null;
double [] av = fromVector(vector);
int num_samples = samples.size();
double [] fx= new double [num_samples + 2];
int num_groups = groups.size();
double sqrt2 = Math.sqrt(2.0);
for (int ns = 0; ns < num_samples; ns++) {
Sample s = samples.get(ns);
int grp = groups.get(s.gi).num;
boolean diag = groups.get(s.gi).diag;
double wScale = diag?sqrt2:1.0;
double Wy = av[WM_INDEX] * scales[s.si] + av[WYD_INDEX];
double Wx = Wy + av[WXY_INDEX];
double dx = s.x - av[X0_INDEX];
double Ag = av[AG_INDEX+grp];
double dxw = wScale*dx/Wx;
double dyw = wScale*s.y/Wy;
double d = (1.0 - dxw*dxw - dyw*dyw);
fx[ns] = d * Ag;
int np = 0;
if (jt != null) {
// if (par_mask[X0_INDEX]) jt[np++][ns] = Ag * 2 * dxw/Wx; // d/dx0
if (par_mask[X0_INDEX]) jt[np++][ns] = wScale * Ag * 2 * dxw/Wx; // d/dx0
double dfdWx = Ag * 2 * dxw * dxw / Wx;
double dfdWy = Ag * 2 * dyw * dyw / Wy;
if (par_mask[WM_INDEX]) jt[np++][ns] = scales[s.si] * (dfdWx + dfdWy); // d/dWm
if (par_mask[WYD_INDEX]) jt[np++][ns] = (dfdWx + dfdWy); // d/dWyd
if (par_mask[WXY_INDEX]) jt[np++][ns] = dfdWx; // d/dWxy
for (int i = 0; i < num_groups; i++) {
if (par_mask[AG_INDEX + i]) jt[np++][ns] = (i == grp) ? d : 0.0; // d/dWAg
}
}
}
// add 2 extra samples - damping cost_wy, cost_wxy
fx[num_samples] = av[WM_INDEX];
fx[num_samples + 1] = av[WXY_INDEX];
// and derivatives
if (jt != null) {
int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) {
jt[np][num_samples] = (i == WM_INDEX)? 1.0 : 0.0;
jt[np++][num_samples+1] = (i == WXY_INDEX)? 1.0 : 0.0;
}
}
return fx;
}
public double [][] getWJtJlambda( // USED in lwir
double lambda,
double [][] jt){
int num_pars = jt.length;
int nup_points = jt[0].length;
double [][] wjtjl = new double [num_pars][num_pars];
for (int i = 0; i < num_pars; i++) {
for (int j = i; j < num_pars; j++) {
double d = 0.0;
for (int k = 0; k < nup_points; k++) {
d += this.weights[k]*jt[i][k]*jt[j][k];
}
wjtjl[i][j] = d;
if (i == j) {
wjtjl[i][j] += d * lambda;
} else {
wjtjl[j][i] = d;
}
}
}
return wjtjl;
}
// returns {rms, rms_pure}
public double [] getWYmFxRms( // USED in lwir
double [] fx) { // will be replaced with y-fx
int num_samples = samples.size();
int num_points = fx.length; // includes 2 extra for regularization
double rms = 0, rms_pure = 0;
for (int i = 0; i < num_samples; i++) {
double d = (values[i] - fx[i]);
fx[i] = this.weights[i] * d;
rms += fx[i]*d; // sum of weights
}
rms_pure = Math.sqrt(rms)/this.pure_weight;
for (int i = num_samples; i < num_points; i++) {
double d = (values[i] - fx[i]);
fx[i] = this.weights[i] * d;
rms += fx[i]*d; // sum of weights
}
rms = Math.sqrt(rms);
double [] rslt = {rms, rms_pure};
return rslt;
}
public double [] getJtWdiff( // not used in lwir
double [] wdiff,
double [][] jt){
int num_pars = jt.length;
int nup_points = jt[0].length;
double [] wjtymfx = new double [num_pars];
for (int i = 0; i < num_pars; i++) {
double d = 0;
for (int j = 0; j < nup_points; j++) d += wdiff[j] + jt[i][j];
wjtymfx[i] = d;
}
return wjtymfx;
}
public boolean runLma( // USED in lwir
double lambda, // 0.1
double lambda_scale_good,// 0.5
double lambda_scale_bad, // 8.0
double lambda_max, // 100
double rms_diff, // 0.001
int num_iter, // 20
int debug_level)
{
boolean [] rslt = {false,false};
int iter = 0;
for (iter = 0; iter < num_iter; iter++) {
rslt = lmaStep(
lambda,
rms_diff,
debug_level);
if (debug_level > 1) {
System.out.println("LMA step "+iter+": {"+rslt[0]+","+rslt[1]+"} full RMS="+good_or_bad_rms[0]+
" ("+initial_rms[0]+"), pure RMS="+good_or_bad_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda);
}
if (rslt[1]) {
break;
}
if (rslt[0]) { // good
lambda *= lambda_scale_good;
} else {
lambda *= lambda_scale_bad;
if (lambda > lambda_max) {
break; // not used in lwir
}
}
}
if (rslt[0]) { // better, but num tries exceeded
if (iter >= num_iter) {
if (debug_level > 0) System.out.println("Step "+iter+": Improved, but number of steps exceeded maximal");
} else {
if (debug_level > 0) System.out.println("Step "+iter+": LMA: Success");
}
} else { // improved over initial ?
if (last_rms[0] < initial_rms[0]) {
rslt[0] = true;
if (debug_level > 0) System.out.println("Step "+iter+": Failed to converge, but result improved over initial");
} else {
if (debug_level > 0) System.out.println("Step "+iter+": Failed to converge");
}
}
if (debug_level > 0) {
System.out.println("LMA: full RMS="+last_rms[0]+" ("+initial_rms[0]+"), pure RMS="+last_rms[1]+" ("+initial_rms[1]+") + lambda="+lambda);
}
return rslt[0];
}
// returns {success, done}
public boolean [] lmaStep( // USED in lwir
double lambda,
double rms_diff,
int debug_level) {
int num_points = this.weights.length; // includes 2 extra for regularization
int num_pars = vector.length;
boolean [] rslt = {false,false};
if (this.last_rms == null) { //first time, need to calculate all (vector is valid)
this.last_jt = new double [num_pars][num_points];
this.last_ymfx = getFxJt(
this.vector, // double [] vector,
this.last_jt); // double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
this.last_rms = getWYmFxRms(this.last_ymfx); // modifies this.last_ymfx
this.initial_rms = this.last_rms.clone();
this.good_or_bad_rms = this.last_rms.clone();
if (debug_level > 3) {
debugJt(
0.000001, // double delta,
this.vector); // double [] vector);
}
}
Matrix y_minus_fx_weighted = new Matrix(this.last_ymfx, this.last_ymfx.length);
Matrix wjtjlambda = new Matrix(getWJtJlambda(
lambda, // *10, // temporary
this.last_jt)); // double [][] jt)
if (debug_level>2) {
System.out.println("JtJ + lambda*diag(JtJ");
wjtjlambda.print(18, 6);
}
Matrix jtjl_inv = null;
try {
jtjl_inv = wjtjlambda.inverse(); // check for errors
} catch (RuntimeException e) {
rslt[1] = true;
if (debug_level > 0) {
System.out.println("Singular Matrix");
}
return rslt;
}
/*
try {
this.SYNC_COMMAND.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/
if (debug_level>2) {
System.out.println("(JtJ + lambda*diag(JtJ).inv()");
jtjl_inv.print(18, 6);
}
Matrix jty = (new Matrix(this.last_jt)).times(y_minus_fx_weighted);
if (debug_level>2) {
System.out.println("Jt * (y-fx)");
jty.print(18, 6);
}
Matrix mdelta = jtjl_inv.times(jty);
if (debug_level>2) {
System.out.println("mdelta");
mdelta.print(18, 6);
}
double [] delta = mdelta.getColumnPackedCopy();
double [] new_vector = this.vector.clone();
for (int i = 0; i < num_pars; i++) new_vector[i]+= delta[i];
// being optimistic, modify jt and last_ymfx in place, restore if failed
this.last_ymfx = getFxJt(
new_vector, // double [] vector,
this.last_jt); // double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
double [] rms = getWYmFxRms(this.last_ymfx); // modifies this.last_ymfx
this.good_or_bad_rms = rms.clone();
if (rms[0] < this.last_rms[0]) { // improved
rslt[0] = true;
rslt[1] = rms[0] >=(this.last_rms[0] * (1.0 - rms_diff));
this.last_rms = rms.clone();
this.vector = new_vector.clone();
if (debug_level > 2) {
System.out.print("New vector: ");
for (int np = 0; np < vector.length; np++) {
System.out.print(this.vector[np]+" ");
}
System.out.println();
}
} else { // worsened
rslt[0] = false;
rslt[1] = false; // do not know, caller will decide
// restore state
this.last_ymfx = getFxJt( // recalculate fx
this.vector, // double [] vector,
this.last_jt); // double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
this.last_rms = getWYmFxRms(this.last_ymfx); // modifies this.last_ymfx
if (debug_level > 2) {
debugJt(
0.000001, // double delta,
this.vector); // double [] vector);
}
}
return rslt;
}
// modify to reuse Samples and apply polynomial approximation to resolve x0,y0 and strength?
public double [] getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial // not used in lwir
/// double outside, // how much solution may be outside of the samples
boolean debug
) {
double [][][] mdata = new double[samples.size()][3][];
/// double min_x = Double.NaN, max_x = Double.NaN, min_y = Double.NaN, max_y =Double.NaN , min_v = Double.NaN;
for (int i = 0; i < mdata.length; i++) {
Sample s = samples.get(i);
mdata[i][0] = new double [2];
mdata[i][0][0] = s.x;
mdata[i][0][1] = s.y;
mdata[i][1] = new double [1];
mdata[i][1][0] = s.v;
mdata[i][2] = new double [1];
mdata[i][2][0] = s.w;
/*
if (i == 0) {
min_x = s.x;
max_x = min_x;
min_y = s.y;
max_y = min_y;
min_v = s.v;
} else {
if (s.x > max_x) max_x = s.x;
else if (s.x < min_x) min_x = s.x;
if (s.y > max_y) max_y = s.y;
else if (s.y < min_y) min_y = s.y;
if (s.v < min_v) min_v = s.x;
}
*/
}
double [] rslt = (new PolynomialApproximation()).quadraticMaxV2dX2Y2XY( // 9 elements - Xc, Yx, f(x,y), A, B, C, D, E, F (from A*x^2 + B*y^2 +C*x*y+...)
mdata,
1.0E-30,//25, // 1.0E-15,
debug? 4:0);
this.poly_coeff = rslt;
if ((rslt == null) || (rslt[2] < 0.0) || // negative strength
(rslt[3] >= 0.0) || // x: min, not max
(rslt[4] >= 0.0)) { // y: min, not max
this.poly_coeff = null;
this.poly_xyvwh = null;
return null;
}
// if ()
// calculate width_x and width_y
double hwx = Double.NaN, hwy = Double.NaN;
if ((rslt[2] > 0.0) && (rslt[3] <0.0) && (rslt[4] <0.0)) {
hwx = Math.sqrt(-rslt[2]/rslt[3]);
hwy = Math.sqrt(-rslt[2]/rslt[4]);
}
double [] xyvwh = {rslt[0], rslt[1], rslt[2], hwx, hwy};
if (debug){
System.out.println("lma.getMaxXYPoly()");
for (int i = 0; i< mdata.length; i++){
System.out.println(i+": "+mdata[i][0][0]+"/"+mdata[i][0][1]+" z="+mdata[i][1][0]+" w="+mdata[i][2][0]);
}
System.out.println("quadraticMax2d(mdata) --> "+((rslt==null)?"null":(rslt[0]+"/"+rslt[1])));
}
this.poly_xyvwh = xyvwh;
return xyvwh; // rslt;
}
public double [] getPoly() { // not used in lwir
return poly_xyvwh;
}
public double [] getPolyFx() {return getPolyFx(this.poly_coeff);} // not used in lwir
public double [] getPolyFx( // not used in lwir
double [] coeff) { // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
if (coeff == null) {
return null;
}
int num_samples = samples.size();
double [] fx= new double [num_samples];
for (int ns = 0; ns < num_samples; ns++) {
Sample s = samples.get(ns);
fx[ns]= coeff[3]*s.x*s.x + coeff[4]*s.y*s.y + coeff[5]*s.x*s.y + coeff[6]*s.x + coeff[7]*s.y + + coeff[8];
}
return fx;
}
}
...@@ -84,41 +84,41 @@ public class Correlation2d { ...@@ -84,41 +84,41 @@ public class Correlation2d {
{ 0.5, -0.5}, { 0.5, -0.5},
{-0.5, 0.5}, {-0.5, 0.5},
{ 0.5, 0.5}}; { 0.5, 0.5}};
// This table is used for CLT-based transform of teh correlation results to the pixel domain // This table is used for CLT-based transform of the correlation results to the pixel domain
final static int [][] ZI = final static int [][] ZI =
{{ 0, 1, 2, 3}, {{ 0, 1, 2, 3},
{-1, 0, -3, 2}, {-1, 0, -3, 2},
{-2, -3, 0, 1}, {-2, -3, 0, 1},
{ 3, -2, -1, 0}}; { 3, -2, -1, 0}};
public boolean isMonochrome() {return monochrome;} public boolean isMonochrome() {return monochrome;} // not used in lwir
// for 8 cameras and 16 pairs. Following data moved from ImageDtt // for 8 cameras and 16 pairs. Following data moved from ImageDtt
// which images to use (0..3 - external, 4..7 - internal) // which images to use (0..3 - external, 4..7 - internal)
public static int getImgMask (int data){ return (data & 0xff);} public static int getImgMask (int data){ return (data & 0xff);} // not used in lwir
// which pairs to combine in the combo see PAIRS data // which pairs to combine in the combo see PAIRS data
public static int getPairMask (int data){ return ((data >> 8) & 0xffff);} public static int getPairMask (int data){ return ((data >> 8) & 0xffff);} // not used in lwir
public static int setImgMask (int data, int mask) {return (data & ~0xff) | (mask & 0xff);} public static int setImgMask (int data, int mask) {return (data & ~0xff) | (mask & 0xff);} // not used in lwir
public static int setPairMask (int data, int mask) {return (data & ~0xffff00) | ((mask & 0xffff) << 8);} public static int setPairMask (int data, int mask) {return (data & ~0xffff00) | ((mask & 0xffff) << 8);} // not used in lwir
public static boolean getForcedDisparity (int data){return (data & 0x1000000) != 0;} public static boolean getForcedDisparity (int data){return (data & 0x1000000) != 0;} // not used in lwir
public static int setForcedDisparity (int data, boolean force) {return (data & ~0x1000000) | (force?0x1000000:0);} public static int setForcedDisparity (int data, boolean force) {return (data & ~0x1000000) | (force?0x1000000:0);} // not used in lwir
public static boolean getOrthoLines (int data){return (data & 0x2000000) != 0;} public static boolean getOrthoLines (int data){return (data & 0x2000000) != 0;} // not used in lwir
public static int setOrthoLines (int data, boolean ortho_lines) {return (data & ~0x2000000) | (ortho_lines?0x2000000:0);} public static int setOrthoLines (int data, boolean ortho_lines) {return (data & ~0x2000000) | (ortho_lines?0x2000000:0);} // not used in lwir
public static boolean isOrthoPair (int npair) {return (PAIRS[npair][2]== PAIR_HORIZONTAL) || (PAIRS[npair][2]== PAIR_VERTICAL);} public static boolean isOrthoPair (int npair) {return (PAIRS[npair][2]== PAIR_HORIZONTAL) || (PAIRS[npair][2]== PAIR_VERTICAL);} // not used in lwir
public static boolean isDiagonalPair (int npair) {return (PAIRS[npair][2]== PAIR_DIAGONAL_MAIN) || (PAIRS[npair][2]== PAIR_DIAGONAL_OTHER);} public static boolean isDiagonalPair (int npair) {return (PAIRS[npair][2]== PAIR_DIAGONAL_MAIN) || (PAIRS[npair][2]== PAIR_DIAGONAL_OTHER);} // USED in lwir
public static boolean isHorizontalPair (int npair) {return PAIRS[npair][2]== PAIR_HORIZONTAL;} public static boolean isHorizontalPair (int npair) {return PAIRS[npair][2]== PAIR_HORIZONTAL;} // USED in lwir
public static boolean isVerticalPair (int npair) {return PAIRS[npair][2]== PAIR_VERTICAL;} public static boolean isVerticalPair (int npair) {return PAIRS[npair][2]== PAIR_VERTICAL;} // USED in lwir
public static boolean isDiagonalMainPair (int npair) {return PAIRS[npair][2]== PAIR_DIAGONAL_MAIN;} public static boolean isDiagonalMainPair (int npair) {return PAIRS[npair][2]== PAIR_DIAGONAL_MAIN;} // USED in lwir
public static boolean isDiagonalOtherPair (int npair) {return PAIRS[npair][2]== PAIR_DIAGONAL_OTHER;} public static boolean isDiagonalOtherPair (int npair) {return PAIRS[npair][2]== PAIR_DIAGONAL_OTHER;} // USED in lwir
public static int getScaleOfPair (int npair) {return PAIRS[npair][3];} public static int getScaleOfPair (int npair) {return PAIRS[npair][3];} // not used in lwir
public static int getMaskHorizontal(int scale) {return getMaskType(PAIR_HORIZONTAL, scale);} public static int getMaskHorizontal(int scale) {return getMaskType(PAIR_HORIZONTAL, scale);} // USED in lwir
public static int getMaskVertical(int scale) {return getMaskType(PAIR_VERTICAL, scale);} public static int getMaskVertical(int scale) {return getMaskType(PAIR_VERTICAL, scale);} // USED in lwir
public static int getMaskDiagonalMain(int scale) {return getMaskType(PAIR_DIAGONAL_MAIN, scale);} public static int getMaskDiagonalMain(int scale) {return getMaskType(PAIR_DIAGONAL_MAIN, scale);} // not used in lwir
public static int getMaskDiagonalOther(int scale) {return getMaskType(PAIR_DIAGONAL_OTHER, scale);} public static int getMaskDiagonalOther(int scale) {return getMaskType(PAIR_DIAGONAL_OTHER, scale);} // not used in lwir
public static int getMaskOrtho(int scale) {return getMaskHorizontal(scale) | getMaskVertical(scale);} public static int getMaskOrtho(int scale) {return getMaskHorizontal(scale) | getMaskVertical(scale);} // not used in lwir
public static int getMaskDiagonal(int scale) {return getMaskDiagonalMain(scale) | getMaskDiagonalOther(scale);} public static int getMaskDiagonal(int scale) {return getMaskDiagonalMain(scale) | getMaskDiagonalOther(scale);} // not used in lwir
private static int getMaskType(int type, int scale) { // scale <0 = any private static int getMaskType(int type, int scale) { // scale <0 = any // USED in lwir
int bm = 0; int bm = 0;
for (int i = 0; i <PAIRS.length; i++) if ((PAIRS[i][2]==type) && ((scale < 0) || (scale == PAIRS[i][3]))) bm |= 1 << i; for (int i = 0; i <PAIRS.length; i++) if ((PAIRS[i][2]==type) && ((scale < 0) || (scale == PAIRS[i][3]))) bm |= 1 << i;
return bm; return bm;
...@@ -126,7 +126,7 @@ public class Correlation2d { ...@@ -126,7 +126,7 @@ public class Correlation2d {
public Correlation2d ( public Correlation2d ( // USED in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
int transform_size, int transform_size,
double wndx_scale, // (wndy scale is always 1.0) double wndx_scale, // (wndy scale is always 1.0)
...@@ -165,12 +165,12 @@ public class Correlation2d { ...@@ -165,12 +165,12 @@ public class Correlation2d {
} }
public int [] getTransposeAll(boolean diagonal){ public int [] getTransposeAll(boolean diagonal){ // USED in lwir
if (diagonal) return getTransposeAllDiagonal(); if (diagonal) return getTransposeAllDiagonal();
else return getTransposeAllOrtho(); else return getTransposeAllOrtho();
} }
public int [] getTransposeAllOrtho(){ public int [] getTransposeAllOrtho(){ // USED in lwir
if (this.transpose_all_ortho[0] == this.transpose_all_ortho[1]) { if (this.transpose_all_ortho[0] == this.transpose_all_ortho[1]) {
for (int i =0; i < corr_size; i++){ for (int i =0; i < corr_size; i++){
for (int j =0; j < corr_size; j++){ for (int j =0; j < corr_size; j++){
...@@ -181,7 +181,7 @@ public class Correlation2d { ...@@ -181,7 +181,7 @@ public class Correlation2d {
return this.transpose_all_ortho; return this.transpose_all_ortho;
} }
public int [] getTransposeAllDiagonal(){ public int [] getTransposeAllDiagonal(){ // USED in lwir
if (this.transpose_all_diagonal[0] == this.transpose_all_diagonal[1]) { if (this.transpose_all_diagonal[0] == this.transpose_all_diagonal[1]) {
for (int i =0; i < corr_size; i++){ for (int i =0; i < corr_size; i++){
for (int j = 0; j < corr_size; j++){ for (int j = 0; j < corr_size; j++){
...@@ -199,7 +199,7 @@ public class Correlation2d { ...@@ -199,7 +199,7 @@ public class Correlation2d {
* @param fat_zero add to normalization amplitude * @param fat_zero add to normalization amplitude
* @return [4][transform_len] FD CLT data * @return [4][transform_len] FD CLT data
*/ */
public double[][] correlateSingleColorFD( public double[][] correlateSingleColorFD( // USED in lwir
double [][] clt_data1, double [][] clt_data1,
double [][] clt_data2, double [][] clt_data2,
double [][] tcorr, // null or initialized to [4][transform_len] double [][] tcorr, // null or initialized to [4][transform_len]
...@@ -249,7 +249,7 @@ public class Correlation2d { ...@@ -249,7 +249,7 @@ public class Correlation2d {
* @param fat_zero fat zero for phase correlation (0 seems to be OK) * @param fat_zero fat zero for phase correlation (0 seems to be OK)
* @return correlation result [(2*transform_size-1) * (2*transform_size-1)] * @return correlation result [(2*transform_size-1) * (2*transform_size-1)]
*/ */
public double[] correlateCompositeFD( public double[] correlateCompositeFD( // USED in lwir
double [][][] clt_data1, double [][][] clt_data1,
double [][][] clt_data2, double [][][] clt_data2,
double [] lpf, double [] lpf,
...@@ -271,7 +271,7 @@ public class Correlation2d { ...@@ -271,7 +271,7 @@ public class Correlation2d {
if (col_weights[i] != 0.0) col_weights[i] *= scale_value; if (col_weights[i] != 0.0) col_weights[i] *= scale_value;
} }
if (clt_data1.length == 1) { // monochrome if (clt_data1.length == 1) { // monochrome // not used in lwir
col_weights = new double[1]; col_weights = new double[1];
col_weights[0] = 1.0; col_weights[0] = 1.0;
} }
...@@ -332,7 +332,7 @@ public class Correlation2d { ...@@ -332,7 +332,7 @@ public class Correlation2d {
* @param fat_zero fat zero for phase correlations * @param fat_zero fat zero for phase correlations
* @return [pair][corr_index] * @return [pair][corr_index]
*/ */
public double [][] correlateCompositeFD( public double [][] correlateCompositeFD( // USED in lwir
double [][][][][][] clt_data, double [][][][][][] clt_data,
int tileX, int tileX,
int tileY, int tileY,
...@@ -359,7 +359,7 @@ public class Correlation2d { ...@@ -359,7 +359,7 @@ public class Correlation2d {
/** /**
* Calculate all required image pairs phase correlation * Calculate all required image pairs phase correlation
* @param clt_data aberration-corrected FD CLT data for one tile [camera][color][quadrant][index] * @param clt_data_tile aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
* @param pairs_mask bimask of required pairs * @param pairs_mask bimask of required pairs
* @param lpf optional low-pass filter * @param lpf optional low-pass filter
* @param scale_value scale correlation results to compensate for lpf changes and other factors * @param scale_value scale correlation results to compensate for lpf changes and other factors
...@@ -367,7 +367,7 @@ public class Correlation2d { ...@@ -367,7 +367,7 @@ public class Correlation2d {
* @param fat_zero fat zero for phase correlations * @param fat_zero fat zero for phase correlations
* @return [pair][corr_index] * @return [pair][corr_index]
*/ */
public double [][] correlateCompositeFD( public double [][] correlateCompositeFD( // USED in lwir
double [][][][] clt_data_tile, double [][][][] clt_data_tile,
int pairs_mask, // already decoded so bit 0 - pair 0 int pairs_mask, // already decoded so bit 0 - pair 0
double [] lpf, double [] lpf,
...@@ -403,7 +403,7 @@ public class Correlation2d { ...@@ -403,7 +403,7 @@ public class Correlation2d {
* @param fat_zero fat zero for phase correlations * @param fat_zero fat zero for phase correlations
* @return 2-d correlation array in line scan order * @return 2-d correlation array in line scan order
*/ */
public double [] correlateInterCamerasFD( public double [] correlateInterCamerasFD( // not used in lwir
double [][][][] clt_data_tile_main, double [][][][] clt_data_tile_main,
double [][][][] clt_data_tile_aux, double [][][][] clt_data_tile_aux,
double [] lpf, double [] lpf,
...@@ -431,7 +431,7 @@ public class Correlation2d { ...@@ -431,7 +431,7 @@ public class Correlation2d {
* @param clt_data_tile aberration-corrected FD CLT data for one tile [camera][color][quadrant][index] * @param clt_data_tile aberration-corrected FD CLT data for one tile [camera][color][quadrant][index]
* @return averaged for all cameras FD data [color][quadrant][index] * @return averaged for all cameras FD data [color][quadrant][index]
*/ */
public double [][][] cltMixCameras( public double [][][] cltMixCameras( // not used in lwir
double [][][][] clt_data_tile){ double [][][][] clt_data_tile){
int tlen = transform_size * transform_size; int tlen = transform_size * transform_size;
double [][][] clt_mix = new double [clt_data_tile[0].length][4][tlen]; double [][][] clt_mix = new double [clt_data_tile[0].length][4][tlen];
...@@ -472,7 +472,7 @@ public class Correlation2d { ...@@ -472,7 +472,7 @@ public class Correlation2d {
* @return single square correlation array, same dimension as the input (now 15x15) * @return single square correlation array, same dimension as the input (now 15x15)
*/ */
public double [] combineCompatiblePairs( public double [] combineCompatiblePairs(// USED in lwir
double [][] correlations, double [][] correlations,
int pairs_mask, int pairs_mask,
boolean diagonal, boolean diagonal,
...@@ -512,7 +512,7 @@ public class Correlation2d { ...@@ -512,7 +512,7 @@ public class Correlation2d {
* (1 - largest, 2 - half, 4 - quarter) * (1 - largest, 2 - half, 4 - quarter)
* @return {number of compatible pairs among the selection, index of the base pair} * @return {number of compatible pairs among the selection, index of the base pair}
*/ */
public int [] getNumberBaseOfCompatiblePairs( public int [] getNumberBaseOfCompatiblePairs(// USED in lwir
double [][] correlations, double [][] correlations,
int pairs_mask, int pairs_mask,
boolean diagonal, boolean diagonal,
...@@ -541,7 +541,7 @@ public class Correlation2d { ...@@ -541,7 +541,7 @@ public class Correlation2d {
* @param pairs_mask bitmask of selected pairs * @param pairs_mask bitmask of selected pairs
* @return subsampling {min, max}: 1 - no subsampling, also possible 2 and 4 (8-camera) * @return subsampling {min, max}: 1 - no subsampling, also possible 2 and 4 (8-camera)
*/ */
public int [] getMinMaxSubSample(int pairs_mask) { public int [] getMinMaxSubSample(int pairs_mask) {// USED in lwir
int ss_max = 0; int ss_max = 0;
for (int npair = 0; npair < PAIRS.length; npair++) if (((pairs_mask >> npair) & 1) != 0 ) { for (int npair = 0; npair < PAIRS.length; npair++) if (((pairs_mask >> npair) & 1) != 0 ) {
if (PAIRS[npair][3] > ss_max) { if (PAIRS[npair][3] > ss_max) {
...@@ -550,7 +550,7 @@ public class Correlation2d { ...@@ -550,7 +550,7 @@ public class Correlation2d {
} }
int ss_min = ss_max; int ss_min = ss_max;
for (int npair = 0; npair < PAIRS.length; npair++) if (((pairs_mask >> npair) & 1) != 0 ) { for (int npair = 0; npair < PAIRS.length; npair++) if (((pairs_mask >> npair) & 1) != 0 ) {
if (PAIRS[npair][3] < ss_min) { if (PAIRS[npair][3] < ss_min) { // not used in lwir
ss_min = PAIRS[npair][3]; ss_min = PAIRS[npair][3];
} }
} }
...@@ -566,7 +566,7 @@ public class Correlation2d { ...@@ -566,7 +566,7 @@ public class Correlation2d {
* @param hwidth number of the result rows (1 - only main diagonal, 2 - main diagonal and 2 other color ones * @param hwidth number of the result rows (1 - only main diagonal, 2 - main diagonal and 2 other color ones
* @return transformed array of correlation arrays [hwidth][2*transform_size-1] (some may be nulls) * @return transformed array of correlation arrays [hwidth][2*transform_size-1] (some may be nulls)
*/ */
public double [][] scaleRotateInterpoateCorrelations( public double [][] scaleRotateInterpoateCorrelations(// USED in lwir
double [][] correlations, double [][] correlations,
int pairs_mask, int pairs_mask,
// int sub_sampling, // int sub_sampling,
...@@ -606,7 +606,7 @@ public class Correlation2d { ...@@ -606,7 +606,7 @@ public class Correlation2d {
* @return transformed correlation array [hwidth][2*transform_size-1] * @return transformed correlation array [hwidth][2*transform_size-1]
*/ */
public double [] scaleRotateInterpoateSingleCorrelation( public double [] scaleRotateInterpoateSingleCorrelation(// USED in lwir
double [][] correlations, double [][] correlations,
int npair, int npair,
int sub_sampling, int sub_sampling,
...@@ -620,7 +620,7 @@ public class Correlation2d { ...@@ -620,7 +620,7 @@ public class Correlation2d {
PAIRS[npair][3]/sub_sampling, PAIRS[npair][3]/sub_sampling,
debug); debug);
} }
public double [] scaleRotateInterpoateSingleCorrelation( public double [] scaleRotateInterpoateSingleCorrelation(// USED in lwir
double [] corr, double [] corr,
int hwidth, int hwidth,
int dir, // 0 - hor, 1 - vert, 2 - parallel to row = col (main) diagonal (0->3), 3 -2->1 int dir, // 0 - hor, 1 - vert, 2 - parallel to row = col (main) diagonal (0->3), 3 -2->1
...@@ -678,11 +678,11 @@ public class Correlation2d { ...@@ -678,11 +678,11 @@ public class Correlation2d {
} else { //interpolate x only } else { //interpolate x only
double dx = (xnum + ilimit) / rdenom - ix0; double dx = (xnum + ilimit) / rdenom - ix0;
double dy = (ynum + ilimit) / rdenom - iy0; double dy = (ynum + ilimit) / rdenom - iy0;
if (int_y) { if (int_y) { // not used in lwir
d = (1.0-dx)*corr[iy0*width + ix0] + dx*corr[iy0 * width + ix0 + 1]; d = (1.0-dx)*corr[iy0*width + ix0] + dx*corr[iy0 * width + ix0 + 1];
} else if (int_x) { } else if (int_x) { // not used in lwir
d = (1.0-dy)*corr[iy0*width + ix0] + dy*corr[iy0 * width + ix0 + width]; d = (1.0-dy)*corr[iy0*width + ix0] + dy*corr[iy0 * width + ix0 + width];
} else { // bilinear } else { // bilinear - // USED in LWIR
d = ( (1.0 - dx) * (1.0 - dy) * corr[iy0 * width + ix0]) + d = ( (1.0 - dx) * (1.0 - dy) * corr[iy0 * width + ix0]) +
( dx * (1.0 - dy) * corr[iy0 * width + ix0 + 1]) + ( dx * (1.0 - dy) * corr[iy0 * width + ix0 + 1]) +
((1.0 - dx) * dy * corr[iy0 * width + ix0 + width]) + ((1.0 - dx) * dy * corr[iy0 * width + ix0 + width]) +
...@@ -736,7 +736,7 @@ public class Correlation2d { ...@@ -736,7 +736,7 @@ public class Correlation2d {
* the weight of diagonal pairs * the weight of diagonal pairs
* @return combined correlation data * @return combined correlation data
*/ */
public double [] combineInterpolatedCorrelations( public double [] combineInterpolatedCorrelations( // USED in lwir
double [][] strips, double [][] strips,
int pairs_mask, int pairs_mask,
double offset, double offset,
...@@ -749,14 +749,14 @@ public class Correlation2d { ...@@ -749,14 +749,14 @@ public class Correlation2d {
combo = new double [strips[npair].length]; combo = new double [strips[npair].length];
for (int i = 0; i < combo.length; i++) combo[i] = 1.0; for (int i = 0; i < combo.length; i++) combo[i] = 1.0;
} }
if (twice_diagonal) { if (twice_diagonal) { // USED in lwir
for (int i = 0; i < combo.length; i++) { for (int i = 0; i < combo.length; i++) {
double d = strips[npair][i] + offset; double d = strips[npair][i] + offset;
if (d < 0.0) d = 0.0; if (d < 0.0) d = 0.0;
combo[i] *= d * d; combo[i] *= d * d;
} }
ncombined++; ncombined++;
} else { } else { // not used in lwir
for (int i = 0; i < combo.length; i++) { for (int i = 0; i < combo.length; i++) {
double d = strips[npair][i] + offset; double d = strips[npair][i] + offset;
if (d < 0.0) d = 0.0; if (d < 0.0) d = 0.0;
...@@ -771,7 +771,7 @@ public class Correlation2d { ...@@ -771,7 +771,7 @@ public class Correlation2d {
if (combo[i] > 0.0) combo[i] = Math.pow(combo[i], pwr) - offset; if (combo[i] > 0.0) combo[i] = Math.pow(combo[i], pwr) - offset;
} }
} }
} else { // use addition } else { // use addition // not used in lwir
for (int npair = 0; npair < strips.length; npair++) if (((pairs_mask & (1 << npair)) != 0) && (strips[npair] != null)){ for (int npair = 0; npair < strips.length; npair++) if (((pairs_mask & (1 << npair)) != 0) && (strips[npair] != null)){
if (combo == null) { if (combo == null) {
combo = new double [strips[npair].length]; combo = new double [strips[npair].length];
...@@ -806,7 +806,7 @@ public class Correlation2d { ...@@ -806,7 +806,7 @@ public class Correlation2d {
*/ */
public int [] getMaxXYInt( // find integer pair or null if below threshold public int [] getMaxXYInt( // find integer pair or null if below threshold // USED in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
boolean axis_only, boolean axis_only,
double minMax, // minimal value to consider (at integer location, not interpolated) double minMax, // minimal value to consider (at integer location, not interpolated)
...@@ -817,7 +817,7 @@ public class Correlation2d { ...@@ -817,7 +817,7 @@ public class Correlation2d {
int center_row = 0; int center_row = 0;
int center = transform_size - 1; int center = transform_size - 1;
if (data_height == data_width) { if (data_height == data_width) {
center_row = center; center_row = center; // not used in lwir
} else { } else {
axis_only = true; axis_only = true;
} }
...@@ -831,7 +831,7 @@ public class Correlation2d { ...@@ -831,7 +831,7 @@ public class Correlation2d {
for (int i = 1; i < data_width; i++) { for (int i = 1; i < data_width; i++) {
if (Double.isNaN(data[imx]) || (data[sol+i] > data[imx])) imx = sol+i; if (Double.isNaN(data[imx]) || (data[sol+i] > data[imx])) imx = sol+i;
} }
} else { // only for the the square tile } else { // only for the the square tile // not used in lwir
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
if (Double.isNaN(data[imx]) || (data[i] > data[imx])) imx = i; if (Double.isNaN(data[imx]) || (data[i] > data[imx])) imx = i;
} }
...@@ -859,7 +859,7 @@ public class Correlation2d { ...@@ -859,7 +859,7 @@ public class Correlation2d {
* @param debug * @param debug
* @return a pair of {x,y} offsets of the center of masses to the tile center. * @return a pair of {x,y} offsets of the center of masses to the tile center.
*/ */
public double [] getMaxXYCm( public double [] getMaxXYCm( // not used in lwir
double [] data, double [] data,
int [] icenter, int [] icenter,
double radius, // positive - within that distance, negative - within 2*(-radius)+1 square double radius, // positive - within that distance, negative - within 2*(-radius)+1 square
...@@ -917,7 +917,7 @@ public class Correlation2d { ...@@ -917,7 +917,7 @@ public class Correlation2d {
* @param debug not yet used * @param debug not yet used
* @return {argmax from center, weight, half_width} or null * @return {argmax from center, weight, half_width} or null
*/ */
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max // USED in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
int ixcenter, // integer center x int ixcenter, // integer center x
boolean debug) { boolean debug) {
...@@ -928,7 +928,7 @@ public class Correlation2d { ...@@ -928,7 +928,7 @@ public class Correlation2d {
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
debug);// boolean debug); debug);// boolean debug);
} }
public double [] getMaxXCmNotch( // get fractional center as a "center of mass" inside circle/square from the integer max 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] double [] data, // [data_size * data_size]
int ixcenter, // integer center x int ixcenter, // integer center x
boolean debug) { boolean debug) {
...@@ -939,7 +939,7 @@ public class Correlation2d { ...@@ -939,7 +939,7 @@ public class Correlation2d {
this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction this.corr_wndx, // double [] window_x, // half of a window function in x (disparity) direction
debug); // boolean debug); debug); // boolean debug);
} }
public double [] getMaxXCm( // get fractional center as a "center of mass" inside circle/square from the integer max 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 double [] data, // rectangular strip of 1/2 of the correlation are with odd rows shifted by 1/2 pixels
int ixcenter, // integer center x int ixcenter, // integer center x
double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1 double [] window_y, // (half) window function in y-direction(perpendicular to disparity: for row0 ==1
...@@ -951,7 +951,7 @@ public class Correlation2d { ...@@ -951,7 +951,7 @@ public class Correlation2d {
double wy_scale = 1.0; double wy_scale = 1.0;
if (data_height > window_y.length) { if (data_height > window_y.length) {
data_height = window_y.length; data_height = window_y.length;
} else if (data_height < window_y.length) { // re- } else if (data_height < window_y.length) { // re- // not used in lwir
double swy = window_y[0]; double swy = window_y[0];
for (int i = 1; i < data_height; i++) swy += window_y[i]; for (int i = 1; i < data_height; i++) swy += window_y[i];
wy_scale = 1.0/swy; wy_scale = 1.0/swy;
...@@ -1050,7 +1050,7 @@ public class Correlation2d { ...@@ -1050,7 +1050,7 @@ public class Correlation2d {
* @return half-window array [ihwidth] * @return half-window array [ihwidth]
*/ */
public double [] halfFlatTopWindow( public double [] halfFlatTopWindow( // USED in lwir
int ihwidth, int ihwidth,
double hwidth, double hwidth,
double blur, double blur,
...@@ -1059,7 +1059,7 @@ public class Correlation2d { ...@@ -1059,7 +1059,7 @@ public class Correlation2d {
double scale) { double scale) {
double [] wnd = new double [ihwidth]; double [] wnd = new double [ihwidth];
for (int i = 0; i < ihwidth; i++) { for (int i = 0; i < ihwidth; i++) {
if (blur <= 0.0) { if (blur <= 0.0) { // not used in lwir
wnd[i] = (i < hwidth)? 1.0:0.0; wnd[i] = (i < hwidth)? 1.0:0.0;
} else { } else {
if (i < hwidth - blur/2) wnd[i] = 1.0; if (i < hwidth - blur/2) wnd[i] = 1.0;
...@@ -1094,7 +1094,7 @@ public class Correlation2d { ...@@ -1094,7 +1094,7 @@ public class Correlation2d {
* @param center_corr - output array [(2*hwidth+1)*(2*hwidth+1)] or null * @param center_corr - output array [(2*hwidth+1)*(2*hwidth+1)] or null
* @return center_corr - center part of the correlation in linescan order * @return center_corr - center part of the correlation in linescan order
*/ */
public double [] corrCenterValues( public double [] corrCenterValues( // USED in lwir
int hwidth, int hwidth,
double [] full_corr, double [] full_corr,
double [] center_corr) { double [] center_corr) {
...@@ -1123,7 +1123,7 @@ public class Correlation2d { ...@@ -1123,7 +1123,7 @@ public class Correlation2d {
* @param full_corr full pixel-domain correlation (now 15x15=225 long)for each of 6 pairs * @param full_corr full pixel-domain correlation (now 15x15=225 long)for each of 6 pairs
* @param center_corr - output array [(2*hwidth+1)*(2*hwidth+1)]. should be [8][] * @param center_corr - output array [(2*hwidth+1)*(2*hwidth+1)]. should be [8][]
*/ */
public void corrCenterValues( public void corrCenterValues( // USED in lwir
int hwidth, int hwidth,
double offset, double offset,
double [][] full_corr, double [][] full_corr,
...@@ -1155,7 +1155,7 @@ public class Correlation2d { ...@@ -1155,7 +1155,7 @@ public class Correlation2d {
} else { } else {
cc = -offset; // smallest value cc = -offset; // smallest value
} }
} else { } else { // not used in lwir
cc = 0.5*(fc0+fc1); cc = 0.5*(fc0+fc1);
} }
...@@ -1178,7 +1178,7 @@ public class Correlation2d { ...@@ -1178,7 +1178,7 @@ public class Correlation2d {
* @param ml_tile (2 * ml_hwidth + 1) * (2 * ml_hwidth + 1) tile data to be saved * @param ml_tile (2 * ml_hwidth + 1) * (2 * ml_hwidth + 1) tile data to be saved
* @param tilesX image width in tiles * @param tilesX image width in tiles
*/ */
public void saveMlTile( public void saveMlTile( // USED in lwir
int tileX, int tileX,
int tileY, int tileY,
int ml_hwidth, int ml_hwidth,
...@@ -1207,7 +1207,7 @@ public class Correlation2d { ...@@ -1207,7 +1207,7 @@ public class Correlation2d {
* @param ml_value value to set * @param ml_value value to set
* @param tilesX image width in tiles * @param tilesX image width in tiles
*/ */
public void saveMlTilePixel( public void saveMlTilePixel(// USED in lwir
int tileX, int tileX,
int tileY, int tileY,
int ml_hwidth, int ml_hwidth,
...@@ -1234,7 +1234,7 @@ public class Correlation2d { ...@@ -1234,7 +1234,7 @@ public class Correlation2d {
* @param tilesX image width in tiles * @param tilesX image width in tiles
* @return value indexed by tileX, tileY, ml_layer and ml_index * @return value indexed by tileX, tileY, ml_layer and ml_index
*/ */
public double restoreMlTilePixel( public double restoreMlTilePixel( // not used in lwir
int tileX, int tileX,
int tileY, int tileY,
int ml_hwidth, int ml_hwidth,
...@@ -1258,7 +1258,7 @@ public class Correlation2d { ...@@ -1258,7 +1258,7 @@ public class Correlation2d {
* @return index of teh selected pixel in thye whole image (specified by tileX, tileY, and ml_index) * @return index of teh selected pixel in thye whole image (specified by tileX, tileY, and ml_index)
*/ */
public int getMlTilePixelIndex( public int getMlTilePixelIndex( // not used in lwir
int tileX, int tileX,
int tileY, int tileY,
int ml_hwidth, int ml_hwidth,
...@@ -1272,7 +1272,7 @@ public class Correlation2d { ...@@ -1272,7 +1272,7 @@ public class Correlation2d {
public double [] debugStrip( public double [] debugStrip( // USED in lwir
double [] strip) { double [] strip) {
if (strip == null) return null; if (strip == null) return null;
int center = transform_size - 1; int center = transform_size - 1;
...@@ -1280,7 +1280,7 @@ public class Correlation2d { ...@@ -1280,7 +1280,7 @@ public class Correlation2d {
int height = strip.length/width; int height = strip.length/width;
double [] padded_strip = new double [width*width]; double [] padded_strip = new double [width*width];
for (int row = 0; row < width; row++) { for (int row = 0; row < width; row++) {
if ((row <= center - height) || (row >= center+ height)) { if ((row <= center - height) || (row >= center+ height)) { // not used in lwir
for (int j = 0; j<width; j++) padded_strip[row*width+j] = Double.NaN; for (int j = 0; j<width; j++) padded_strip[row*width+j] = Double.NaN;
} else { } else {
int srow = (row >= center)? (row - center) : (center - row); int srow = (row >= center)? (row - center) : (center - row);
...@@ -1292,7 +1292,7 @@ public class Correlation2d { ...@@ -1292,7 +1292,7 @@ public class Correlation2d {
} }
// only show center part, but with correct shift // only show center part, but with correct shift
public double [] debugStrip2( public double [] debugStrip2( // USED in lwir
double [] strip) { double [] strip) {
if (strip == null) return null; if (strip == null) return null;
int center = transform_size - 1; int center = transform_size - 1;
...@@ -1300,7 +1300,7 @@ public class Correlation2d { ...@@ -1300,7 +1300,7 @@ public class Correlation2d {
int height = strip.length/width; int height = strip.length/width;
double [] padded_strip = new double [width*width]; double [] padded_strip = new double [width*width];
for (int row = 0; row < width; row++) { for (int row = 0; row < width; row++) {
if ((row <= center - height) || (row >= center+ height)) { if ((row <= center - height) || (row >= center+ height)) { // not used in lwir
for (int j = 0; j<width; j++) padded_strip[row*width+j] = Double.NaN; for (int j = 0; j<width; j++) padded_strip[row*width+j] = Double.NaN;
} else { } else {
int srow = (row >= center)? (row - center) : (center - row); int srow = (row >= center)? (row - center) : (center - row);
...@@ -1316,7 +1316,7 @@ public class Correlation2d { ...@@ -1316,7 +1316,7 @@ public class Correlation2d {
} }
// Full size/resolution.but on a larger rectangle // Full size/resolution.but on a larger rectangle
public double [] debugStrip3( public double [] debugStrip3( // not used in lwir
double [] strip) { double [] strip) {
if (strip == null) return null; if (strip == null) return null;
int center = transform_size - 1; int center = transform_size - 1;
...@@ -1341,7 +1341,7 @@ public class Correlation2d { ...@@ -1341,7 +1341,7 @@ public class Correlation2d {
return padded_strip; return padded_strip;
} }
public double [] mismatchPairsCM( // returns x-xcenter, y, strength (sign same as disparity) public double [] mismatchPairsCM( // returns x-xcenter, y, strength (sign same as disparity) // USED in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [][] corrs, double [][] corrs,
int pair_mask, // which pairs to process int pair_mask, // which pairs to process
...@@ -1378,7 +1378,7 @@ public class Correlation2d { ...@@ -1378,7 +1378,7 @@ public class Correlation2d {
} else if (isDiagonalOtherPair(pair)) { } else if (isDiagonalOtherPair(pair)) {
icenter[0] = ixcenter; icenter[0] = ixcenter;
icenter[1] = -ixcenter; icenter[1] = -ixcenter;
} else { } else { // not used in lwir
System.out.println("************ BUG: illegal pair type for pair1"+pair); System.out.println("************ BUG: illegal pair type for pair1"+pair);
return null; return null;
} }
...@@ -1422,7 +1422,7 @@ public class Correlation2d { ...@@ -1422,7 +1422,7 @@ public class Correlation2d {
} else if (isDiagonalOtherPair(pair)) { } else if (isDiagonalOtherPair(pair)) {
rslt[3 * np + 0] = xcenter - xm; rslt[3 * np + 0] = xcenter - xm;
rslt[3 * np + 1] = -xcenter - ym; rslt[3 * np + 1] = -xcenter - ym;
} else { } else { // not used in lwir
System.out.println("************ BUG: illegal pair type for pair "+pair); System.out.println("************ BUG: illegal pair type for pair "+pair);
return null; return null;
} }
...@@ -1439,7 +1439,7 @@ public class Correlation2d { ...@@ -1439,7 +1439,7 @@ public class Correlation2d {
// returns array 3*num_pairs long // returns array 3*num_pairs long
// TODO: now works for small offsets. Maybe add re-calculate int argmax for each pair? xcenter is still needed to subtract Add switch? (small/large correction) // TODO: now works for small offsets. Maybe add re-calculate int argmax for each pair? xcenter is still needed to subtract Add switch? (small/large correction)
public double [] mismatchPairs( // returns x-xcenter, y, strength (sign same as disparity) public double [] mismatchPairs( // returns x-xcenter, y, strength (sign same as disparity) // not used in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [][] corrs, double [][] corrs,
int pair_mask, // which pairs to process int pair_mask, // which pairs to process
...@@ -1508,7 +1508,7 @@ public class Correlation2d { ...@@ -1508,7 +1508,7 @@ public class Correlation2d {
} }
// run a single correlation poly // run a single correlation poly
public double [] single2dPoly( // returns x-xcenter, y, strength (sign same as disparity) public double [] single2dPoly( // returns x-xcenter, y, strength (sign same as disparity) // not used in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [] corr, double [] corr,
double xcenter, // -disparity to compare. use 0? double xcenter, // -disparity to compare. use 0?
...@@ -1537,7 +1537,7 @@ public class Correlation2d { ...@@ -1537,7 +1537,7 @@ public class Correlation2d {
} }
// ignores negative values // ignores negative values
public double [] single2dCM( // returns x-xcenter, y, strength (sign same as disparity) public double [] single2dCM( // returns x-xcenter, y, strength (sign same as disparity) // not used in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [] corr, double [] corr,
double xcenter, // -disparity to compare. use 0? double xcenter, // -disparity to compare. use 0?
...@@ -1590,7 +1590,7 @@ public class Correlation2d { ...@@ -1590,7 +1590,7 @@ public class Correlation2d {
public double [][] corr4dirsLMA( public double [][] corr4dirsLMA( // USED in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [][] corrs, double [][] corrs,
int pair_mask, // which pairs to process int pair_mask, // which pairs to process
...@@ -1609,7 +1609,7 @@ public class Correlation2d { ...@@ -1609,7 +1609,7 @@ public class Correlation2d {
for (int i = 0; i < PAIRS.length; i++) if (((pair_mask & (1 << i)) != 0) && (PAIRS[i][2] == types[dir])) { for (int i = 0; i < PAIRS.length; i++) if (((pair_mask & (1 << i)) != 0) && (PAIRS[i][2] == types[dir])) {
this_mask |= (1 << i); this_mask |= (1 << i);
} }
if (this_mask == 0) { if (this_mask == 0) { // not used in lwir
rslt[dir] = null; rslt[dir] = null;
} else { } else {
Correlations2dLMA lma=corrLMA( Correlations2dLMA lma=corrLMA(
...@@ -1662,7 +1662,7 @@ public class Correlation2d { ...@@ -1662,7 +1662,7 @@ public class Correlation2d {
} }
// each element may be null, data may contain NaN // each element may be null, data may contain NaN
*/ */
public double [] foregroundCorrect( public double [] foregroundCorrect( // USED in lwir
boolean bg, boolean bg,
boolean ortho, boolean ortho,
double [][] dir_disp_strength, // double [][] dir_disp_strength, //
...@@ -1716,7 +1716,7 @@ public class Correlation2d { ...@@ -1716,7 +1716,7 @@ public class Correlation2d {
"width_d["+isel+"] = "+width_d[isel]+" > "+max_hwidth+")"); "width_d["+isel+"] = "+width_d[isel]+" > "+max_hwidth+")");
} else if ((eff_strength[isel]/eff_strength[iortho] < min_eff_ratio)) { } else if ((eff_strength[isel]/eff_strength[iortho] < min_eff_ratio)) {
corr = Double.NaN; corr = Double.NaN;
if (debug) System.out.println("Direction with "+(bg?"min":"max")+" has effective strenbgth ratio too small -> no correction ("+ if (debug) System.out.println("Direction with "+(bg?"min":"max")+" has effective strength ratio too small -> no correction ("+
"(eff_strength["+isel+"] = "+eff_strength[isel]+")/(eff_strength["+iortho+"] = "+eff_strength[iortho]+") < "+min_eff_ratio+")"); "(eff_strength["+isel+"] = "+eff_strength[isel]+")/(eff_strength["+iortho+"] = "+eff_strength[iortho]+") < "+min_eff_ratio+")");
} else { } else {
if (ortho && !are_ortho) { if (ortho && !are_ortho) {
...@@ -1728,7 +1728,7 @@ public class Correlation2d { ...@@ -1728,7 +1728,7 @@ public class Correlation2d {
if (debug) System.out.println("Orthogonal direction is not strong enough -> overcorrection = 0 (just using "+(bg?"min":"max") ); if (debug) System.out.println("Orthogonal direction is not strong enough -> overcorrection = 0 (just using "+(bg?"min":"max") );
} }
} }
if (!(mx >= (mn + min_diff))) { // so NaN are OK if (!(mx >= (mn + min_diff))) { // so NaN are OK // not used in lwir
corr = Double.NaN; corr = Double.NaN;
if (debug) System.out.println("difference max - min="+(mx - mn)+" < "+min_diff+" -> no fo correction"); if (debug) System.out.println("difference max - min="+(mx - mn)+" < "+min_diff+" -> no fo correction");
} }
...@@ -1736,7 +1736,7 @@ public class Correlation2d { ...@@ -1736,7 +1736,7 @@ public class Correlation2d {
double disp = full_disp; double disp = full_disp;
if (!Double.isNaN(corr)) { if (!Double.isNaN(corr)) {
double lim; double lim;
if (bg) { if (bg) { // not used in lwir
lim = full_disp - (full_disp - mn) * lim_overcorr; lim = full_disp - (full_disp - mn) * lim_overcorr;
disp = Math.max(mn - corr, lim); disp = Math.max(mn - corr, lim);
} else { } else {
...@@ -1753,7 +1753,7 @@ public class Correlation2d { ...@@ -1753,7 +1753,7 @@ public class Correlation2d {
public Correlations2dLMA corrLMA( public Correlations2dLMA corrLMA( // USED in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [][] corrs, double [][] corrs,
int pair_mask, // which pairs to process int pair_mask, // which pairs to process
...@@ -1827,7 +1827,161 @@ public class Correlation2d { ...@@ -1827,7 +1827,161 @@ public class Correlation2d {
debug_level); // int debug_level debug_level); // int debug_level
boolean lmaSuccess; boolean lmaSuccess;
if (run_poly_instead) { if (run_poly_instead) { // not used in lwir
lma.getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial
debug_level>3); // boolean debug
lmaSuccess = lma.getPolyFx() != null;
} else {
lma.initVector(
imgdtt_params.lma_adjust_wm, // boolean adjust_wm,
imgdtt_params.lma_adjust_wy, // boolean adjust_wy,
imgdtt_params.lma_adjust_wxy, // boolean adjust_wxy,
imgdtt_params.lma_adjust_ag, // boolean adjust_Ag,
xcenter, // double x0,
imgdtt_params.lma_half_width, // double half_width,
imgdtt_params.lma_cost_wy, // double cost_wy, // cost of non-zero this.all_pars[WYD_INDEX]
imgdtt_params.lma_cost_wxy //double cost_wxy // cost of non-zero this.all_pars[WXY_INDEX]
);
if (debug_level > 1) {
System.out.println("Input data:");
lma.printInputDataFx(false);
}
lmaSuccess = lma.runLma(
imgdtt_params.lma_lambda_initial, // double lambda, // 0.1
imgdtt_params.lma_lambda_scale_good, // double lambda_scale_good,// 0.5
imgdtt_params.lma_lambda_scale_bad, // double lambda_scale_bad, // 8.0
imgdtt_params.lma_lambda_max, // double lambda_max, // 100
imgdtt_params.lma_rms_diff, // double rms_diff, // 0.001
imgdtt_params.lma_num_iter, // int num_iter, // 20
debug_level); // int debug_level)
lma.updateFromVector();
double [] rms = lma.getRMS();
if (debug_level > 0) {
System.out.println("LMA ->"+lmaSuccess+" RMS="+rms[0]+", pure RMS="+rms[1]);
lma.printParams();
}
}
if ((debug_level > 1) && (groups_LMA !=null) && (groups_LMA.length > 0)) {
double [][] y_and_fx = new double [groups_LMA.length * 2][];
double [][] groups_fx = getFitSamples( // just for debug to compare LMA-fitted fx with original data
xcenter, // double xcenter, // preliminary center x in pixels for largest baseline
imgdtt_params.cnvx_hwnd_size, // int hwindow_y, // = window_y.length; // should actually be the same?
imgdtt_params.cnvx_hwnd_size, //int hwindow_x, // = window_x.length;
groups_pairs, // int [][] groups_pairs,
scales, // double [] scales,
group_scale_ind, // int [] group_scale_ind,
lma, // Correlations2dLMA lma,
groups_LMA, // double [][] groups_LMA,
imgdtt_params.cnvx_add3x3, // boolean add3x3,
imgdtt_params.cnvx_weight, // double nc_cost,
debug_level); // int debug_level
String [] titles = new String [groups_LMA.length * 2];
for (int i = 0; i < groups_LMA.length; i++) if (groups_pairs[i][0] > 0){
int base_pair = groups_pairs[i][1];
titles[2 * i] = (isDiagonalPair(base_pair)?"diag":"ortho")+getScaleOfPair(base_pair);
titles[2 * i + 1] = (isDiagonalPair(base_pair)?"diag":"ortho")+getScaleOfPair(base_pair)+"-fit";
y_and_fx[2 * i] = groups_LMA[i];
y_and_fx[2 * i + 1] = groups_fx[i];
}
// String [] titles = {"ortho","diagonal"};
(new ShowDoubleFloatArrays()).showArrays(
y_and_fx,
2 * transform_size-1,
2 * transform_size-1,
true, (run_poly_instead?("mismatch"+pair_mask):"groups")+"_x"+tileX+"_y"+tileY, titles);
}
if (debug_level > 1) {
System.out.println("Input data and approximation:");
lma.printInputDataFx(true);
}
return lmaSuccess? lma: null;
}
public Correlations2dLMA corrLMA( // New for non-square
ImageDttParameters imgdtt_params,
double [][] disparity_distortions, // {d_disp/dx, d_ndisp/dx, d_disp/dy, d_ndisp/dy} for each camera
double [][] corrs,
int pair_mask, // which pairs to process
boolean run_poly_instead, // true - run LMA, false - run 2d polynomial approximation
double xcenter, // preliminary center x in pixels for largest baseline
double vasw_pwr, // value as weight to this power,
int debug_level,
int tileX, // just for debug output
int tileY
)
{
// for quad camera
int [][] groups = new int [GROUPS.length][];
int [] scale_ind = new int [GROUPS.length];
// See which groups exist for current pairs mask
int ng = 0;
ArrayList<Integer> sl = new ArrayList<Integer>();
for (int i = 0; i < GROUPS.length; i++) {
groups[i] = getNumberBaseOfCompatiblePairs(
corrs, // double [][] correlations,
pair_mask, // int pairs_mask,
(GROUPS[i][0] > 0), // boolean diagonal,
GROUPS[i][1]); // int baseline_scale
if (groups[i][0] > 0) {
ng++;
if (!sl.contains(GROUPS[i][1])) {
sl.add(GROUPS[i][1]);
}
scale_ind[i] = sl.indexOf(GROUPS[i][1]);
}
}
if (debug_level > 1) {
System.out.println("corrLMA(): found "+ng+" groups, "+sl.size()+" scales");
}
double [][] groups_LMA = new double [ng][];
int [][] groups_pairs = new int [ng][]; // [ng]{number of combined pairs, index of base pair}
int [] group_scale_ind = new int [ng]; // number of combined pairs, index of base pair
{
int ig = 0;
for (int i = 0; i < groups.length; i++) if (groups[i][0] >0){
groups_LMA[ig] = combineCompatiblePairs(
corrs, // double [][] correlations,
pair_mask, // int pairs_mask,
(GROUPS[i][0] > 0), // boolean diagonal,
GROUPS[i][1]); // int baseline_scale
groups_pairs[ig] = groups[i]; // {number, base_pair_index}
group_scale_ind[ig] = scale_ind[i];
ig++;
}
}
double [] scales = new double [sl.size()];
for (int i = 0; i < scales.length; i++) scales[i] = sl.get(i); // from int to double
Correlations2dLMA lma = new Correlations2dLMA(scales);
if (debug_level > 1) {
for (int i = 0; i < groups_pairs.length; i++) {
System.out.println("Group #"+i+" - "+groups_pairs[i][0]+", type:"+groups_pairs[i][1]);
}
}
addSamples(
xcenter, // double xcenter, // preliminary center x in pixels for largest baseline
imgdtt_params.cnvx_hwnd_size, // int hwindow_y, // = window_y.length; // should actually be the same?
imgdtt_params.cnvx_hwnd_size, //int hwindow_x, // = window_x.length;
vasw_pwr, // double vasw_pwr, // value as weight to this power,
groups_LMA, // double [][] groups_LMA,
groups_pairs, // int [][] groups_pairs,
scales, // double [] scales,
group_scale_ind, // int [] group_scale_ind,
lma, // Correlations2dLMA lma,
imgdtt_params.cnvx_add3x3, // boolean add3x3,
imgdtt_params.cnvx_weight, // double nc_cost,
debug_level); // int debug_level
boolean lmaSuccess;
if (run_poly_instead) { // not used in lwir
lma.getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial lma.getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial
debug_level>3); // boolean debug debug_level>3); // boolean debug
lmaSuccess = lma.getPolyFx() != null; lmaSuccess = lma.getPolyFx() != null;
...@@ -1902,7 +2056,7 @@ public class Correlation2d { ...@@ -1902,7 +2056,7 @@ public class Correlation2d {
} }
// Run for a single horizontal 2d correlation array // Run for a single horizontal 2d correlation array
public Correlations2dLMA corrLMA( public Correlations2dLMA corrLMA( // not used in lwir
ImageDttParameters imgdtt_params, ImageDttParameters imgdtt_params,
double [] corr, double [] corr,
boolean run_poly_instead, // true - run LMA, false - run 2d polynomial approximation boolean run_poly_instead, // true - run LMA, false - run 2d polynomial approximation
...@@ -2025,7 +2179,7 @@ public class Correlation2d { ...@@ -2025,7 +2179,7 @@ public class Correlation2d {
* @return cost packed array, corresponding to the input. selected convex points have weight * @return cost packed array, corresponding to the input. selected convex points have weight
* 1.0, other selected - nc_cost * 1.0, other selected - nc_cost
*/ */
public double [] filterConvex( public double [] filterConvex(// USED in lwir
double [] corr_data, double [] corr_data,
int hwin, int hwin,
int x0c, int x0c,
...@@ -2201,7 +2355,7 @@ public class Correlation2d { ...@@ -2201,7 +2355,7 @@ public class Correlation2d {
return weights; return weights;
} }
public void debug_convex( public void debug_convex( // not used in lwir
boolean [] convex, boolean [] convex,
boolean [] sel, boolean [] sel,
String title) { String title) {
...@@ -2221,7 +2375,7 @@ public class Correlation2d { ...@@ -2221,7 +2375,7 @@ public class Correlation2d {
} }
public void addSamples( public void addSamples(// USED in lwir
double xcenter, // preliminary center x in pixels for largest baseline double xcenter, // preliminary center x in pixels for largest baseline
int hwindow_y, // = window_y.length; // should actually be the same? int hwindow_y, // = window_y.length; // should actually be the same?
int hwindow_x, // = window_x.length; int hwindow_x, // = window_x.length;
...@@ -2373,7 +2527,7 @@ public class Correlation2d { ...@@ -2373,7 +2527,7 @@ public class Correlation2d {
} }
// Mimics addSamples, but reads f(x) values instead of setting them // Mimics addSamples, but reads f(x) values instead of setting them
public double [][] getFitSamples( // just for debug to compare LMA-fitted fx with original data public double [][] getFitSamples( // just for debug to compare LMA-fitted fx with original data // not used in lwir
double xcenter, // preliminary center x in pixels for largest baseline double xcenter, // preliminary center x in pixels for largest baseline
int hwindow_y, // should actually be the same? int hwindow_y, // should actually be the same?
int hwindow_x, int hwindow_x,
...@@ -2458,7 +2612,7 @@ public class Correlation2d { ...@@ -2458,7 +2612,7 @@ public class Correlation2d {
return groups_fitted; return groups_fitted;
} }
public int [] listPairs( public int [] listPairs( // USED in lwir
double [][] correlations, double [][] correlations,
int pairs_mask) { int pairs_mask) {
ArrayList<Integer> pairs = new ArrayList<Integer>(); ArrayList<Integer> pairs = new ArrayList<Integer>();
...@@ -2484,7 +2638,7 @@ public class Correlation2d { ...@@ -2484,7 +2638,7 @@ public class Correlation2d {
* @param debug * @param debug
* @return {center, strength} pair (center is 0 for the correlation center) * @return {center, strength} pair (center is 0 for the correlation center)
*/ */
public double [] getMaxXSOrtho( // // get fractional center using a quadratic polynomial public double [] getMaxXSOrtho( // // get fractional center using a quadratic polynomial // USED in lwir
double [][] correlations, double [][] correlations,
int pairs_mask, int pairs_mask,
double offset, // double offset); double offset, // double offset);
...@@ -2547,7 +2701,7 @@ public class Correlation2d { ...@@ -2547,7 +2701,7 @@ public class Correlation2d {
} }
if (debug) System.out.println(); if (debug) System.out.println();
} }
} else { // use averaging (linear) } else { // use averaging (linear) // not used in lwir
for (int j = 0; j < corr_size; j++){ for (int j = 0; j < corr_size; j++){
corr_1d[j] = 0; corr_1d[j] = 0;
for (int ip = 0; ip < pairs.length; ip++) { for (int ip = 0; ip < pairs.length; ip++) {
...@@ -2583,7 +2737,7 @@ public class Correlation2d { ...@@ -2583,7 +2737,7 @@ public class Correlation2d {
} }
if (debug) System.out.println(); if (debug) System.out.println();
} }
} else { // use averaging (linear) } else { // use averaging (linear) // not used in lwir
for (int j = 0; j < corr_size; j++){ for (int j = 0; j < corr_size; j++){
corr_1d[j] = 0; corr_1d[j] = 0;
for (int ip = 0; ip < pairs.length; ip++) { for (int ip = 0; ip < pairs.length; ip++) {
...@@ -2636,7 +2790,7 @@ public class Correlation2d { ...@@ -2636,7 +2790,7 @@ public class Correlation2d {
} }
public void createOrtoNotch( public void createOrtoNotch( // USED in lwir
double enhortho_width, double enhortho_width,
double enhortho_scale, double enhortho_scale,
boolean debug) { boolean debug) {
......
package com.elphel.imagej.tileprocessor; package com.elphel.imagej.tileprocessor;
/** /**
** **
** Correlation2dLMA - Fit multi - baseline correaltion pairs to the model ** Correlation2dLMA - Fit multi - baseline correlation pairs to the model
** **
** Copyright (C) 2018 Elphel, Inc. ** Copyright (C) 2018 Elphel, Inc.
** **
...@@ -84,7 +84,7 @@ public class Correlations2dLMA { ...@@ -84,7 +84,7 @@ public class Correlations2dLMA {
double [] poly_coeff = null; // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...) double [] poly_coeff = null; // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
double [] poly_xyvwh = null; // result of 2-d polynomial approximation instead of the LMA - used for lazy eye correction double [] poly_xyvwh = null; // result of 2-d polynomial approximation instead of the LMA - used for lazy eye correction
public class NumDiag{ public class NumDiag{ // USED in lwir
int num; int num;
boolean diag; boolean diag;
public NumDiag(int num, boolean diag) { public NumDiag(int num, boolean diag) {
...@@ -93,7 +93,7 @@ public class Correlations2dLMA { ...@@ -93,7 +93,7 @@ public class Correlations2dLMA {
} }
} }
public class Sample{ public class Sample{ // USED in lwir
double x; // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis double x; // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double y; // y coordinate (0 - disparity axis) double y; // y coordinate (0 - disparity axis)
double v; // correlation value at that point double v; // correlation value at that point
...@@ -117,7 +117,7 @@ public class Correlations2dLMA { ...@@ -117,7 +117,7 @@ public class Correlations2dLMA {
} }
} }
public void printParams() { public void printParams() { // not used in lwir
for (int np = 0; np < all_pars.length; np++) { for (int np = 0; np < all_pars.length; np++) {
System.out.println(String.format("%2d%1s %22s %f", System.out.println(String.format("%2d%1s %22s %f",
np, np,
...@@ -127,7 +127,7 @@ public class Correlations2dLMA { ...@@ -127,7 +127,7 @@ public class Correlations2dLMA {
} }
} }
public void printInputDataFx(boolean show_fx){ public void printInputDataFx(boolean show_fx){ // not used in lwir
if (show_fx) { if (show_fx) {
Sample s = null; Sample s = null;
double [] fx = getPolyFx(); double [] fx = getPolyFx();
...@@ -151,18 +151,18 @@ public class Correlations2dLMA { ...@@ -151,18 +151,18 @@ public class Correlations2dLMA {
} }
} }
public double [] getRMS() { public double [] getRMS() { // USED in lwir
return last_rms; return last_rms;
} }
public double [] getGoodOrBadRMS() { public double [] getGoodOrBadRMS() { // not used in lwir
return good_or_bad_rms; return good_or_bad_rms;
} }
public double [] getAllPars() { public double [] getAllPars() { // not used in lwir
return all_pars; return all_pars;
} }
public double [] getDisparityStrength() { public double [] getDisparityStrength() { // USED in lwir
if (group_weights == null) return null; if (group_weights == null) return null;
double disparity = -all_pars[X0_INDEX]; double disparity = -all_pars[X0_INDEX];
double sum_amp = 0.0; double sum_amp = 0.0;
...@@ -176,7 +176,7 @@ public class Correlations2dLMA { ...@@ -176,7 +176,7 @@ public class Correlations2dLMA {
double [] ds = {disparity, sum_amp}; double [] ds = {disparity, sum_amp};
return ds; return ds;
} }
public double [] getDisparityStrengthWidth() { public double [] getDisparityStrengthWidth() { // USED in lwir
double [] ds = getDisparityStrength(); double [] ds = getDisparityStrength();
if (ds == null) return null; if (ds == null) return null;
double [] dsw = {ds[0], ds[1], all_pars[WM_INDEX], all_pars[WXY_INDEX]}; // asymmetry double [] dsw = {ds[0], ds[1], all_pars[WM_INDEX], all_pars[WXY_INDEX]}; // asymmetry
...@@ -184,16 +184,16 @@ public class Correlations2dLMA { ...@@ -184,16 +184,16 @@ public class Correlations2dLMA {
} }
public Correlations2dLMA ( public Correlations2dLMA ( // USED in lwir
double [] scales // null - use default table double [] scales // null - use default table
) { ) {
if (scales != null) this.scales = scales.clone(); if (scales != null) this.scales = scales.clone();
} }
public void setDiag(boolean diag_in) { public void setDiag(boolean diag_in) { // USED in lwir
this.input_diag = diag_in; this.input_diag = diag_in;
} }
public void addSample( public void addSample( // USED in lwir
double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis double x, // x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double y, // y coordinate (0 - disparity axis) double y, // y coordinate (0 - disparity axis)
double v, // correlation value at that point double v, // correlation value at that point
...@@ -209,7 +209,7 @@ public class Correlations2dLMA { ...@@ -209,7 +209,7 @@ public class Correlations2dLMA {
//NumDiag //NumDiag
// TODO: add auto x0, half-width? // TODO: add auto x0, half-width?
// should be called ater all samples are entered (to list groups) // should be called ater all samples are entered (to list groups)
public void initVector( public void initVector( // USED in lwir
boolean adjust_wm, boolean adjust_wm,
boolean adjust_wy, boolean adjust_wy,
boolean adjust_wxy, boolean adjust_wxy,
...@@ -242,7 +242,7 @@ public class Correlations2dLMA { ...@@ -242,7 +242,7 @@ public class Correlations2dLMA {
toVector(); toVector();
} }
public void setWeightsValues( public void setWeightsValues( // USED in lwir
double half_width, // expected width double half_width, // expected width
double cost_wm, // cost of non-zero this.all_pars[WYD_INDEX] double cost_wm, // cost of non-zero this.all_pars[WYD_INDEX]
double cost_wxy) { // cost of non-zero this.all_pars[WXY_INDEX] double cost_wxy) { // cost of non-zero this.all_pars[WXY_INDEX]
...@@ -260,7 +260,7 @@ public class Correlations2dLMA { ...@@ -260,7 +260,7 @@ public class Correlations2dLMA {
weights[i] = s.w; weights[i] = s.w;
values[i] = s.v; values[i] = s.v;
group_weights[groups.get(s.gi).num] += s.w; group_weights[groups.get(s.gi).num] += s.w;
if (Double.isNaN(values[i]) || Double.isNaN(weights[i])) { if (Double.isNaN(values[i]) || Double.isNaN(weights[i])) { // not used in lwir
weights[i] = 0.0; weights[i] = 0.0;
values[i] = 0.0; values[i] = 0.0;
} }
...@@ -277,7 +277,7 @@ public class Correlations2dLMA { ...@@ -277,7 +277,7 @@ public class Correlations2dLMA {
pure_weight *= sw; pure_weight *= sw;
} }
public void toVector() { public void toVector() { // USED in lwir
int np = 0; int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) np++; for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) np++;
vector = new double[np]; vector = new double[np];
...@@ -285,12 +285,12 @@ public class Correlations2dLMA { ...@@ -285,12 +285,12 @@ public class Correlations2dLMA {
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) vector[np++] = all_pars[i]; for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) vector[np++] = all_pars[i];
} }
public void updateFromVector() { public void updateFromVector() { // USED in lwir
int np = 0; int np = 0;
for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) all_pars[i] = vector[np++]; for (int i = 0; i < par_mask.length; i++) if (par_mask[i]) all_pars[i] = vector[np++];
} }
public double [] fromVector(double [] vector) { // mix fixed and variable parameters public double [] fromVector(double [] vector) { // mix fixed and variable parameters // USED in lwir
if ( all_pars == null) return null; if ( all_pars == null) return null;
double [] ap = all_pars.clone(); double [] ap = all_pars.clone();
int np = 0; int np = 0;
...@@ -298,7 +298,7 @@ public class Correlations2dLMA { ...@@ -298,7 +298,7 @@ public class Correlations2dLMA {
return ap; return ap;
} }
public void debugJt( public void debugJt( // not used in lwir
double delta, double delta,
double [] vector) { double [] vector) {
int num_points = this.values.length; int num_points = this.values.length;
...@@ -338,7 +338,7 @@ public class Correlations2dLMA { ...@@ -338,7 +338,7 @@ public class Correlations2dLMA {
} }
public double [] getFxJt( public double [] getFxJt( // not used in lwir
double delta, // for testing derivatives: calculates as delta-F/delta_x double delta, // for testing derivatives: calculates as delta-F/delta_x
double [] vector, double [] vector,
double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
...@@ -361,11 +361,11 @@ public class Correlations2dLMA { ...@@ -361,11 +361,11 @@ public class Correlations2dLMA {
public double [] getFx() { public double [] getFx() { // not used in lwir
return getFxJt(this.vector, null); return getFxJt(this.vector, null);
} }
public double [] getFxJt( public double [] getFxJt( // USED in lwir
double [] vector, double [] vector,
double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated double [][] jt) { // should be either [vector.length][samples.size()] or null - then only fx is calculated
if (vector == null) return null; if (vector == null) return null;
...@@ -415,7 +415,7 @@ public class Correlations2dLMA { ...@@ -415,7 +415,7 @@ public class Correlations2dLMA {
return fx; return fx;
} }
public double [][] getWJtJlambda( public double [][] getWJtJlambda( // USED in lwir
double lambda, double lambda,
double [][] jt){ double [][] jt){
int num_pars = jt.length; int num_pars = jt.length;
...@@ -439,7 +439,7 @@ public class Correlations2dLMA { ...@@ -439,7 +439,7 @@ public class Correlations2dLMA {
} }
// returns {rms, rms_pure} // returns {rms, rms_pure}
public double [] getWYmFxRms( public double [] getWYmFxRms( // USED in lwir
double [] fx) { // will be replaced with y-fx double [] fx) { // will be replaced with y-fx
int num_samples = samples.size(); int num_samples = samples.size();
int num_points = fx.length; // includes 2 extra for regularization int num_points = fx.length; // includes 2 extra for regularization
...@@ -460,7 +460,7 @@ public class Correlations2dLMA { ...@@ -460,7 +460,7 @@ public class Correlations2dLMA {
return rslt; return rslt;
} }
public double [] getJtWdiff( public double [] getJtWdiff( // not used in lwir
double [] wdiff, double [] wdiff,
double [][] jt){ double [][] jt){
int num_pars = jt.length; int num_pars = jt.length;
...@@ -474,7 +474,7 @@ public class Correlations2dLMA { ...@@ -474,7 +474,7 @@ public class Correlations2dLMA {
return wjtymfx; return wjtymfx;
} }
public boolean runLma( public boolean runLma( // USED in lwir
double lambda, // 0.1 double lambda, // 0.1
double lambda_scale_good,// 0.5 double lambda_scale_good,// 0.5
double lambda_scale_bad, // 8.0 double lambda_scale_bad, // 8.0
...@@ -502,7 +502,7 @@ public class Correlations2dLMA { ...@@ -502,7 +502,7 @@ public class Correlations2dLMA {
} else { } else {
lambda *= lambda_scale_bad; lambda *= lambda_scale_bad;
if (lambda > lambda_max) { if (lambda > lambda_max) {
break; break; // not used in lwir
} }
} }
} }
...@@ -530,7 +530,7 @@ public class Correlations2dLMA { ...@@ -530,7 +530,7 @@ public class Correlations2dLMA {
// returns {success, done} // returns {success, done}
public boolean [] lmaStep( public boolean [] lmaStep( // USED in lwir
double lambda, double lambda,
double rms_diff, double rms_diff,
int debug_level) { int debug_level) {
...@@ -640,7 +640,7 @@ public class Correlations2dLMA { ...@@ -640,7 +640,7 @@ public class Correlations2dLMA {
} }
// modify to reuse Samples and apply polynomial approximation to resolve x0,y0 and strength? // modify to reuse Samples and apply polynomial approximation to resolve x0,y0 and strength?
public double [] getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial public double [] getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial // not used in lwir
/// double outside, // how much solution may be outside of the samples /// double outside, // how much solution may be outside of the samples
boolean debug boolean debug
) { ) {
...@@ -703,11 +703,11 @@ public class Correlations2dLMA { ...@@ -703,11 +703,11 @@ public class Correlations2dLMA {
this.poly_xyvwh = xyvwh; this.poly_xyvwh = xyvwh;
return xyvwh; // rslt; return xyvwh; // rslt;
} }
public double [] getPoly() { public double [] getPoly() { // not used in lwir
return poly_xyvwh; return poly_xyvwh;
} }
public double [] getPolyFx() {return getPolyFx(this.poly_coeff);} public double [] getPolyFx() {return getPolyFx(this.poly_coeff);} // not used in lwir
public double [] getPolyFx( public double [] getPolyFx( // not used in lwir
double [] coeff) { // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...) double [] coeff) { // 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
if (coeff == null) { if (coeff == null) {
return null; return null;
......
...@@ -91,7 +91,7 @@ public class GeometryCorrection { ...@@ -91,7 +91,7 @@ public class GeometryCorrection {
public RigOffset rigOffset = null; public RigOffset rigOffset = null;
public int [] woi_tops; // used to calculate scanline timing public int [] woi_tops; // used to calculate scanline timing
public int [] getWOITops() { public int [] getWOITops() {// not used in lwir
return woi_tops; return woi_tops;
} }
...@@ -126,47 +126,47 @@ public class GeometryCorrection { ...@@ -126,47 +126,47 @@ public class GeometryCorrection {
public double getDisparityRadius() { public double getDisparityRadius() {
return disparityRadius; return disparityRadius;
} }
public double getBaseline() { public double getBaseline() {// not used in lwir
return (rigOffset==null)?Double.NaN:rigOffset.baseline; return (rigOffset==null)?Double.NaN:rigOffset.baseline;
} }
public double [][] getAuxOffsetAndDerivatives( public double [][] getAuxOffsetAndDerivatives(// not used in lwir
GeometryCorrection gc_main) { GeometryCorrection gc_main) {
if (rigOffset == null) return null; if (rigOffset == null) return null;
return rigOffset.getAuxOffsetAndDerivatives(gc_main); return rigOffset.getAuxOffsetAndDerivatives(gc_main);
} }
public Matrix getAuxRotMatrix() { public Matrix getAuxRotMatrix() {// not used in lwir
if (rigOffset == null) return null; if (rigOffset == null) return null;
return rigOffset.getRotMatrix(); return rigOffset.getRotMatrix();
} }
public Matrix [] getAuxRotDeriveMatrices() { public Matrix [] getAuxRotDeriveMatrices() {// not used in lwir
if (rigOffset == null) return null; if (rigOffset == null) return null;
return rigOffset.getRotDeriveMatrices(); return rigOffset.getRotDeriveMatrices();
} }
public RigOffset rigOffsetClone() { public RigOffset rigOffsetClone() {// not used in lwir
if (rigOffset == null) return null; if (rigOffset == null) return null;
return rigOffset.clone(); return rigOffset.clone();
} }
public void rigOffestSetParNorm(int index, double value) { public void rigOffestSetParNorm(int index, double value) {// not used in lwir
rigOffset.setParNorm(index, value); rigOffset.setParNorm(index, value);
} }
public void rigOffestSetParNorm(RigOffset ro, int index, double value) { public void rigOffestSetParNorm(RigOffset ro, int index, double value) {// not used in lwir
ro. setParNorm(index, value); ro. setParNorm(index, value);
} }
public double rigOffestGetParNorm(int index) { public double rigOffestGetParNorm(int index) {// not used in lwir
return rigOffset.getParNorm(index); return rigOffset.getParNorm(index);
} }
public double rigOffestGetParNorm(RigOffset ro, int index) { public double rigOffestGetParNorm(RigOffset ro, int index) {// not used in lwir
return ro.getParNorm(index); return ro.getParNorm(index);
} }
public double [] getRigCorrection( public double [] getRigCorrection(// not used in lwir
double infinity_importance, // of all measurements double infinity_importance, // of all measurements
double dx_max, // = 0.3; double dx_max, // = 0.3;
double dx_pow, // = 1.0; double dx_pow, // = 1.0;
...@@ -208,7 +208,7 @@ public class GeometryCorrection { ...@@ -208,7 +208,7 @@ public class GeometryCorrection {
} }
// correction of cameras mis-alignment // correction of cameras mis-alignment
public CorrVector getCorrVector(double [] vector){ public CorrVector getCorrVector(double [] vector){// not used in lwir
return new CorrVector(vector); return new CorrVector(vector);
} }
public CorrVector getCorrVector( public CorrVector getCorrVector(
...@@ -225,7 +225,7 @@ public class GeometryCorrection { ...@@ -225,7 +225,7 @@ public class GeometryCorrection {
setCorrVector(new CorrVector(dv)); setCorrVector(new CorrVector(dv));
} }
public void setCorrVector(int indx, double d){ public void setCorrVector(int indx, double d){// not used in lwir
if (getCorrVector().toArray() == null) { if (getCorrVector().toArray() == null) {
resetCorrVector(); resetCorrVector();
} }
...@@ -235,12 +235,12 @@ public class GeometryCorrection { ...@@ -235,12 +235,12 @@ public class GeometryCorrection {
public void setCorrVector(CorrVector vector){ public void setCorrVector(CorrVector vector){
if (vector == null){ if (vector == null){
vector = new CorrVector(); vector = new CorrVector();// not used in lwir
} }
extrinsic_corr = vector; extrinsic_corr = vector;
} }
public void resetCorrVector(){ public void resetCorrVector(){// not used in lwir
extrinsic_corr = new CorrVector(); extrinsic_corr = new CorrVector();
} }
...@@ -316,7 +316,7 @@ public class GeometryCorrection { ...@@ -316,7 +316,7 @@ public class GeometryCorrection {
} }
@Override @Override
public RigOffset clone() { public RigOffset clone() {// not used in lwir
RigOffset ro = new RigOffset(); RigOffset ro = new RigOffset();
ro.baseline = this.baseline; ro.baseline = this.baseline;
ro.aux_angle = this.aux_angle; ro.aux_angle = this.aux_angle;
...@@ -330,7 +330,7 @@ public class GeometryCorrection { ...@@ -330,7 +330,7 @@ public class GeometryCorrection {
return ro; return ro;
} }
public void setParNorm(int index, double value) { public void setParNorm(int index, double value) {// not used in lwir
value /= par_scales[index]; value /= par_scales[index];
switch (index) { switch (index) {
case AUX_AZIMUTH_INDEX: aux_azimuth = value; break; case AUX_AZIMUTH_INDEX: aux_azimuth = value; break;
...@@ -341,7 +341,7 @@ public class GeometryCorrection { ...@@ -341,7 +341,7 @@ public class GeometryCorrection {
case AUX_BASELINE_INDEX: baseline = value; break; case AUX_BASELINE_INDEX: baseline = value; break;
} }
} }
public double getParNorm(int index) { public double getParNorm(int index) {// not used in lwir
switch (index) { switch (index) {
case AUX_AZIMUTH_INDEX: return aux_azimuth * par_scales[index]; case AUX_AZIMUTH_INDEX: return aux_azimuth * par_scales[index];
case AUX_TILT_INDEX: return aux_tilt * par_scales[index]; case AUX_TILT_INDEX: return aux_tilt * par_scales[index];
...@@ -354,7 +354,7 @@ public class GeometryCorrection { ...@@ -354,7 +354,7 @@ public class GeometryCorrection {
} }
public void setVector( public void setVector(// not used in lwir
boolean adjust_orientation, boolean adjust_orientation,
boolean adjust_roll, boolean adjust_roll,
boolean adjust_zoom, boolean adjust_zoom,
...@@ -371,7 +371,7 @@ public class GeometryCorrection { ...@@ -371,7 +371,7 @@ public class GeometryCorrection {
par_select[AUX_BASELINE_INDEX] = adjust_distance; par_select[AUX_BASELINE_INDEX] = adjust_distance;
setVector(); setVector();
} }
public void setVector() { public void setVector() {// not used in lwir
int num_pars = 0; int num_pars = 0;
for (int i = 0; i < par_select.length; i++) if (par_select[i]) num_pars++; for (int i = 0; i < par_select.length; i++) if (par_select[i]) num_pars++;
vector = new double[num_pars]; vector = new double[num_pars];
...@@ -392,7 +392,7 @@ public class GeometryCorrection { ...@@ -392,7 +392,7 @@ public class GeometryCorrection {
} }
//full_par_index //full_par_index
} }
public void commitVector(double [] v) { public void commitVector(double [] v) {// not used in lwir
vector = v; vector = v;
int par_index = 0; int par_index = 0;
for (int i = 0; i < par_select.length; i++) if (par_select[i]) { for (int i = 0; i < par_select.length; i++) if (par_select[i]) {
...@@ -409,7 +409,7 @@ public class GeometryCorrection { ...@@ -409,7 +409,7 @@ public class GeometryCorrection {
recalcRXY(); recalcRXY();
} }
double [][] getJacobianTransposed( double [][] getJacobianTransposed(// not used in lwir
GeometryCorrection gc_main, GeometryCorrection gc_main,
int debugLevel){ int debugLevel){
double [][] jt = new double[vector.length][xy_vector.length]; // npe double [][] jt = new double[vector.length][xy_vector.length]; // npe
...@@ -440,7 +440,7 @@ public class GeometryCorrection { ...@@ -440,7 +440,7 @@ public class GeometryCorrection {
} }
// dbug method; // dbug method;
double [][] getJacobianTransposed( double [][] getJacobianTransposed(// not used in lwir
double delta, double delta,
GeometryCorrection gc_main, GeometryCorrection gc_main,
int debugLevel){ int debugLevel){
...@@ -498,7 +498,7 @@ public class GeometryCorrection { ...@@ -498,7 +498,7 @@ public class GeometryCorrection {
double [][] getJTJWeighted( double [][] getJTJWeighted(// not used in lwir
double [][] jt) double [][] jt)
{ {
double [][] jtj = new double [jt.length][jt.length]; double [][] jtj = new double [jt.length][jt.length];
...@@ -515,7 +515,7 @@ public class GeometryCorrection { ...@@ -515,7 +515,7 @@ public class GeometryCorrection {
return jtj; return jtj;
} }
double [] getJTYWeighted(double [][] jt) { double [] getJTYWeighted(double [][] jt) {// not used in lwir
double [] jtyw = new double [jt.length]; double [] jtyw = new double [jt.length];
for (int i = 0; i < jt.length; i++){ for (int i = 0; i < jt.length; i++){
for (int k=0; k < jt[i].length; k++){ for (int k=0; k < jt[i].length; k++){
...@@ -525,7 +525,7 @@ public class GeometryCorrection { ...@@ -525,7 +525,7 @@ public class GeometryCorrection {
return jtyw; return jtyw;
} }
public double [] getRigCorrection( public double [] getRigCorrection(// not used in lwir
double infinity_importance, // of all measurements double infinity_importance, // of all measurements
double dx_max, // = 0.3; double dx_max, // = 0.3;
double dx_pow, // = 1.0; double dx_pow, // = 1.0;
...@@ -649,7 +649,7 @@ public class GeometryCorrection { ...@@ -649,7 +649,7 @@ public class GeometryCorrection {
return vector; return vector;
} }
public double setupYW( public double setupYW(// not used in lwir
double infinity_importance, // of all measurements double infinity_importance, // of all measurements
double dx_max, // = 0.3; double dx_max, // = 0.3;
double dx_pow, // = 1.0; double dx_pow, // = 1.0;
...@@ -744,7 +744,7 @@ public class GeometryCorrection { ...@@ -744,7 +744,7 @@ public class GeometryCorrection {
return Math.sqrt(sum2); // RMS return Math.sqrt(sum2); // RMS
} }
public void recalcRXY() { public void recalcRXY() {// USED in lwir
if (rXY != null) { if (rXY != null) {
// rXY_aux = rXY; // FIXME: put real stuff !!! // rXY_aux = rXY; // FIXME: put real stuff !!!
double xc_pix = baseline * Math.cos(aux_angle)/getDisparityRadius(); double xc_pix = baseline * Math.cos(aux_angle)/getDisparityRadius();
...@@ -769,7 +769,7 @@ public class GeometryCorrection { ...@@ -769,7 +769,7 @@ public class GeometryCorrection {
* @param gc_main Instance of the main camera GeometryCorrection class * @param gc_main Instance of the main camera GeometryCorrection class
* @return {{xc, yc},{dxc/dAngle,dyc/dAngle},{dxc/dBaseline,dyc/dBaseline}} * @return {{xc, yc},{dxc/dAngle,dyc/dAngle},{dxc/dBaseline,dyc/dBaseline}}
*/ */
public double [][] getAuxOffsetAndDerivatives( public double [][] getAuxOffsetAndDerivatives(// not used in lwir
GeometryCorrection gc_main) { GeometryCorrection gc_main) {
double blp = baseline /gc_main.getDisparityRadius(); double blp = baseline /gc_main.getDisparityRadius();
double xc_pix = blp * Math.cos(aux_angle); double xc_pix = blp * Math.cos(aux_angle);
...@@ -786,7 +786,7 @@ public class GeometryCorrection { ...@@ -786,7 +786,7 @@ public class GeometryCorrection {
return rslt; return rslt;
} }
public Matrix getRotMatrix() public Matrix getRotMatrix() // USED in lwir
{ {
double ca = Math.cos(aux_azimuth); double ca = Math.cos(aux_azimuth);
double sa = Math.sin(aux_azimuth); double sa = Math.sin(aux_azimuth);
...@@ -820,7 +820,7 @@ public class GeometryCorrection { ...@@ -820,7 +820,7 @@ public class GeometryCorrection {
* @return 2-d array array of derivatives matrices * @return 2-d array array of derivatives matrices
*/ */
//TODO: UPDATE to include scales //TODO: UPDATE to include scales
public Matrix [] getRotDeriveMatrices() public Matrix [] getRotDeriveMatrices()// not used in lwir
{ {
Matrix [] rot_derivs = new Matrix [4]; // channel, azimuth-tilt-roll-zoom Matrix [] rot_derivs = new Matrix [4]; // channel, azimuth-tilt-roll-zoom
...@@ -879,7 +879,7 @@ public class GeometryCorrection { ...@@ -879,7 +879,7 @@ public class GeometryCorrection {
public void setProperties(String parent_prefix,Properties properties){ public void setProperties(String parent_prefix,Properties properties){// USED in lwir
String prefix = parent_prefix + RIG_PREFIX; String prefix = parent_prefix + RIG_PREFIX;
properties.setProperty(prefix+"baseline", this.baseline+""); properties.setProperty(prefix+"baseline", this.baseline+"");
properties.setProperty(prefix+"aux_angle", this.aux_angle+""); properties.setProperty(prefix+"aux_angle", this.aux_angle+"");
...@@ -889,7 +889,7 @@ public class GeometryCorrection { ...@@ -889,7 +889,7 @@ public class GeometryCorrection {
properties.setProperty(prefix+"aux_roll", this.aux_roll+""); properties.setProperty(prefix+"aux_roll", this.aux_roll+"");
properties.setProperty(prefix+"aux_zoom", this.aux_zoom+""); properties.setProperty(prefix+"aux_zoom", this.aux_zoom+"");
} }
public boolean getProperties(String parent_prefix,Properties properties){ public boolean getProperties(String parent_prefix,Properties properties){// USED in lwir
String prefix = parent_prefix + RIG_PREFIX; String prefix = parent_prefix + RIG_PREFIX;
boolean got_data = false; boolean got_data = false;
if (properties.getProperty(prefix+"baseline")!=null) {this.baseline=Double.parseDouble(properties.getProperty(prefix+"baseline")); got_data=true;} if (properties.getProperty(prefix+"baseline")!=null) {this.baseline=Double.parseDouble(properties.getProperty(prefix+"baseline")); got_data=true;}
...@@ -903,7 +903,7 @@ public class GeometryCorrection { ...@@ -903,7 +903,7 @@ public class GeometryCorrection {
return got_data; return got_data;
} }
// 9:%8.5f° 10: %8.5f‰ // 9:%8.5f° 10: %8.5f‰
public boolean editOffsetsDegrees() { public boolean editOffsetsDegrees() {// not used in lwir
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",800,900); GenericJTabbedDialog gd = new GenericJTabbedDialog("Set CLT parameters",800,900);
gd.addNumericField("Baseline", this.baseline, 1,6,"mm", gd.addNumericField("Baseline", this.baseline, 1,6,"mm",
"Distance between quad camera centers"); "Distance between quad camera centers");
...@@ -931,7 +931,7 @@ public class GeometryCorrection { ...@@ -931,7 +931,7 @@ public class GeometryCorrection {
recalcRXY(); recalcRXY();
return true; return true;
} }
public boolean editOffsetsPixels() { public boolean editOffsetsPixels() {// not used in lwir
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set dual camera rig parameters (auxiliary camera relative to the main one)",800,300); GenericJTabbedDialog gd = new GenericJTabbedDialog("Set dual camera rig parameters (auxiliary camera relative to the main one)",800,300);
gd.addNumericField("Baseline", this.baseline, 1,6,"mm", gd.addNumericField("Baseline", this.baseline, 1,6,"mm",
"Distance between quad camera centers"); "Distance between quad camera centers");
...@@ -959,7 +959,7 @@ public class GeometryCorrection { ...@@ -959,7 +959,7 @@ public class GeometryCorrection {
recalcRXY(); recalcRXY();
return true; return true;
} }
public void showRigOffsets() public void showRigOffsets()// not used in lwir
{ {
System.out.println("=== Inter-camera adjustments ==="); System.out.println("=== Inter-camera adjustments ===");
System.out.println(" Baseline "+ this.baseline +"mm"); System.out.println(" Baseline "+ this.baseline +"mm");
...@@ -971,7 +971,7 @@ public class GeometryCorrection { ...@@ -971,7 +971,7 @@ public class GeometryCorrection {
System.out.println(" Relative zoom - difference from 1.0 in parts parts per 1/1000 "+ (par_scales[AUX_ZOOM_INDEX] * this.aux_zoom) +"pix"); System.out.println(" Relative zoom - difference from 1.0 in parts parts per 1/1000 "+ (par_scales[AUX_ZOOM_INDEX] * this.aux_zoom) +"pix");
} }
public double getRigOffsetParameter(int indx, boolean inPix) public double getRigOffsetParameter(int indx, boolean inPix)// not used in lwir
{ {
if ((indx <0.0) || (indx >=par_scales.length)){ if ((indx <0.0) || (indx >=par_scales.length)){
return Double.NaN; return Double.NaN;
...@@ -990,25 +990,25 @@ public class GeometryCorrection { ...@@ -990,25 +990,25 @@ public class GeometryCorrection {
} }
public boolean editRig() { public boolean editRig() {// not used in lwir
if (this.rigOffset == null) { if (this.rigOffset == null) {
this.rigOffset = new RigOffset(); this.rigOffset = new RigOffset();
} }
return this.rigOffset.editOffsetsPixels(); return this.rigOffset.editOffsetsPixels();
} }
public void showRig() { public void showRig() {// not used in lwir
if (this.rigOffset == null) { if (this.rigOffset == null) {
this.rigOffset = new RigOffset(); this.rigOffset = new RigOffset();
} }
this.rigOffset.showRigOffsets(); this.rigOffset.showRigOffsets();
} }
public double getRigOffsetParameter(int indx, boolean inPix) { public double getRigOffsetParameter(int indx, boolean inPix) {// not used in lwir
return this.rigOffset.getRigOffsetParameter(indx,inPix); return this.rigOffset.getRigOffsetParameter(indx,inPix);
} }
public boolean setRigOffsetFromProperies(String parent_prefix,Properties properties) { public boolean setRigOffsetFromProperies(String parent_prefix,Properties properties) {// USED in lwir
RigOffset rigOffset = new RigOffset(); RigOffset rigOffset = new RigOffset();
boolean gotit = rigOffset.getProperties(parent_prefix, properties); boolean gotit = rigOffset.getProperties(parent_prefix, properties);
if (gotit) { if (gotit) {
...@@ -1030,7 +1030,7 @@ public class GeometryCorrection { ...@@ -1030,7 +1030,7 @@ public class GeometryCorrection {
static final double ROT_RL_SGN = 1.0; // sign of first sin for roll rotation static final double ROT_RL_SGN = 1.0; // sign of first sin for roll rotation
double [] vector; double [] vector;
public Matrix [] getRotMatrices(Matrix rigMatrix) public Matrix [] getRotMatrices(Matrix rigMatrix)// USED in lwir
{ {
Matrix [] rots = getRotMatrices(); Matrix [] rots = getRotMatrices();
if (rigMatrix != null) { if (rigMatrix != null) {
...@@ -1043,7 +1043,7 @@ public class GeometryCorrection { ...@@ -1043,7 +1043,7 @@ public class GeometryCorrection {
} }
// not yet used // not yet used
public Matrix [][] getRotDeriveMatrices(Matrix rigMatrix) public Matrix [][] getRotDeriveMatrices(Matrix rigMatrix)// not used in lwir
{ {
Matrix [][] derivs = getRotDeriveMatrices(); Matrix [][] derivs = getRotDeriveMatrices();
if (rigMatrix != null) { if (rigMatrix != null) {
...@@ -1057,7 +1057,7 @@ public class GeometryCorrection { ...@@ -1057,7 +1057,7 @@ public class GeometryCorrection {
return derivs; return derivs;
} }
public Matrix [] getRotMatrices() public Matrix [] getRotMatrices() // USED in lwir
{ {
Matrix [] rots = new Matrix [4]; Matrix [] rots = new Matrix [4];
double [] azimuths = getAzimuths(); double [] azimuths = getAzimuths();
...@@ -1097,7 +1097,7 @@ public class GeometryCorrection { ...@@ -1097,7 +1097,7 @@ public class GeometryCorrection {
* @return 2-d array array of derivatives matrices * @return 2-d array array of derivatives matrices
*/ */
//TODO: UPDATE to include scales //TODO: UPDATE to include scales
public Matrix [][] getRotDeriveMatrices() public Matrix [][] getRotDeriveMatrices() // USED in lwir
{ {
Matrix [][] rot_derivs = new Matrix [4][4]; // channel, azimuth-tilt-roll-zoom Matrix [][] rot_derivs = new Matrix [4][4]; // channel, azimuth-tilt-roll-zoom
double [] azimuths = getAzimuths(); double [] azimuths = getAzimuths();
...@@ -1166,12 +1166,12 @@ public class GeometryCorrection { ...@@ -1166,12 +1166,12 @@ public class GeometryCorrection {
public CorrVector () public CorrVector ()// USED in lwir
{ {
this.vector = new double[LENGTH]; this.vector = new double[LENGTH];
} }
public CorrVector ( public CorrVector (// USED in lwir
double [] sym_vector, double [] sym_vector,
boolean [] par_mask) boolean [] par_mask)
{ {
...@@ -1179,7 +1179,7 @@ public class GeometryCorrection { ...@@ -1179,7 +1179,7 @@ public class GeometryCorrection {
} }
public CorrVector ( public CorrVector (// not used in lwir
double tilt0, double tilt1, double tilt2, double tilt0, double tilt1, double tilt2,
double azimuth0, double azimuth1, double azimuth2, double azimuth0, double azimuth1, double azimuth2,
double roll0, double roll1, double roll2, double roll3, double roll0, double roll1, double roll2, double roll3,
...@@ -1199,11 +1199,11 @@ public class GeometryCorrection { ...@@ -1199,11 +1199,11 @@ public class GeometryCorrection {
if (vector != null) { if (vector != null) {
if (vector.length != LENGTH) { if (vector.length != LENGTH) {
throw new IllegalArgumentException("vector.length = "+vector.length+" != "+LENGTH); throw new IllegalArgumentException("vector.length = "+vector.length+" != "+LENGTH);// not used in lwir
} }
this.vector = vector; this.vector = vector;
} else { } else {
this.vector = new double[LENGTH]; this.vector = new double[LENGTH];// not used in lwir
} }
} }
/** /**
...@@ -1213,7 +1213,7 @@ public class GeometryCorrection { ...@@ -1213,7 +1213,7 @@ public class GeometryCorrection {
* @param roll for subcameras 0..3, radians, positive - CW looking to the target * @param roll for subcameras 0..3, radians, positive - CW looking to the target
* @param zoom for subcameras 0..2, difference from 1.0 . Positive - image is too small, needs to be zoomed in by (1.0 + scale) * @param zoom for subcameras 0..2, difference from 1.0 . Positive - image is too small, needs to be zoomed in by (1.0 + scale)
*/ */
public CorrVector (double [] tilt, double [] azimuth, double [] roll, double [] zoom) public CorrVector (double [] tilt, double [] azimuth, double [] roll, double [] zoom)// not used in lwir
{ {
double [] vector = { double [] vector = {
tilt[0], tilt[1], tilt[2], tilt[0], tilt[1], tilt[2],
...@@ -1223,59 +1223,59 @@ public class GeometryCorrection { ...@@ -1223,59 +1223,59 @@ public class GeometryCorrection {
this.vector = vector; this.vector = vector;
} }
public CorrVector getCorrVector(double [] vector){ public CorrVector getCorrVector(double [] vector){// not used in lwir
return new CorrVector(vector); return new CorrVector(vector);
} }
public double [] toArray() public double [] toArray() // USED in lwir
{ {
return vector; return vector;
} }
public double [] getTilts() public double [] getTilts() // USED in lwir
{ {
double [] tilts = {vector[0], vector[1], vector[2], - (vector[0] + vector[1] +vector[2])}; double [] tilts = {vector[0], vector[1], vector[2], - (vector[0] + vector[1] +vector[2])};
return tilts; return tilts;
} }
public double getTilt(int indx) public double getTilt(int indx) // not used in lwir
{ {
if (indx == 3) return - (vector[0] + vector[1] +vector[2]); if (indx == 3) return - (vector[0] + vector[1] +vector[2]);
else return vector[0 + indx]; else return vector[0 + indx];
} }
public double [] getAzimuths() public double [] getAzimuths() // USED in lwir
{ {
double [] azimuths = {vector[3], vector[4], vector[5], -(vector[3] + vector[4] + vector[5])}; double [] azimuths = {vector[3], vector[4], vector[5], -(vector[3] + vector[4] + vector[5])};
return azimuths; return azimuths;
} }
public double getAzimuth(int indx) public double getAzimuth(int indx) // not used in lwir
{ {
if (indx == 3) return - (vector[3] + vector[4] +vector[5]); if (indx == 3) return - (vector[3] + vector[4] +vector[5]);
else return vector[3 + indx]; else return vector[3 + indx];
} }
public double [] getRolls() public double [] getRolls() // not used in lwir
{ {
double [] rolls = {vector[6],vector[7],vector[8], vector[9]}; double [] rolls = {vector[6],vector[7],vector[8], vector[9]};
return rolls; return rolls;
} }
public double getRoll(int indx) public double getRoll(int indx) // not used in lwir
{ {
return vector[6 + indx]; return vector[6 + indx];
} }
public double [] getZooms() public double [] getZooms() // USED in lwir
{ {
double [] zooms = {vector[10], vector[11], vector[12], - (vector[10] + vector[11] +vector[12])}; double [] zooms = {vector[10], vector[11], vector[12], - (vector[10] + vector[11] +vector[12])};
return zooms; return zooms;
} }
public double getZoom(int indx) public double getZoom(int indx) // not used in lwir
{ {
if (indx == 3) return - (vector[10] + vector[11] +vector[12]); if (indx == 3) return - (vector[10] + vector[11] +vector[12]);
else return vector[10 + indx]; else return vector[10 + indx];
} }
public double setZoomsFromF(double f0, double f1, double f2, double f3) { public double setZoomsFromF(double f0, double f1, double f2, double f3) { // USED in lwir
double f_avg = (f0+f1+f2+f3)/4; double f_avg = (f0+f1+f2+f3)/4;
vector[10] = (f0 - f_avg)/f_avg; vector[10] = (f0 - f_avg)/f_avg;
vector[11] = (f1 - f_avg)/f_avg; vector[11] = (f1 - f_avg)/f_avg;
...@@ -1284,7 +1284,7 @@ public class GeometryCorrection { ...@@ -1284,7 +1284,7 @@ public class GeometryCorrection {
} }
// Tilts in radians, theta in degrees // Tilts in radians, theta in degrees
public double setTiltsFromThetas(double t0, double t1, double t2, double t3) { public double setTiltsFromThetas(double t0, double t1, double t2, double t3) { // USED in lwir
double t_avg = (t0+t1+t2+t3)/4; double t_avg = (t0+t1+t2+t3)/4;
vector[0] = (t0 - t_avg)*Math.PI/180.0; vector[0] = (t0 - t_avg)*Math.PI/180.0;
vector[1] = (t1 - t_avg)*Math.PI/180.0; vector[1] = (t1 - t_avg)*Math.PI/180.0;
...@@ -1293,7 +1293,7 @@ public class GeometryCorrection { ...@@ -1293,7 +1293,7 @@ public class GeometryCorrection {
} }
// Azimuths in radians, headings in degrees // Azimuths in radians, headings in degrees
public double setAzimuthsFromHeadings(double h0, double h1, double h2, double h3) { public double setAzimuthsFromHeadings(double h0, double h1, double h2, double h3) { // USED in lwir
double h_avg = (h0+h1+h2+h3)/4; double h_avg = (h0+h1+h2+h3)/4;
vector[3] = (h0 - h_avg)*Math.PI/180.0; vector[3] = (h0 - h_avg)*Math.PI/180.0;
vector[4] = (h1 - h_avg)*Math.PI/180.0; vector[4] = (h1 - h_avg)*Math.PI/180.0;
...@@ -1303,7 +1303,7 @@ public class GeometryCorrection { ...@@ -1303,7 +1303,7 @@ public class GeometryCorrection {
// Include factory calibration rolls // Include factory calibration rolls
public double [] getFullRolls() public double [] getFullRolls() // USED in lwir
{ {
double d2r= Math.PI/180.0; double d2r= Math.PI/180.0;
double [] rolls = { double [] rolls = {
...@@ -1313,7 +1313,7 @@ public class GeometryCorrection { ...@@ -1313,7 +1313,7 @@ public class GeometryCorrection {
vector[9] + d2r * roll[3]}; vector[9] + d2r * roll[3]};
return rolls; return rolls;
} }
public double getFullRoll(int indx) public double getFullRoll(int indx) // not used in lwir
{ {
return vector[6 + indx] + roll[indx] * Math.PI/180.0; return vector[6 + indx] + roll[indx] * Math.PI/180.0;
} }
...@@ -1323,14 +1323,14 @@ public class GeometryCorrection { ...@@ -1323,14 +1323,14 @@ public class GeometryCorrection {
* @param inPix show result in pixels , false - in radians (even for zooms) * @param inPix show result in pixels , false - in radians (even for zooms)
* @return parameter value * @return parameter value
*/ */
public double getExtrinsicParameterValue(int indx, boolean inPix) { public double getExtrinsicParameterValue(int indx, boolean inPix) { // not used in lwir
if (indx <0) return Double.NaN; if (indx <0) return Double.NaN;
if (indx < ROLL_INDEX) return vector[indx]* (inPix? (1000.0*focalLength /pixelSize): 1.0); // tilt and azimuth if (indx < ROLL_INDEX) return vector[indx]* (inPix? (1000.0*focalLength /pixelSize): 1.0); // tilt and azimuth
if (indx < LENGTH_ANGLES) return vector[indx]* (inPix? (1000.0*distortionRadius/pixelSize): 1.0); // rolls if (indx < LENGTH_ANGLES) return vector[indx]* (inPix? (1000.0*distortionRadius/pixelSize): 1.0); // rolls
if (indx < LENGTH) return vector[indx]* (inPix? (1000.0*distortionRadius/pixelSize): 1.0); // zooms if (indx < LENGTH) return vector[indx]* (inPix? (1000.0*distortionRadius/pixelSize): 1.0); // zooms
return Double.NaN; return Double.NaN;
} }
public double getExtrinsicSymParameterValue(int indx, boolean inPix) { public double getExtrinsicSymParameterValue(int indx, boolean inPix) { // not used in lwir
double [] sym_vect = toSymArray(null); double [] sym_vect = toSymArray(null);
if (indx <0) return Double.NaN; if (indx <0) return Double.NaN;
if (indx < ROLL_INDEX) return sym_vect[indx]* (inPix? (1000.0*focalLength /pixelSize): 1.0); // tilt and azimuth if (indx < ROLL_INDEX) return sym_vect[indx]* (inPix? (1000.0*focalLength /pixelSize): 1.0); // tilt and azimuth
...@@ -1340,7 +1340,7 @@ public class GeometryCorrection { ...@@ -1340,7 +1340,7 @@ public class GeometryCorrection {
} }
@Override @Override
public String toString() public String toString() // USED in lwir
{ {
String s; String s;
double [] sym_vect = toSymArray(null); double [] sym_vect = toSymArray(null);
...@@ -1372,7 +1372,7 @@ public class GeometryCorrection { ...@@ -1372,7 +1372,7 @@ public class GeometryCorrection {
return s; return s;
} }
public String toStringDegrees() public String toStringDegrees() // not used in lwir
{ {
String s; String s;
double [] sym_vect = toSymArray(null); double [] sym_vect = toSymArray(null);
...@@ -1405,7 +1405,7 @@ public class GeometryCorrection { ...@@ -1405,7 +1405,7 @@ public class GeometryCorrection {
// returns false if any component is NaN, in that case do not increment // returns false if any component is NaN, in that case do not increment
public boolean incrementVector(double [] incr, public boolean incrementVector(double [] incr, // USED in lwir
double scale) double scale)
{ {
for (int i = 0; i < incr.length; i++){ for (int i = 0; i < incr.length; i++){
...@@ -1417,13 +1417,13 @@ public class GeometryCorrection { ...@@ -1417,13 +1417,13 @@ public class GeometryCorrection {
return true; return true;
} }
public boolean incrementVector(CorrVector incr, double scale) public boolean incrementVector(CorrVector incr, double scale) // USED in lwir
{ {
return incrementVector(incr.toArray(), scale); return incrementVector(incr.toArray(), scale);
} }
@Override @Override
public CorrVector clone(){ public CorrVector clone(){ // not used in lwir
return new CorrVector(this.vector.clone()); return new CorrVector(this.vector.clone());
} }
...@@ -1432,7 +1432,7 @@ public class GeometryCorrection { ...@@ -1432,7 +1432,7 @@ public class GeometryCorrection {
* and apply (add) them to the current vector (normally should be all 0.0) * and apply (add) them to the current vector (normally should be all 0.0)
* @param pXY_shift manula XY pixel corrections (shiftXY made of clt_parameters.fine_corr_[xy]_[0123]) * @param pXY_shift manula XY pixel corrections (shiftXY made of clt_parameters.fine_corr_[xy]_[0123])
*/ */
public void applyPixelShift(double [][] pXY_shift){ public void applyPixelShift(double [][] pXY_shift){ // not used in lwir
double [] pXY_avg = {0.0,0.0}; double [] pXY_avg = {0.0,0.0};
for (int i = 0; i < numSensors; i++){ for (int i = 0; i < numSensors; i++){
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
...@@ -1454,7 +1454,7 @@ public class GeometryCorrection { ...@@ -1454,7 +1454,7 @@ public class GeometryCorrection {
* 0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖| * 0: |↗ ↖| 1: |↙ ↖| 2: |↖ ↙| 3: |↖ ↗| 4: |↗ ↙| 5: |↘ ↖|
* *
*/ */
public double [][] dSym_j_dTar_i() public double [][] dSym_j_dTar_i() // USED in lwir
{ {
double [][] tar_to_sym = { double [][] tar_to_sym = {
{-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0 {-2.0, -2.0, 2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // t0
...@@ -1512,7 +1512,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1512,7 +1512,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
[-0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0.5 , -0.5 , 0.5 ], [-0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0. , -0.5 , -0.5 , 0.5 ],
[ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -0.5 , 0.5 , 0.5 ]]) [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , -0.5 , 0.5 , 0.5 ]])
*/ */
double [][] sym_to_tar= { double [][] sym_to_tar= { // USED in lwir
// t0 t1 t2 a0 a1 a2 r0 r1 r2 r3 s0 s1 s2 // t0 t1 t2 a0 a1 a2 r0 r1 r2 r3 s0 s1 s2
{-0.125,-0.125, 0.125, 0.125,-0.125, 0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, // sym0 {-0.125,-0.125, 0.125, 0.125,-0.125, 0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, // sym0
{-0.125, 0.125,-0.125, 0.125, 0.125,-0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, // sym1 {-0.125, 0.125,-0.125, 0.125, 0.125,-0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, // sym1
...@@ -1531,7 +1531,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1531,7 +1531,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
return sym_to_tar; return sym_to_tar;
} }
public boolean [] getParMask( public boolean [] getParMask( // USED in lwir
boolean use_disparity, boolean use_disparity,
// boolean use_other_extr, // boolean use_other_extr,
boolean use_aztilts, // Adjust azimuths and tilts excluding disparity boolean use_aztilts, // Adjust azimuths and tilts excluding disparity
...@@ -1561,7 +1561,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1561,7 +1561,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
corr_focalLength, //sym11 corr_focalLength, //sym11
corr_focalLength //sym12 corr_focalLength //sym12
}; };
if (manual_par_sel != 0) { if (manual_par_sel != 0) { // not used in lwir
for (int i = 0; i < par_mask.length; i++) { for (int i = 0; i < par_mask.length; i++) {
par_mask[i] = ((manual_par_sel >> i) & 1) != 0; par_mask[i] = ((manual_par_sel >> i) & 1) != 0;
} }
...@@ -1593,7 +1593,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1593,7 +1593,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @return * @return
*/ */
public double [][] getJtPartial( public double [][] getJtPartial( // USED in lwir
double [][] port_coord_deriv, double [][] port_coord_deriv,
boolean [] par_mask) boolean [] par_mask)
{ {
...@@ -1615,12 +1615,12 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1615,12 +1615,12 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
return jt_part; return jt_part;
} }
// convert tilt0,... roll3 array to symmetrical coordinates [0] - to the center (disparity) // convert tilt0,... roll3 array to symmetrical coordinates [0] - to the center (disparity)
public double [] toSymArray(boolean [] par_mask) public double [] toSymArray(boolean [] par_mask) // USED in lwir
{ {
return toSymArray(this.vector, par_mask); return toSymArray(this.vector, par_mask);
} }
public double [] toSymArray( public double [] toSymArray( // USED in lwir
double [] tar_array, double [] tar_array,
boolean [] par_mask) boolean [] par_mask)
{ {
...@@ -1640,7 +1640,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1640,7 +1640,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
return sym_array; return sym_array;
} }
public double [] toTarArray( public double [] toTarArray( // USED in lwir
double [] sym_array, double [] sym_array,
boolean [] par_mask) boolean [] par_mask)
{ {
...@@ -1660,7 +1660,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1660,7 +1660,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
public void setDistortion( public void setDistortion( // USED in lwir
double focalLength, double focalLength,
double distortionC, double distortionC,
double distortionB, double distortionB,
...@@ -1691,7 +1691,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1691,7 +1691,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
// imp.setProperty("distortionRadius", ""+subCam.distortionRadius); // imp.setProperty("distortionRadius", ""+subCam.distortionRadius);
} }
public void setSensors( public void setSensors( // USED in lwir
int numSensors, // <=0 - keep current int numSensors, // <=0 - keep current
double elevation, // NaN - keep double elevation, // NaN - keep
double heading, // NaN - keep double heading, // NaN - keep
...@@ -1744,7 +1744,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1744,7 +1744,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
} }
public void planeProjectLenses(){ // calculate XYZ_he (any number of sensors) public void planeProjectLenses(){ // calculate XYZ_he (any number of sensors) // USED in lwir
// get center of the adjusted camera // get center of the adjusted camera
common_right = 0; common_right = 0;
common_forward = 0; common_forward = 0;
...@@ -1799,7 +1799,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1799,7 +1799,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
// cameras should be Z-numbered (looking to the target, X - right, Y - down) // cameras should be Z-numbered (looking to the target, X - right, Y - down)
public void adustSquare(){ // rotate heading/elevation aligned cameras around the Z-axis to make it more "square" public void adustSquare(){ // rotate heading/elevation aligned cameras around the Z-axis to make it more "square" // USED in lwir
if (numSensors != 4 ){ if (numSensors != 4 ){
throw new IllegalArgumentException ("adjustSquare() is valid only for quad-cameras, numSensors="+numSensors); throw new IllegalArgumentException ("adjustSquare() is valid only for quad-cameras, numSensors="+numSensors);
} }
...@@ -1836,11 +1836,11 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1836,11 +1836,11 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
for (int j = 0; j<2;j++) this.rXY[i][j] = this.XYZ_her[i][j]/this.disparityRadius; for (int j = 0; j<2;j++) this.rXY[i][j] = this.XYZ_her[i][j]/this.disparityRadius;
} }
if (rigOffset != null) { if (rigOffset != null) {
rigOffset.recalcRXY(); rigOffset.recalcRXY(); // not used in lwir
} }
} }
public void listGeometryCorrection(boolean showAll){ public void listGeometryCorrection(boolean showAll){ // not used in lwir
System.out.println("'=== Constant parameters ==="); System.out.println("'=== Constant parameters ===");
System.out.println("pixelCorrectionWidth =\t"+ pixelCorrectionWidth+"\tpix"); System.out.println("pixelCorrectionWidth =\t"+ pixelCorrectionWidth+"\tpix");
System.out.println("pixelCorrectionHeight =\t"+ pixelCorrectionHeight+"\tpix"); System.out.println("pixelCorrectionHeight =\t"+ pixelCorrectionHeight+"\tpix");
...@@ -1931,32 +1931,32 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1931,32 +1931,32 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
// return distance from disparity (in pixel units) for the current camera geometry // return distance from disparity (in pixel units) for the current camera geometry
public double getZFromDisparity(double disparity){ public double getZFromDisparity(double disparity){ // not used in lwir
return SCENE_UNITS_SCALE * this.focalLength * this.disparityRadius / (disparity * 0.001*this.pixelSize); return SCENE_UNITS_SCALE * this.focalLength * this.disparityRadius / (disparity * 0.001*this.pixelSize);
} }
public double getDisparityFromZ(double z){ public double getDisparityFromZ(double z){ // USED in lwir
return (1000.0 * SCENE_UNITS_SCALE * this.focalLength * this.disparityRadius / this.pixelSize) / z; return (1000.0 * SCENE_UNITS_SCALE * this.focalLength * this.disparityRadius / this.pixelSize) / z;
} }
public double getFOVPix(){ // get ratio of 1 pixel X/Y to Z (distance to object) public double getFOVPix(){ // get ratio of 1 pixel X/Y to Z (distance to object) // USED in lwir
return 0.001 * this.pixelSize / this.focalLength; return 0.001 * this.pixelSize / this.focalLength;
} }
public double getFOVWidth(){ // get FOV ratio: width to distance public double getFOVWidth(){ // get FOV ratio: width to distance // USED in lwir
return this.pixelCorrectionWidth * 0.001 * this.pixelSize / this.focalLength; return this.pixelCorrectionWidth * 0.001 * this.pixelSize / this.focalLength;
} }
public double getFOVHeight(){ // get FOV ratio: width to distance public double getFOVHeight(){ // get FOV ratio: width to distance // USED in lwir
return this.pixelCorrectionHeight * 0.001 * this.pixelSize / this.focalLength; return this.pixelCorrectionHeight * 0.001 * this.pixelSize / this.focalLength;
} }
public double getScaleDzDx() public double getScaleDzDx() // USED in lwir
{ {
return ( 0.001 * this.pixelSize) / this.focalLength; return ( 0.001 * this.pixelSize) / this.focalLength;
} }
// get rotation matrix of the composite camera // get rotation matrix of the composite camera
public Matrix getCommonRotMatrix() { public Matrix getCommonRotMatrix() { // USED in lwir
double heading_rad = Math.PI / 180.0 * heading; double heading_rad = Math.PI / 180.0 * heading;
double elevation_rad = Math.PI / 180.0 * elevation; double elevation_rad = Math.PI / 180.0 * elevation;
double roll_rad = Math.PI / 180.0 * common_roll; double roll_rad = Math.PI / 180.0 * common_roll;
...@@ -1984,7 +1984,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -1984,7 +1984,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
Matrix rot = (new Matrix(a_r).times(new Matrix(a_t).times(new Matrix(a_az)))); Matrix rot = (new Matrix(a_r).times(new Matrix(a_t).times(new Matrix(a_az))));
return rot; return rot;
} }
public Matrix getCommonTranslateMatrix() { public Matrix getCommonTranslateMatrix() { // USED in lwir
// * SCENE_UNITS_SCALE to get meters from mm // * SCENE_UNITS_SCALE to get meters from mm
double [][] a_translate= { double [][] a_translate= {
{common_right * SCENE_UNITS_SCALE}, {common_right * SCENE_UNITS_SCALE},
...@@ -2003,7 +2003,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2003,7 +2003,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param disparity nominal disparity (pixels) * @param disparity nominal disparity (pixels)
* @return {x, y, z} in meters * @return {x, y, z} in meters
*/ */
public double [] getTrueWorldCoordinates( public double [] getTrueWorldCoordinates( // USED in lwir
double px, double px,
double py, double py,
double disparity) double disparity)
...@@ -2024,7 +2024,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2024,7 +2024,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param xyz real world coordinates {x, y, z} in meters (right up, towards camera) * @param xyz real world coordinates {x, y, z} in meters (right up, towards camera)
* @return {disparity, px, py} (right, down) * @return {disparity, px, py} (right, down)
*/ */
public double [] getTrueImageCoordinates( public double [] getTrueImageCoordinates( // USED in lwir
double [] xyz) // correct distortion (will need corrected background too !) double [] xyz) // correct distortion (will need corrected background too !)
{ {
double [][] a_xyz = {{xyz[0]}, {xyz[1]},{xyz[2]}}; double [][] a_xyz = {{xyz[0]}, {xyz[1]},{xyz[2]}};
...@@ -2040,7 +2040,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2040,7 +2040,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @return {disparity, px, py} (right, down) for this GeometryCorrection * @return {disparity, px, py} (right, down) for this GeometryCorrection
*/ */
public double [] getFromOther( public double [] getFromOther( // USED in lwir
GeometryCorrection other_gc, GeometryCorrection other_gc,
double other_px, double other_px,
double other_py, double other_py,
...@@ -2060,7 +2060,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2060,7 +2060,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param correctDistortions true: correct lens distortions, false - no lens distortions * @param correctDistortions true: correct lens distortions, false - no lens distortions
* @return {x, y, z} in meters * @return {x, y, z} in meters
*/ */
public double [] getWorldCoordinates( public double [] getWorldCoordinates( // USED in lwir
double px, double px,
double py, double py,
double disparity, double disparity,
...@@ -2085,7 +2085,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2085,7 +2085,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param correctDistortions true: correct lens distortions, false - no lens distortions * @param correctDistortions true: correct lens distortions, false - no lens distortions
* @return {disparity, px, py} (right, down) * @return {disparity, px, py} (right, down)
*/ */
public double [] getImageCoordinates( public double [] getImageCoordinates( // USED in lwir
double [] xyz, double [] xyz,
boolean correctDistortions) // correct distortion (will need corrected background too !) boolean correctDistortions) // correct distortion (will need corrected background too !)
{ {
...@@ -2114,7 +2114,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2114,7 +2114,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param correctDistortions true for lens distortion correction, false otherwise * @param correctDistortions true for lens distortion correction, false otherwise
* @return disparity for the point on the plane specified by norm_xyz and known view coordinates px, py * @return disparity for the point on the plane specified by norm_xyz and known view coordinates px, py
*/ */
public double getPlaneDisparity( public double getPlaneDisparity( // USED in lwir
double [] norm_xyz, double [] norm_xyz,
double px, double px,
double py, double py,
...@@ -2136,7 +2136,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2136,7 +2136,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
/* Just for testing using delta instead of d */ /* Just for testing using delta instead of d */
public double [][] getWorldJacobian( public double [][] getWorldJacobian( // not used in lwir
double px, double px,
double py, double py,
double disparity, double disparity,
...@@ -2166,7 +2166,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2166,7 +2166,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param correctDistortions true: correct lens distortions, false - no lens distortions * @param correctDistortions true: correct lens distortions, false - no lens distortions
* @return {{dx/ddisparity, dx/dpx, dx/dpy},{dy/ddisparity, dy/dpx, dy/dpy},{dz/ddisparity, dz/dpx, dz/dpy}} * @return {{dx/ddisparity, dx/dpx, dx/dpy},{dy/ddisparity, dy/dpx, dy/dpy},{dz/ddisparity, dz/dpx, dz/dpy}}
*/ */
public double [][] getWorldJacobian( public double [][] getWorldJacobian( // USED in lwir
double px, double px,
double py, double py,
double disparity, double disparity,
...@@ -2229,7 +2229,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2229,7 +2229,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
/* Just for testing using delta instead of d */ /* Just for testing using delta instead of d */
public double [][] getImageJacobian( public double [][] getImageJacobian( // not used in lwir
double [] xyz0, double [] xyz0,
boolean correctDistortions, // correct distortion (will need corrected background too !) boolean correctDistortions, // correct distortion (will need corrected background too !)
double delta) double delta)
...@@ -2254,7 +2254,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2254,7 +2254,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param correctDistortions true: correct lens distortions, false - no lens distortions * @param correctDistortions true: correct lens distortions, false - no lens distortions
* @return {{dx/ddisparity, dx/dpx, dx/dpy},{dy/ddisparity, dy/dpx, dy/dpy},{dz/ddisparity, dz/dpx, dz/dpy}} * @return {{dx/ddisparity, dx/dpx, dx/dpy},{dy/ddisparity, dy/dpx, dy/dpy},{dz/ddisparity, dz/dpx, dz/dpy}}
*/ */
public double [][] getImageJacobian( public double [][] getImageJacobian( // USED in lwir
double [] xyz, double [] xyz,
boolean correctDistortions, boolean correctDistortions,
int debugLevel) int debugLevel)
...@@ -2320,7 +2320,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2320,7 +2320,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param pXY pair of pixel X, pixel Y image coordinates * @param pXY pair of pixel X, pixel Y image coordinates
* @return pair of relative X, Y coordinates -n -1.0 ..+1.0 range * @return pair of relative X, Y coordinates -n -1.0 ..+1.0 range
*/ */
public double [] getRelativeCoords(double [] pXY){ public double [] getRelativeCoords(double [] pXY){ // USED in lwir
double [] relXY ={ double [] relXY ={
2.0 * (pXY[0]/this.pixelCorrectionWidth - 0.5), 2.0 * (pXY[0]/this.pixelCorrectionWidth - 0.5),
2.0 * (pXY[1]/this.pixelCorrectionWidth - 0.5), 2.0 * (pXY[1]/this.pixelCorrectionWidth - 0.5),
...@@ -2342,7 +2342,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2342,7 +2342,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param disparity disparity (for non-distorted image space) * @param disparity disparity (for non-distorted image space)
* @return array of per port pairs of pixel shifts * @return array of per port pairs of pixel shifts
*/ */
public double [][] getPortsCoordinatesAndDerivatives( public double [][] getPortsCoordinatesAndDerivatives( // USED in lwir
GeometryCorrection gc_main, GeometryCorrection gc_main,
boolean use_rig_offsets, boolean use_rig_offsets,
Matrix [] rots, Matrix [] rots,
...@@ -2589,7 +2589,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2589,7 +2589,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @return a pair of x,y coordinates of the matching image tile of the aux camera image * @return a pair of x,y coordinates of the matching image tile of the aux camera image
*/ */
public double [] getRigAuxCoordinatesAndDerivatives( public double [] getRigAuxCoordinatesAndDerivatives( // not used in lwir
GeometryCorrection gc_main, GeometryCorrection gc_main,
Matrix aux_rot, Matrix aux_rot,
Matrix [] aux_rot_derivs, Matrix [] aux_rot_derivs,
...@@ -2762,7 +2762,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2762,7 +2762,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
return pXY; return pXY;
} }
public double [][] getPortsCoordinatesAndDerivatives( // uses rotations - used in AlignmentCorrection class public double [][] getPortsCoordinatesAndDerivatives( // uses rotations - used in AlignmentCorrection class // not used in lwir
boolean use_rig_offsets, boolean use_rig_offsets,
double [] dbg_a_vector, // replace actual radial distortion coefficients (not currently used) double [] dbg_a_vector, // replace actual radial distortion coefficients (not currently used)
double delta, // 1e-6 double delta, // 1e-6
...@@ -2831,7 +2831,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2831,7 +2831,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
// should return same as input if disparity==0 // should return same as input if disparity==0
public double [][] getPortsCoordinatesIdeal( // used in macro mode public double [][] getPortsCoordinatesIdeal( // used in macro mode // USED in lwir
double px, double px,
double py, double py,
double disparity) double disparity)
...@@ -2920,7 +2920,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2920,7 +2920,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
*/ */
public double [][] getPortsCoordinatesIdeal( public double [][] getPortsCoordinatesIdeal( // USED in lwir
int macro_scale, // 1 for pixels, 8 - for tiles when correlating tiles instead of the pixels int macro_scale, // 1 for pixels, 8 - for tiles when correlating tiles instead of the pixels
double px, double px,
double py, double py,
...@@ -2938,7 +2938,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2938,7 +2938,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
return coords; return coords;
} }
public double [] getRigAuxCoordinatesIdeal( public double [] getRigAuxCoordinatesIdeal( // not used in lwir
int macro_scale, // 1 for pixels, 8 - for tiles when correlating tiles instead of the pixels int macro_scale, // 1 for pixels, 8 - for tiles when correlating tiles instead of the pixels
GeometryCorrection gc_main, GeometryCorrection gc_main,
Matrix aux_rot, Matrix aux_rot,
...@@ -2969,7 +2969,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2969,7 +2969,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* Rdist/R=A5*R^4+A*R^3+B*R^2+C*R+(1-A5-A-B-C) * Rdist/R=A5*R^4+A*R^3+B*R^2+C*R+(1-A5-A-B-C)
* @return false if distortion is too high * @return false if distortion is too high
*/ */
public boolean calcReverseDistortionTable(){ public boolean calcReverseDistortionTable(){ // USED in lwir
boolean debugThis=false; //true; boolean debugThis=false; //true;
double delta=1E-20; // 12; // 10; // -8; double delta=1E-20; // 12; // 10; // -8;
double minDerivative=0.01; double minDerivative=0.01;
...@@ -2998,7 +2998,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -2998,7 +2998,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
if (use8){ if (use8){
k=(((((((this.distortionA8)*r+this.distortionA7)*r+this.distortionA6)*r+this.distortionA5)*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d; k=(((((((this.distortionA8)*r+this.distortionA7)*r+this.distortionA6)*r+this.distortionA5)*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d;
drDistDr=(((((((8*this.distortionA8)*r + 7*this.distortionA7)*r + 6*this.distortionA6)*r + 5*this.distortionA5)*r + 4*this.distortionA)*r+3*this.distortionB)*r+2*this.distortionC)*r+d; drDistDr=(((((((8*this.distortionA8)*r + 7*this.distortionA7)*r + 6*this.distortionA6)*r + 5*this.distortionA5)*r + 4*this.distortionA)*r+3*this.distortionB)*r+2*this.distortionC)*r+d;
} else { } else { // not used in lwir
k=(((this.distortionA5*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d; k=(((this.distortionA5*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d;
drDistDr=(((5*this.distortionA5*r + 4*this.distortionA)*r+3*this.distortionB)*r+2*this.distortionC)*r+d; drDistDr=(((5*this.distortionA5*r + 4*this.distortionA)*r+3*this.distortionB)*r+2*this.distortionC)*r+d;
} }
...@@ -3030,7 +3030,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -3030,7 +3030,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param r non-distorted radius (1.0 is 2.8512mm) * @param r non-distorted radius (1.0 is 2.8512mm)
* @return ratio of distorted to non-distorted radius * @return ratio of distorted to non-distorted radius
*/ */
public double getRDistByR(double r) // relative to distortion radius public double getRDistByR(double r) // relative to distortion radius // USED in lwir
{ {
boolean use8=(this.distortionA8!=0.0) || (this.distortionA7!=0.0) || (this.distortionA6!=0.0); boolean use8=(this.distortionA8!=0.0) || (this.distortionA7!=0.0) || (this.distortionA6!=0.0);
double d=1.0-this.distortionA8-this.distortionA7-this.distortionA6-this.distortionA5-this.distortionA-this.distortionB-this.distortionC; double d=1.0-this.distortionA8-this.distortionA7-this.distortionA6-this.distortionA5-this.distortionA-this.distortionB-this.distortionC;
...@@ -3038,7 +3038,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -3038,7 +3038,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
double k; double k;
if (use8){ if (use8){
k=(((((((this.distortionA8)*r+this.distortionA7)*r+this.distortionA6)*r+this.distortionA5)*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d; k=(((((((this.distortionA8)*r+this.distortionA7)*r+this.distortionA6)*r+this.distortionA5)*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d;
} else { } else { // not used in lwir
k=(((this.distortionA5*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d; k=(((this.distortionA5*r + this.distortionA)*r+this.distortionB)*r+this.distortionC)*r+d;
} }
return k; return k;
...@@ -3049,26 +3049,26 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -3049,26 +3049,26 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
* @param r non-distorted relative radius * @param r non-distorted relative radius
* @return derivative d_Rdist/d_R from (relative to relative) * @return derivative d_Rdist/d_R from (relative to relative)
*/ */
public double getDerivRDistFromR(double r) // relative to distortion radius public double getDerivRDistFromR(double r) // relative to distortion radius // USED in lwir
{ {
boolean use8=(this.distortionA8!=0.0) || (this.distortionA7!=0.0) || (this.distortionA6!=0.0); boolean use8=(this.distortionA8!=0.0) || (this.distortionA7!=0.0) || (this.distortionA6!=0.0);
double drDistDr; double drDistDr;
if (use8){ if (use8){
drDistDr=(((((((7*this.distortionA8)*r + 6*this.distortionA7)*r + 5*this.distortionA6)*r + 4*this.distortionA5)*r + 3*this.distortionA)*r+2*this.distortionB)*r+1*this.distortionC); // +d; drDistDr=(((((((7*this.distortionA8)*r + 6*this.distortionA7)*r + 5*this.distortionA6)*r + 4*this.distortionA5)*r + 3*this.distortionA)*r+2*this.distortionB)*r+1*this.distortionC); // +d;
} else { } else { // not used in lwir
drDistDr=((4*this.distortionA5*r + 3*this.distortionA)*r+2*this.distortionB)*r+1*this.distortionC; drDistDr=((4*this.distortionA5*r + 3*this.distortionA)*r+2*this.distortionB)*r+1*this.distortionC;
} }
return drDistDr; return drDistDr;
} }
public double getDerivRDistFromR(double r, double delta) // relative to distortion radius public double getDerivRDistFromR(double r, double delta) // relative to distortion radius // not used in lwir
{ {
return (getRDistByR(r+delta) -getRDistByR(r))/delta; return (getRDistByR(r+delta) -getRDistByR(r))/delta;
} }
public double getRByRDistlin(double rDist, boolean debug){ public double getRByRDistlin(double rDist, boolean debug){ // not used in lwir
// add exceptions; // add exceptions;
if (this.rByRDist==null) { if (this.rByRDist==null) {
calcReverseDistortionTable(); calcReverseDistortionTable();
...@@ -3096,20 +3096,20 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -3096,20 +3096,20 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
} }
public double getRByRDist(double rDist, boolean debug){ public double getRByRDist(double rDist, boolean debug){ // USED in lwir
// add exceptions; // add exceptions;
if (this.rByRDist==null) { if (this.rByRDist==null) { // not used in lwir
calcReverseDistortionTable(); calcReverseDistortionTable();
if (debug)System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): this.rByRDist==null"); if (debug)System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): this.rByRDist==null");
// return Double.NaN; // return Double.NaN;
} }
if (rDist < 0) { if (rDist < 0) { // not used in lwir
if (debug)System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): rDist < 0"); if (debug)System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): rDist < 0");
return Double.NaN; return Double.NaN;
} }
double findex = rDist/this.stepR; double findex = rDist/this.stepR;
int index=(int) Math.floor(findex); int index=(int) Math.floor(findex);
if (index>=(this.rByRDist.length-2)) { if (index>=(this.rByRDist.length-2)) { // not used in lwir
if (debug) System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): index="+index+">="+(this.rByRDist.length-2)); if (debug) System.out.println("getRByRDist("+IJ.d2s(rDist,3)+"): index="+index+">="+(this.rByRDist.length-2));
return Double.NaN; return Double.NaN;
} }
...@@ -3127,7 +3127,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0. ...@@ -3127,7 +3127,7 @@ matrix([[-0.125, -0.125, 0.125, 0.125, -0.125, 0.125, -0. , -0. , -0.
double result= a0*mu*mu2+a1*mu2+a2*mu+a3; double result= a0*mu*mu2+a1*mu2+a2*mu+a3;
// double result=this.rByRDist[index] + (this.rByRDist[index+1]-this.rByRDist[index])*(rDist/this.stepR-index); // double result=this.rByRDist[index] + (this.rByRDist[index+1]-this.rByRDist[index])*(rDist/this.stepR-index);
// double result=this.rByRDist[index] + (this.rByRDist[index+1]-this.rByRDist[index])*mu; // double result=this.rByRDist[index] + (this.rByRDist[index+1]-this.rByRDist[index])*mu;
if (Double.isNaN(result)){ if (Double.isNaN(result)){ // not used in lwir
if (debug) System.out.println("this.rByRDist["+index+"]="+this.rByRDist[index]); if (debug) System.out.println("this.rByRDist["+index+"]="+this.rByRDist[index]);
if (debug) System.out.println("this.rByRDist["+(index+1)+"]="+this.rByRDist[index+1]); if (debug) System.out.println("this.rByRDist["+(index+1)+"]="+this.rByRDist[index+1]);
if (debug) System.out.println("rDist="+rDist); if (debug) System.out.println("rDist="+rDist);
......
...@@ -219,8 +219,8 @@ public class ImageDtt { ...@@ -219,8 +219,8 @@ public class ImageDtt {
public static int setPairMask (int data, int mask) {return (data & ~0xf0) | ((mask & 0xf) << 4);} public static int setPairMask (int data, int mask) {return (data & ~0xf0) | ((mask & 0xf) << 4);}
public static boolean getForcedDisparity (int data){return (data & 0x100) != 0;} public static boolean getForcedDisparity (int data){return (data & 0x100) != 0;}
public static int setForcedDisparity (int data, boolean force) {return (data & ~0x100) | (force?0x100:0);} public static int setForcedDisparity (int data, boolean force) {return (data & ~0x100) | (force?0x100:0);}
public static boolean getOrthoLines (int data){return (data & 0x200) != 0;} public static boolean getOrthoLines (int data){return (data & 0x200) != 0;} // not used in lwir
public static int setOrthoLines (int data, boolean force) {return (data & ~0x200) | (force?0x200:0);} public static int setOrthoLines (int data, boolean force) {return (data & ~0x200) | (force?0x200:0);} // not used in lwir
public ImageDtt( public ImageDtt(
boolean mono, boolean mono,
...@@ -238,7 +238,7 @@ public class ImageDtt { ...@@ -238,7 +238,7 @@ public class ImageDtt {
} }
public double [][][][] mdctStack( public double [][][][] mdctStack( // not used in lwir
final ImageStack imageStack, final ImageStack imageStack,
final int subcamera, // final int subcamera, //
final EyesisCorrectionParameters.DCTParameters dctParameters, // final EyesisCorrectionParameters.DCTParameters dctParameters, //
...@@ -292,7 +292,7 @@ public class ImageDtt { ...@@ -292,7 +292,7 @@ public class ImageDtt {
return dct_data; return dct_data;
} }
public double [][][] lapped_dct( public double [][][] lapped_dct( // not used in lwir
final double [] dpixels, final double [] dpixels,
final int width, final int width,
final int dct_size, final int dct_size,
...@@ -557,7 +557,7 @@ public class ImageDtt { ...@@ -557,7 +557,7 @@ public class ImageDtt {
} }
// extract DCT transformed parameters in linescan order (for visualization) // extract DCT transformed parameters in linescan order (for visualization)
public double [] lapped_dct_dbg( public double [] lapped_dct_dbg( // not used in lwir
final double [][][] dct_data, final double [][][] dct_data,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel) final int globalDebugLevel)
...@@ -591,7 +591,7 @@ public class ImageDtt { ...@@ -591,7 +591,7 @@ public class ImageDtt {
return dct_data_out; return dct_data_out;
} }
public void dct_lpf( public void dct_lpf( // not used in lwir
final double sigma, final double sigma,
final double [][][] dct_data, final double [][][] dct_data,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -670,7 +670,7 @@ public class ImageDtt { ...@@ -670,7 +670,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
} }
public double [][][][] dct_color_convert( public double [][][][] dct_color_convert( // not used in lwir
final double [][][][] dct_data, final double [][][][] dct_data,
final double kr, final double kr,
final double kb, final double kb,
...@@ -797,7 +797,7 @@ public class ImageDtt { ...@@ -797,7 +797,7 @@ public class ImageDtt {
public double [] lapped_idct( public double [] lapped_idct( // not used in lwir
// final double [][][] dctdc_data, // array [tilesY][tilesX][dct_size*dct_size+1] - last element is DC value // final double [][][] dctdc_data, // array [tilesY][tilesX][dct_size*dct_size+1] - last element is DC value
final double [][][] dct_data, // array [tilesY][tilesX][dct_size*dct_size] final double [][][] dct_data, // array [tilesY][tilesX][dct_size*dct_size]
final int dct_size, final int dct_size,
...@@ -870,7 +870,7 @@ public class ImageDtt { ...@@ -870,7 +870,7 @@ public class ImageDtt {
} }
// perform 2d clt and apply aberration corrections, all colors // perform 2d clt and apply aberration corrections, all colors
public double [][][][][] clt_aberrations( public double [][][][][] clt_aberrations( // not used in lwir
final double [][] image_data, final double [][] image_data,
final int width, final int width,
final double [][][][][] clt_kernels, // [color][tileY][tileX][band][pixel] , size should match image (have 1 tile around) final double [][][][][] clt_kernels, // [color][tileY][tileX][band][pixel] , size should match image (have 1 tile around)
...@@ -974,7 +974,7 @@ public class ImageDtt { ...@@ -974,7 +974,7 @@ public class ImageDtt {
} }
public double [][][][][][] clt_aberrations_quad( public double [][][][][][] clt_aberrations_quad( // not used in lwir
final double disparity, final double disparity,
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final int width, final int width,
...@@ -1128,7 +1128,7 @@ public class ImageDtt { ...@@ -1128,7 +1128,7 @@ public class ImageDtt {
return clt_data; return clt_data;
} }
public void printSignsFPGA ( public void printSignsFPGA ( // not used in lwir
DttRad2 dtt DttRad2 dtt
){ ){
double [][][] fold_coeff = dtt.getFoldK(); double [][][] fold_coeff = dtt.getFoldK();
...@@ -1171,7 +1171,7 @@ public class ImageDtt { ...@@ -1171,7 +1171,7 @@ public class ImageDtt {
} }
} }
public void generateFPGACompareData( public void generateFPGACompareData( // not used in lwir
final double [][] image_data, // for selected subcamera final double [][] image_data, // for selected subcamera
final double [][] colorCentersXY, // pixel centers per color (2 - green) final double [][] colorCentersXY, // pixel centers per color (2 - green)
final int transform_size, final int transform_size,
...@@ -1513,7 +1513,7 @@ public class ImageDtt { ...@@ -1513,7 +1513,7 @@ public class ImageDtt {
} }
public double [][][][][][] clt_aberrations_quad_corr_new( public double [][][][][][] clt_aberrations_quad_corr_new( // USED in LWIR
final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
...@@ -1677,13 +1677,13 @@ public class ImageDtt { ...@@ -1677,13 +1677,13 @@ public class ImageDtt {
{-1, 0, -3, 2}, {-1, 0, -3, 2},
{-2, -3, 0, 1}, {-2, -3, 0, 1},
{ 3, -2, -1, 0}}; { 3, -2, -1, 0}};
final int [][] corr_pairs ={ // {first, second, rot} rot: 0 - as is, 1 - swap y,x final int [][] corr_pairs ={ // {first, second, rot} rot: 0 - as is, 1 - swap y,x // not used in lwir
{0,1,0}, {0,1,0},
{2,3,0}, {2,3,0},
{0,2,1}, {0,2,1},
{1,3,1}}; {1,3,1}};
final double[][] port_offsets = { final double[][] port_offsets = { // lwir: used only in textures to scale differences
{-0.5, -0.5}, {-0.5, -0.5},
{ 0.5, -0.5}, { 0.5, -0.5},
{-0.5, 0.5}, {-0.5, 0.5},
...@@ -1843,7 +1843,7 @@ public class ImageDtt { ...@@ -1843,7 +1843,7 @@ public class ImageDtt {
macro_scale* disparity_array[tileY][tileX] + disparity_corr); macro_scale* disparity_array[tileY][tileX] + disparity_corr);
} else { } else {
if (use_main) { // this is AUX camera that uses main coordinates if (use_main) { // this is AUX camera that uses main coordinates // not used in lwir
centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives( centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives(
geometryCorrection_main, // GeometryCorrection gc_main, geometryCorrection_main, // GeometryCorrection gc_main,
true, // boolean use_rig_offsets, true, // boolean use_rig_offsets,
...@@ -1856,7 +1856,7 @@ public class ImageDtt { ...@@ -1856,7 +1856,7 @@ public class ImageDtt {
disparity_array[tileY][tileX] + disparity_corr); // _aux); // + disparity_corr); disparity_array[tileY][tileX] + disparity_corr); // _aux); // + disparity_corr);
} else { } else { // used in lwir
centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives( centersXY = geometryCorrection.getPortsCoordinatesAndDerivatives(
geometryCorrection, // GeometryCorrection gc_main, geometryCorrection, // GeometryCorrection gc_main,
false, // boolean use_rig_offsets, false, // boolean use_rig_offsets,
...@@ -1914,7 +1914,7 @@ public class ImageDtt { ...@@ -1914,7 +1914,7 @@ public class ImageDtt {
} }
} }
} // if (macro_mode) ... else } // if (macro_mode) ... else
if (FPGA_COMPARE_DATA && (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)) { if (FPGA_COMPARE_DATA && (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY)) { // not used in lwir
final int fpga_cam = 0; final int fpga_cam = 0;
double [][] manual_offsets={ double [][] manual_offsets={
// { 1.3, -2.7}, // { 1.3, -2.7},
...@@ -1944,7 +1944,7 @@ public class ImageDtt { ...@@ -1944,7 +1944,7 @@ public class ImageDtt {
} }
// See if macro_mode uses color channels for non-color? // See if macro_mode uses color channels for non-color?
for (int ncol = 0; ncol <numcol; ncol++) { for (int ncol = 0; ncol <numcol; ncol++) {
if (!isMonochrome() || (ncol == MONO_CHN) || macro_mode) { // in monochrome mode skip all non-mono (green) channels if (!isMonochrome() || (ncol == MONO_CHN) || macro_mode) { // in monochrome mode skip all non-mono (green) channels // used in lwir (5 of 6 branches)
boolean debug_for_fpga = FPGA_COMPARE_DATA && (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2); boolean debug_for_fpga = FPGA_COMPARE_DATA && (globalDebugLevel > 0) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2);
if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2)) { if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2)) {
System.out.println("\nUsing "+(macro_mode?"MACRO":"PIXEL")+" mode, centerX="+centerX+", centerY="+centerY); System.out.println("\nUsing "+(macro_mode?"MACRO":"PIXEL")+" mode, centerX="+centerX+", centerY="+centerY);
...@@ -1956,7 +1956,7 @@ public class ImageDtt { ...@@ -1956,7 +1956,7 @@ public class ImageDtt {
} }
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) {
if (debug_for_fpga && (i==0)){ if (debug_for_fpga && (i==0)){ // not used in lwir
double [][] fpga_clt_data = new double [4][]; double [][] fpga_clt_data = new double [4][];
double [] fpga_fract_shiftsXY; double [] fpga_fract_shiftsXY;
double [] fpga_centersXY = {centersXY[i][0],centersXY[i][1]}; double [] fpga_centersXY = {centersXY[i][0],centersXY[i][1]};
...@@ -2046,24 +2046,24 @@ public class ImageDtt { ...@@ -2046,24 +2046,24 @@ public class ImageDtt {
System.out.println(); System.out.println();
} }
} // end of debug_for_fpga } // end of debug_for_fpga
clt_data[i][ncol][tileY][tileX] = new double [4][]; clt_data[i][ncol][tileY][tileX] = new double [4][];
// Extract image tiles and kernels, correct aberrations, return (ut do not apply) fractional shifts
fract_shiftsXY[i] = extract_correct_tile( // return a pair of residual offsets fract_shiftsXY[i] = extract_correct_tile( // return a pair of residual offsets
image_data[i], image_data[i],
width, // image width width, // image width
(clt_kernels == null) ? null : clt_kernels[i], // [color][tileY][tileX][band][pixel] ((clt_kernels == null) ? null : clt_kernels[i]), // [color][tileY][tileX][band][pixel]
clt_data[i][ncol][tileY][tileX], //double [][] clt_tile, // should be double [4][]; clt_data[i][ncol][tileY][tileX], //double [][] clt_tile, // should be double [4][];
kernel_step, kernel_step,
transform_size, transform_size,
dtt, dtt,
ncol, ncol,
centersXY[i][0], // centerX, // center of aberration-corrected (common model) tile, X centersXY[i][0], // centerX, // center of aberration-corrected (common model) tile, X
centersXY[i][1], // centerY, // centersXY[i][1], // centerY, //
(!FPGA_COMPARE_DATA && (globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2) && (i==0)) ? (globalDebugLevel + 0) : 0, // external tile compare ((!FPGA_COMPARE_DATA && (globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2) && (i==0)) ? (globalDebugLevel + 0) : 0), // external tile compare
no_deconvolution, no_deconvolution,
false, // ); // transpose); false, // ); // transpose);
((saturation_imp != null) ? saturation_imp[i] : null), //final boolean [][] saturation_imp, // (near) saturated pixels or null ((saturation_imp != null) ? saturation_imp[i] : null), //final boolean [][] saturation_imp, // (near) saturated pixels or null
((saturation_imp != null) ? overexp_all: null)); // final double [] overexposed) ((saturation_imp != null) ? overexp_all: null)); // final double [] overexposed)
} // for (int i = 0; i < quad; i++) } // for (int i = 0; i < quad; i++)
if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2)) { if ((globalDebugLevel > -1) && (tileX == debug_tileX) && (tileY == debug_tileY) && (ncol == 2)) {
System.out.println(); System.out.println();
...@@ -2084,7 +2084,7 @@ public class ImageDtt { ...@@ -2084,7 +2084,7 @@ public class ImageDtt {
} }
} }
if (!no_fract_shift) { if (!no_fract_shift) { // USED in lwir
// apply residual shift // apply residual shift
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) {
fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations
...@@ -2110,12 +2110,12 @@ public class ImageDtt { ...@@ -2110,12 +2110,12 @@ public class ImageDtt {
} }
} else { // if (!isMonochrome() || (chn == MONO_CHN) || macro_mode) { // in monochrome mode skip all non-mono (green) channels } else { // if (!isMonochrome() || (chn == MONO_CHN) || macro_mode) { // in monochrome mode skip all non-mono (green) channels
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) { // used in lwir
clt_data[i][ncol] = null; // erase unused clt_data clt_data[i][ncol] = null; // erase unused clt_data
} }
} }
}// end of for (int chn = 0; chn <numcol; chn++) }// end of for (int chn = 0; chn <numcol; chn++)
// used in lwir
int tile_lma_debug_level = ((tileX == debug_tileX) && (tileY == debug_tileY))? imgdtt_params.lma_debug_level : -1; int tile_lma_debug_level = ((tileX == debug_tileX) && (tileY == debug_tileY))? imgdtt_params.lma_debug_level : -1;
// all color channels are done here // all color channels are done here
...@@ -2395,7 +2395,7 @@ public class ImageDtt { ...@@ -2395,7 +2395,7 @@ public class ImageDtt {
} }
double [] mismatch_result = null; double [] mismatch_result = null;
boolean need_CM = true; boolean need_CM = true;
if (imgdtt_params.ly_poly) { if (imgdtt_params.ly_poly) { // not used in lwir
mismatch_result = corr2d.mismatchPairs( // returns x-xcenter, y, strength (sign same as disparity) mismatch_result = corr2d.mismatchPairs( // returns x-xcenter, y, strength (sign same as disparity)
imgdtt_params, // ImageDttParameters imgdtt_params, imgdtt_params, // ImageDttParameters imgdtt_params,
corrs, // double [][] corrs, corrs, // double [][] corrs,
...@@ -2469,9 +2469,9 @@ public class ImageDtt { ...@@ -2469,9 +2469,9 @@ public class ImageDtt {
if (corr_mode == 0) extra_disparity = disparity_map[DISPARITY_INDEX_INT][tIndex]; if (corr_mode == 0) extra_disparity = disparity_map[DISPARITY_INDEX_INT][tIndex];
else if (corr_mode == 1) extra_disparity = disparity_map[DISPARITY_INDEX_CM][tIndex]; else if (corr_mode == 1) extra_disparity = disparity_map[DISPARITY_INDEX_CM][tIndex];
else if (corr_mode == 2) extra_disparity = disparity_map[DISPARITY_INDEX_POLY][tIndex]; else if (corr_mode == 2) extra_disparity = disparity_map[DISPARITY_INDEX_POLY][tIndex];
else if (corr_mode == 3) extra_disparity = disparity_map[DISPARITY_INDEX_HOR][tIndex]; else if (corr_mode == 3) extra_disparity = disparity_map[DISPARITY_INDEX_HOR][tIndex]; // not used in lwir
else if (corr_mode == 4) extra_disparity = disparity_map[DISPARITY_INDEX_VERT][tIndex]; else if (corr_mode == 4) extra_disparity = disparity_map[DISPARITY_INDEX_VERT][tIndex]; // not used in lwir
if (Double.isNaN(extra_disparity)) extra_disparity = 0; if (Double.isNaN(extra_disparity)) extra_disparity = 0; // used in lwir
if (Double.isNaN(disparity_map[DISPARITY_STRENGTH_INDEX][tIndex])) { if (Double.isNaN(disparity_map[DISPARITY_STRENGTH_INDEX][tIndex])) {
System.out.println("BUG: 3. disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] should not be NaN"); System.out.println("BUG: 3. disparity_map[DISPARITY_STRENGTH_INDEX][tIndex] should not be NaN");
...@@ -2479,7 +2479,7 @@ public class ImageDtt { ...@@ -2479,7 +2479,7 @@ public class ImageDtt {
} // if (disparity_map != null){ // not null - calculate correlations } // if (disparity_map != null){ // not null - calculate correlations
// only debug is left // only debug is left
// old (per-color correlation) // old (per-color correlation)
if ((clt_corr_combo != null) && !imgdtt_params.corr_mode_debug){ // not null - calculate correlations if ((clt_corr_combo != null) && !imgdtt_params.corr_mode_debug){ // not null - calculate correlations // not used in lwir
tcorr_tpartial= new double[corr_pairs.length][numcol+1][4][transform_len]; tcorr_tpartial= new double[corr_pairs.length][numcol+1][4][transform_len];
tcorr_partial = new double[quad][numcol+1][]; tcorr_partial = new double[quad][numcol+1][];
...@@ -2689,7 +2689,7 @@ public class ImageDtt { ...@@ -2689,7 +2689,7 @@ public class ImageDtt {
if (texture_tiles !=null) { if (texture_tiles !=null) {
if ((extra_disparity != 0) && !getForcedDisparity(tile_op[tileY][tileX])){ // 0 - adjust disparity, 1 - use provided if ((extra_disparity != 0) && !getForcedDisparity(tile_op[tileY][tileX])){ // 0 - adjust disparity, 1 - use provided
// shift images by 0.5 * extra disparity in the diagonal direction // shift images by 0.5 * extra disparity in the diagonal direction // not used in lwir
for (int ncol = 0; ncol <numcol; ncol++) { // color for (int ncol = 0; ncol <numcol; ncol++) { // color
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) {
if (clt_data[i][ncol] != null) { if (clt_data[i][ncol] != null) {
...@@ -2710,7 +2710,7 @@ public class ImageDtt { ...@@ -2710,7 +2710,7 @@ public class ImageDtt {
double [][][] iclt_tile = new double [quad][numcol][]; // in mono some may remain null double [][][] iclt_tile = new double [quad][numcol][]; // in mono some may remain null
double [] clt_tile; double [] clt_tile;
double scale = 0.25; // matching iclt_2d double scale = 0.25; // matching iclt_2d
for (int i = 0; i < quad; i++) { for (int i = 0; i < quad; i++) { // USED in lwir
for (int ncol = 0; ncol <numcol; ncol++) if (clt_data[i][ncol] != null) { // color for (int ncol = 0; ncol <numcol; ncol++) if (clt_data[i][ncol] != null) { // color
// double [] clt_tile = new double [transform_size*transform_size]; // double [] clt_tile = new double [transform_size*transform_size];
for (int dct_mode = 0; dct_mode < 4; dct_mode++){ for (int dct_mode = 0; dct_mode < 4; dct_mode++){
...@@ -2772,9 +2772,9 @@ public class ImageDtt { ...@@ -2772,9 +2772,9 @@ public class ImageDtt {
double [][][] tiles_debayered = new double [quad][numcol][]; double [][][] tiles_debayered = new double [quad][numcol][];
for (int i =0; i<quad; i++){ for (int i =0; i<quad; i++){
for (int ncol = 0; ncol < numcol; ncol++) if (iclt_tile[i][ncol] != null) { for (int ncol = 0; ncol < numcol; ncol++) if (iclt_tile[i][ncol] != null) {
if (isMonochrome()) { if (isMonochrome()) { // used in lwir
tiles_debayered[i][ncol] = iclt_tile[i][ncol]; tiles_debayered[i][ncol] = iclt_tile[i][ncol];
} else { } else { // used in lwir
tiles_debayered[i][ncol] = tile_debayer_shot_corr( tiles_debayered[i][ncol] = tile_debayer_shot_corr(
(ncol != 2), // red or blue (false - green) (ncol != 2), // red or blue (false - green)
iclt_tile[i][ncol], iclt_tile[i][ncol],
...@@ -2797,7 +2797,7 @@ public class ImageDtt { ...@@ -2797,7 +2797,7 @@ public class ImageDtt {
} }
sdfa_instance.showArrays(dbg_tile, 2* transform_size, 2* transform_size, true, "tiles_debayered_x"+tileX+"_y"+tileY, titles); sdfa_instance.showArrays(dbg_tile, 2* transform_size, 2* transform_size, true, "tiles_debayered_x"+tileX+"_y"+tileY, titles);
} }
// ... used in lwir
double [] max_diff = null; double [] max_diff = null;
if ((disparity_map != null) && (disparity_map.length >= (IMG_DIFF0_INDEX + quad))){ if ((disparity_map != null) && (disparity_map.length >= (IMG_DIFF0_INDEX + quad))){
max_diff = new double[quad]; max_diff = new double[quad];
...@@ -2854,7 +2854,7 @@ public class ImageDtt { ...@@ -2854,7 +2854,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
// final double [][] dbg_distort = debug_distort? (new double [4*quad][tilesX*tilesY]) : null; // final double [][] dbg_distort = debug_distort? (new double [4*quad][tilesX*tilesY]) : null;
if (dbg_distort != null) { if ((dbg_distort != null) &&(globalDebugLevel >=0)) {
(new ShowDoubleFloatArrays()).showArrays(dbg_distort, tilesX, tilesY, true, "disparity_distortions"); // , dbg_titles); (new ShowDoubleFloatArrays()).showArrays(dbg_distort, tilesX, tilesY, true, "disparity_distortions"); // , dbg_titles);
} }
...@@ -2866,11 +2866,11 @@ public class ImageDtt { ...@@ -2866,11 +2866,11 @@ public class ImageDtt {
return clt_data; return clt_data;
} }
public boolean dmExists(double [][] dm, int indx) { public boolean dmExists(double [][] dm, int indx) { // not used in lwir or else
return (dm != null) && (dm.length > indx) && (dm[indx]!= null); return (dm != null) && (dm.length > indx) && (dm[indx]!= null);
} }
public double [][] tile_combine_rgba( public double [][] tile_combine_rgba( // used in lwir
double [][][] iclt_tile, // [port][numcol][256] // in mono some are null double [][][] iclt_tile, // [port][numcol][256] // in mono some are null
double [] ports_rgb, // average values of R,G,B for each camera (R0,R1,...,B2,B3) double [] ports_rgb, // average values of R,G,B for each camera (R0,R1,...,B2,B3)
double [] max_diff, // maximal (weighted) deviation of each channel from the average double [] max_diff, // maximal (weighted) deviation of each channel from the average
...@@ -2993,7 +2993,7 @@ public class ImageDtt { ...@@ -2993,7 +2993,7 @@ public class ImageDtt {
} // or (int i = 0; i < tile_len; i++){ } // or (int i = 0; i < tile_len; i++){
} else if (usedPorts > 0){ // just copy from a single channel } else if (usedPorts > 0){ // just copy from a single channel // not used in lwir
for (int ip = 0; ip < ports; ip++) if ((port_mask & ( 1 << ip)) != 0){ for (int ip = 0; ip < ports; ip++) if ((port_mask & ( 1 << ip)) != 0){
for (int i = 0; i < tile_len; i++){ for (int i = 0; i < tile_len; i++){
for (int ncol = 0; ncol < numcol; ncol++) if (iclt_tile[0][ncol] != null){ for (int ncol = 0; ncol < numcol; ncol++) if (iclt_tile[0][ncol] != null){
...@@ -3053,7 +3053,7 @@ public class ImageDtt { ...@@ -3053,7 +3053,7 @@ public class ImageDtt {
return rgba; return rgba;
} }
public void dust_remove( // redistribute weight between 3 best ports (use only when all 3 are enabled) public void dust_remove( // redistribute weight between 3 best ports (use only when all 3 are enabled) // USED in lwir
double [][] port_weights) double [][] port_weights)
{ {
int np = port_weights.length; int np = port_weights.length;
...@@ -3073,7 +3073,7 @@ public class ImageDtt { ...@@ -3073,7 +3073,7 @@ public class ImageDtt {
} }
public double [] tile_debayer_shot_corr( public double [] tile_debayer_shot_corr( // USED in lwir
boolean rb, boolean rb,
double [] tile, double [] tile,
int tile_size, int tile_size,
...@@ -3099,7 +3099,7 @@ public class ImageDtt { ...@@ -3099,7 +3099,7 @@ public class ImageDtt {
} }
public double [] tile_debayer( public double [] tile_debayer( // USED in lwir
boolean rb, boolean rb,
double [] tile, double [] tile,
int tile_size) int tile_size)
...@@ -3203,7 +3203,7 @@ public class ImageDtt { ...@@ -3203,7 +3203,7 @@ public class ImageDtt {
// return weights for positive x,y, [(radius+a)*(radius+1)] // return weights for positive x,y, [(radius+a)*(radius+1)]
public double [] setMaxXYWeights( public double [] setMaxXYWeights( // not used in lwir
double sigma, double sigma,
int radius){ // ==3.0, ignore data outside sigma * nSigma int radius){ // ==3.0, ignore data outside sigma * nSigma
// //
...@@ -3219,7 +3219,7 @@ public class ImageDtt { ...@@ -3219,7 +3219,7 @@ public class ImageDtt {
// find interpolated location of maximum, return {x,y} or null (if too low or non-existing) // find interpolated location of maximum, return {x,y} or null (if too low or non-existing)
public int [] getMaxXYInt( // find integer pair or null if below threshold public int [] getMaxXYInt( // find integer pair or null if below threshold // not used in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
int data_size, int data_size,
double minMax, // minimal value to consider (at integer location, not interpolated) double minMax, // minimal value to consider (at integer location, not interpolated)
...@@ -3244,7 +3244,7 @@ public class ImageDtt { ...@@ -3244,7 +3244,7 @@ public class ImageDtt {
return rslt; return rslt;
} }
public double [] getMaxXYCm( // get fractiona center as a "center of mass" inside circle/square from the integer max public double [] getMaxXYCm( // get fractiona center as a "center of mass" inside circle/square from the integer max // not used in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
int data_size, int data_size,
int [] icenter, // integer center coordinates (relative to top left) int [] icenter, // integer center coordinates (relative to top left)
...@@ -3287,7 +3287,7 @@ public class ImageDtt { ...@@ -3287,7 +3287,7 @@ public class ImageDtt {
return rslt; return rslt;
} }
public double [] getMaxXSOrtho( // // get fractional center using a quadratic polynomial public double [] getMaxXSOrtho( // // get fractional center using a quadratic polynomial // not used in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
double [] enhortho_scales, // [data_size] double [] enhortho_scales, // [data_size]
int data_size, int data_size,
...@@ -3355,7 +3355,7 @@ public class ImageDtt { ...@@ -3355,7 +3355,7 @@ public class ImageDtt {
// balance strength? Or just assume appropriate window // balance strength? Or just assume appropriate window
// maybe optimized to symmetrical data // maybe optimized to symmetrical data
public double [] getMaxXSOrtho2( // get fractional center using a quadratic polynomial public double [] getMaxXSOrtho2( // get fractional center using a quadratic polynomial // not used in lwir
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
double [] vweights, // [data_size] double [] vweights, // [data_size]
int data_size, int data_size,
...@@ -3435,7 +3435,7 @@ public class ImageDtt { ...@@ -3435,7 +3435,7 @@ public class ImageDtt {
public double [] getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial public double [] getMaxXYPoly( // get interpolated maximum coordinates using 2-nd degree polynomial // not used in lwir
PolynomialApproximation pa, PolynomialApproximation pa,
double [] data, // [data_size * data_size] double [] data, // [data_size * data_size]
int data_size, int data_size,
...@@ -3517,7 +3517,7 @@ public class ImageDtt { ...@@ -3517,7 +3517,7 @@ public class ImageDtt {
// perform 2d clt, result is [tileY][tileX][cc_sc_cs_ss][index_in_tile] // perform 2d clt, result is [tileY][tileX][cc_sc_cs_ss][index_in_tile]
public double [][][][] clt_2d( public double [][][][] clt_2d( // not used in lwir
final double [] dpixels, final double [] dpixels,
final int width, final int width,
final int dct_size, final int dct_size,
...@@ -3610,7 +3610,7 @@ public class ImageDtt { ...@@ -3610,7 +3610,7 @@ public class ImageDtt {
return dct_data; return dct_data;
} }
public double [] iclt_2d( public double [] iclt_2d( // USED in lwir
final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size] final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size]
final int dct_size, final int dct_size,
final int window_type, final int window_type,
...@@ -3719,7 +3719,7 @@ public class ImageDtt { ...@@ -3719,7 +3719,7 @@ public class ImageDtt {
return dpixels; return dpixels;
} }
public double [] iclt_2d_debug_gpu( public double [] iclt_2d_debug_gpu( // not used in lwir
final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size] final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size]
final int dct_size, final int dct_size,
final int window_type, final int window_type,
...@@ -3910,7 +3910,7 @@ public class ImageDtt { ...@@ -3910,7 +3910,7 @@ public class ImageDtt {
// in monochrome mode only MONO_CHN == GREEN_CHN is used, R and B are null // in monochrome mode only MONO_CHN == GREEN_CHN is used, R and B are null
public double [][] combineRBGATiles( public double [][] combineRBGATiles( // USED in lwir
final double [][][][] texture_tiles, // array [tilesY][tilesX][4][4*transform_size] or [tilesY][tilesX]{null} final double [][][][] texture_tiles, // array [tilesY][tilesX][4][4*transform_size] or [tilesY][tilesX]{null}
final int transform_size, final int transform_size,
final boolean overlap, // when false - output each tile as 16x16, true - overlap to make 8x8 final boolean overlap, // when false - output each tile as 16x16, true - overlap to make 8x8
...@@ -3993,7 +3993,7 @@ public class ImageDtt { ...@@ -3993,7 +3993,7 @@ public class ImageDtt {
dpixels[chn][start_line + j] += texture_tile[schn][n2 * i + j]; dpixels[chn][start_line + j] += texture_tile[schn][n2 * i + j];
} }
} else if ((i >= n_half) && (i < (n2-n_half))) { } else if ((i >= n_half) && (i < (n2-n_half))) {
for (int j = n_half; j < (n2 - n_half); j++) { for (int j = n_half; j < (n2 - n_half); j++) { // not used in lwir
dpixels[chn][start_line + j] += texture_tile[schn][n2 * i + j]; dpixels[chn][start_line + j] += texture_tile[schn][n2 * i + j];
} }
} }
...@@ -4023,7 +4023,7 @@ public class ImageDtt { ...@@ -4023,7 +4023,7 @@ public class ImageDtt {
} }
} }
} else if ((i >= n_half) && (i < (n2-n_half))) { } else if ((i >= n_half) && (i < (n2-n_half))) {
for (int j = n_half; j < (n2 - n_half); j++) { for (int j = n_half; j < (n2 - n_half); j++) { // not used in lwir
if ( ((tileX > 0) && (tileX < lastX)) || if ( ((tileX > 0) && (tileX < lastX)) ||
((tileX == 0) && (j >= n_half)) || ((tileX == 0) && (j >= n_half)) ||
((tileX == lastX) && (j < (n2 - n_half)))) { ((tileX == lastX) && (j < (n2 - n_half)))) {
...@@ -4038,7 +4038,7 @@ public class ImageDtt { ...@@ -4038,7 +4038,7 @@ public class ImageDtt {
} }
} else { //if (overlap) - just copy tiles w/o overlapping } else { //if (overlap) - just copy tiles w/o overlapping
for (int i = 0; i < n2;i++){ for (int i = 0; i < n2;i++){ // not used in lwir
for (int chn = 0; chn < texture_tile.length; chn++) { for (int chn = 0; chn < texture_tile.length; chn++) {
int schn = chn; int schn = chn;
if (isMonochrome() && (chn<3)) { if (isMonochrome() && (chn<3)) {
...@@ -4071,7 +4071,7 @@ public class ImageDtt { ...@@ -4071,7 +4071,7 @@ public class ImageDtt {
public double [][][][] clt_shiftXY( public double [][][][] clt_shiftXY( // not used in lwir
final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size] final double [][][][] dct_data, // array [tilesY][tilesX][4][dct_size*dct_size]
final int dct_size, final int dct_size,
final double shiftX, final double shiftX,
...@@ -4153,7 +4153,7 @@ public class ImageDtt { ...@@ -4153,7 +4153,7 @@ public class ImageDtt {
return rslt; return rslt;
} }
public double [][][][] clt_correlate( public double [][][][] clt_correlate( // not used in lwir
final double [][][][] data1, // array [tilesY][tilesX][4][dct_size*dct_size] final double [][][][] data1, // array [tilesY][tilesX][4][dct_size*dct_size]
final double [][][][] data2, // array [tilesY][tilesX][4][dct_size*dct_size] final double [][][][] data2, // array [tilesY][tilesX][4][dct_size*dct_size]
final int dct_size, final int dct_size,
...@@ -4255,7 +4255,7 @@ public class ImageDtt { ...@@ -4255,7 +4255,7 @@ public class ImageDtt {
return rslt; return rslt;
} }
public void clt_lpf( public void clt_lpf( // USED in lwir
final double sigma, final double sigma,
final double [][][][] clt_data, final double [][][][] clt_data,
final int dct_size, final int dct_size,
...@@ -4354,7 +4354,7 @@ public class ImageDtt { ...@@ -4354,7 +4354,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
} }
public void clt_dtt2( // transform dcct2, dsct2, dcst2, dsst2 public void clt_dtt2( // transform dcct2, dsct2, dcst2, dsst2 // not used in lwir
final double [][][][] data, final double [][][][] data,
final boolean transpose, // when doing inverse transform, the data comes in transposed form, so CS <->SC final boolean transpose, // when doing inverse transform, the data comes in transposed form, so CS <->SC
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -4387,7 +4387,7 @@ public class ImageDtt { ...@@ -4387,7 +4387,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
} }
public double [][][] clt_corr_quad( // combine 4 correlation quadrants after DTT2 public double [][][] clt_corr_quad( // combine 4 correlation quadrants after DTT2 // not used in lwir
final double [][][][] data, final double [][][][] data,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel) final int globalDebugLevel)
...@@ -4505,7 +4505,7 @@ public class ImageDtt { ...@@ -4505,7 +4505,7 @@ public class ImageDtt {
*/ */
// extract correlation result in linescan order (for visualization) // extract correlation result in linescan order (for visualization)
public double [] corr_dbg( public double [] corr_dbg( // not used in lwir
final double [][][] corr_data, final double [][][] corr_data,
final int corr_size, final int corr_size,
final double border_contrast, final double border_contrast,
...@@ -4555,7 +4555,7 @@ public class ImageDtt { ...@@ -4555,7 +4555,7 @@ public class ImageDtt {
// extract correlation result in linescan order (for visualization) // extract correlation result in linescan order (for visualization)
public double [][] corr_partial_dbg( public double [][] corr_partial_dbg( // not used in lwir
final double [][][][][] corr_data, final double [][][][][] corr_data,
final int corr_size, final int corr_size,
final int pairs, final int pairs,
...@@ -4624,7 +4624,7 @@ public class ImageDtt { ...@@ -4624,7 +4624,7 @@ public class ImageDtt {
public double [][][][][] cltStack( public double [][][][][] cltStack( // not used in lwir
final ImageStack imageStack, final ImageStack imageStack,
final int subcamera, // final int subcamera, //
final CLTParameters cltParameters, // final CLTParameters cltParameters, //
...@@ -4667,7 +4667,7 @@ public class ImageDtt { ...@@ -4667,7 +4667,7 @@ public class ImageDtt {
// extract DCT transformed parameters in linescan order (for visualization) // extract DCT transformed parameters in linescan order (for visualization)
public double [][] clt_dbg( public double [][] clt_dbg( // not used in lwir
final double [][][][] dct_data, final double [][][][] dct_data,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final int globalDebugLevel) final int globalDebugLevel)
...@@ -4706,7 +4706,7 @@ public class ImageDtt { ...@@ -4706,7 +4706,7 @@ public class ImageDtt {
return dct_data_out; return dct_data_out;
} }
void clt_convert_double_kernel( // converts double resolution kernel void clt_convert_double_kernel( // converts double resolution kernel // not used in lwir
double [] src_kernel, // double [] src_kernel, //
double [] dst_kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) + extra_items size - kernel and dx, dy to the nearest 1/2 pixels + actual full center shift) double [] dst_kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) + extra_items size - kernel and dx, dy to the nearest 1/2 pixels + actual full center shift)
int src_size, // 64 int src_size, // 64
...@@ -4755,7 +4755,7 @@ public class ImageDtt { ...@@ -4755,7 +4755,7 @@ public class ImageDtt {
dst_kernel[indx++] = 0.5*(sy / s); dst_kernel[indx++] = 0.5*(sy / s);
} }
void clt_normalize_kernel( // void clt_normalize_kernel( // not used in lwir
double [] kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) + 4 size (last (2*dtt_size-1) are not modified) double [] kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) + 4 size (last (2*dtt_size-1) are not modified)
double [] window, // normalizes result kernel * window to have sum of elements == 1.0 double [] window, // normalizes result kernel * window to have sum of elements == 1.0
int dtt_size, // 8 int dtt_size, // 8
...@@ -4779,7 +4779,7 @@ public class ImageDtt { ...@@ -4779,7 +4779,7 @@ public class ImageDtt {
} }
} }
void clt_symmetrize_kernel( // void clt_symmetrize_kernel( // not used in lwir
double [] kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) +2 size (last 2 are not modified) double [] kernel, // should be (2*dtt_size-1) * (2*dtt_size-1) +2 size (last 2 are not modified)
double [][] sym_kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift double [][] sym_kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift
final int dtt_size) // 8 final int dtt_size) // 8
...@@ -4806,7 +4806,7 @@ public class ImageDtt { ...@@ -4806,7 +4806,7 @@ public class ImageDtt {
} }
} }
void clt_dtt3_kernel( // void clt_dtt3_kernel( // not used in lwir
double [][] kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift double [][] kernels, // set of 4 SS, AS, SA, AA kdernels, each dtt_size * dtt_size (may have 5-th with center shift
final int dtt_size, // 8 final int dtt_size, // 8
DttRad2 dtt) DttRad2 dtt)
...@@ -4834,8 +4834,8 @@ public class ImageDtt { ...@@ -4834,8 +4834,8 @@ public class ImageDtt {
public double dyc_dx = 0.0; public double dyc_dx = 0.0;
public double dyc_dy = 0.0; public double dyc_dy = 0.0;
public CltExtra(){} public CltExtra(){} // not used in lwir
public CltExtra(double [] data) public CltExtra(double [] data) // USED in lwir
{ {
data_x = data[0]; // kernel data is relative to this displacement X (0.5 pixel increments) data_x = data[0]; // kernel data is relative to this displacement X (0.5 pixel increments)
data_y = data[1]; // kernel data is relative to this displacement Y (0.5 pixel increments) data_y = data[1]; // kernel data is relative to this displacement Y (0.5 pixel increments)
...@@ -4846,7 +4846,7 @@ public class ImageDtt { ...@@ -4846,7 +4846,7 @@ public class ImageDtt {
dyc_dx = data[6]; dyc_dx = data[6];
dyc_dy = data[7]; dyc_dy = data[7];
} }
public double [] getArray() public double [] getArray() // not used in lwir
{ {
double [] rslt = { double [] rslt = {
data_x, data_x,
...@@ -4862,7 +4862,7 @@ public class ImageDtt { ...@@ -4862,7 +4862,7 @@ public class ImageDtt {
} }
} }
public void offsetKernelSensor( public void offsetKernelSensor( // not used in lwir
double [][] clt_tile, // clt tile, including [4] - metadata double [][] clt_tile, // clt tile, including [4] - metadata
double dx, double dx,
double dy) { double dy) {
...@@ -4873,7 +4873,7 @@ public class ImageDtt { ...@@ -4873,7 +4873,7 @@ public class ImageDtt {
ce.data_y += dy; ce.data_y += dy;
clt_tile[4] = ce.getArray(); clt_tile[4] = ce.getArray();
} }
public void clt_fill_coord_corr( public void clt_fill_coord_corr( // not used in lwir
final int kern_step, // distance between kernel centers, in pixels. final int kern_step, // distance between kernel centers, in pixels.
final double [][][][][] clt_data, final double [][][][][] clt_data,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -4934,7 +4934,7 @@ public class ImageDtt { ...@@ -4934,7 +4934,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
} }
public class CltTile{ public class CltTile{ // not used in lwir
public double [][] tile = new double[4][]; // 4 CLT tiles public double [][] tile = new double[4][]; // 4 CLT tiles
public double fract_x; // remaining fractional offset X public double fract_x; // remaining fractional offset X
public double fract_y; // remaining fractional offset X public double fract_y; // remaining fractional offset X
...@@ -4948,7 +4948,7 @@ public class ImageDtt { ...@@ -4948,7 +4948,7 @@ public class ImageDtt {
// return // return
// kernel [0][0] is centered at (-kernel_step/2,-kernel_step/2) // kernel [0][0] is centered at (-kernel_step/2,-kernel_step/2)
public double [] extract_correct_tile( // return a pair of residual offsets public double [] extract_correct_tile( // return a pair of residual offsets // USED in lwir (except debug, fpga, gpu)
double [][] image_data, double [][] image_data,
int width, // image width int width, // image width
double [][][][][] clt_kernels, // [color][tileY][tileX][band][pixel] double [][][][][] clt_kernels, // [color][tileY][tileX][band][pixel]
...@@ -5495,7 +5495,7 @@ public class ImageDtt { ...@@ -5495,7 +5495,7 @@ public class ImageDtt {
} }
// public // public
public void convolve_tile( public void convolve_tile( // USED in lwir
double [][] data, // array [transform_size*transform_size], will be updated DTT4 converted double [][] data, // array [transform_size*transform_size], will be updated DTT4 converted
double [][] kernel, // array [4][transform_size*transform_size] DTT3 converted double [][] kernel, // array [4][transform_size*transform_size] DTT3 converted
int transform_size, int transform_size,
...@@ -5556,7 +5556,7 @@ public class ImageDtt { ...@@ -5556,7 +5556,7 @@ public class ImageDtt {
} }
} }
public void fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations public void fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations // USED in lwir
double [][] clt_tile, double [][] clt_tile,
int transform_size, int transform_size,
double shiftX, double shiftX,
...@@ -5654,7 +5654,7 @@ public class ImageDtt { ...@@ -5654,7 +5654,7 @@ public class ImageDtt {
public double [][][][] mdctScale( public double [][][][] mdctScale( // not used in lwir
final ImageStack imageStack, final ImageStack imageStack,
final int subcamera, // not needed final int subcamera, // not needed
final EyesisCorrectionParameters.DCTParameters dctParameters, // final EyesisCorrectionParameters.DCTParameters dctParameters, //
...@@ -5699,7 +5699,7 @@ public class ImageDtt { ...@@ -5699,7 +5699,7 @@ public class ImageDtt {
public double [][][] lapped_dct_scale( // scale image to 8/9 size in each direction public double [][][] lapped_dct_scale( // scale image to 8/9 size in each direction // not used in lwir
final double [] dpixels, final double [] dpixels,
final int width, final int width,
final int dct_size, final int dct_size,
...@@ -5783,7 +5783,7 @@ public class ImageDtt { ...@@ -5783,7 +5783,7 @@ public class ImageDtt {
return dct_data; return dct_data;
} }
public void dct_scale( public void dct_scale( // not used in lwir
final double scale_hor, // < 1.0 - enlarge in dct domain (shrink in time/space) final double scale_hor, // < 1.0 - enlarge in dct domain (shrink in time/space)
final double scale_vert, // < 1.0 - enlarge in dct domain (shrink in time/space) final double scale_vert, // < 1.0 - enlarge in dct domain (shrink in time/space)
final boolean normalize, // preserve weighted dct values final boolean normalize, // preserve weighted dct values
...@@ -5913,7 +5913,7 @@ public class ImageDtt { ...@@ -5913,7 +5913,7 @@ public class ImageDtt {
* From Stephan Preibisch's Multithreading.java class. See: * From Stephan Preibisch's Multithreading.java class. See:
* http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD * http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD
*/ */
public static Thread[] newThreadArray(int maxCPUs) { public static Thread[] newThreadArray(int maxCPUs) { // USED in lwir
int n_cpus = Runtime.getRuntime().availableProcessors(); int n_cpus = Runtime.getRuntime().availableProcessors();
if (n_cpus>maxCPUs)n_cpus=maxCPUs; if (n_cpus>maxCPUs)n_cpus=maxCPUs;
return new Thread[n_cpus]; return new Thread[n_cpus];
...@@ -5922,7 +5922,7 @@ public class ImageDtt { ...@@ -5922,7 +5922,7 @@ public class ImageDtt {
* From Stephan Preibisch's Multithreading.java class. See: * From Stephan Preibisch's Multithreading.java class. See:
* http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD * http://repo.or.cz/w/trakem2.git?a=blob;f=mpi/fruitfly/general/MultiThreading.java;hb=HEAD
*/ */
public static void startAndJoin(Thread[] threads) public static void startAndJoin(Thread[] threads) // USED in lwir
{ {
for (int ithread = 0; ithread < threads.length; ++ithread) for (int ithread = 0; ithread < threads.length; ++ithread)
{ {
...@@ -5942,7 +5942,7 @@ public class ImageDtt { ...@@ -5942,7 +5942,7 @@ public class ImageDtt {
// temporary switch between old/new implementations // temporary switch between old/new implementations
public double [][][][][][] clt_aberrations_quad_corr( public double [][][][][][] clt_aberrations_quad_corr( // USED in lwir (new branch)
final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
...@@ -6069,7 +6069,7 @@ public class ImageDtt { ...@@ -6069,7 +6069,7 @@ public class ImageDtt {
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
globalDebugLevel); globalDebugLevel);
} else { // old way? } else { // old way?
return clt_aberrations_quad_corr_old( return clt_aberrations_quad_corr_old( // not used in lwir
imgdtt_params, // Now just extra correlation parameters, later will include, most others imgdtt_params, // Now just extra correlation parameters, later will include, most others
macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
...@@ -6134,7 +6134,7 @@ public class ImageDtt { ...@@ -6134,7 +6134,7 @@ public class ImageDtt {
globalDebugLevel); globalDebugLevel);
} }
} }
public double [][][][][][] clt_aberrations_quad_corr_old( public double [][][][][][] clt_aberrations_quad_corr_old( // not used in lwir
final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others final ImageDttParameters imgdtt_params, // Now just extra correlation parameters, later will include, most others
final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles final int macro_scale, // to correlate tile data instead of the pixel data: 1 - pixels, 8 - tiles
final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile final int [][] tile_op, // [tilesY][tilesX] - what to do - 0 - nothing for this tile
...@@ -7396,7 +7396,7 @@ public class ImageDtt { ...@@ -7396,7 +7396,7 @@ public class ImageDtt {
* @return * @return
*/ */
public double [] tileInterCamCorrs( public double [] tileInterCamCorrs( // not used in lwir
final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
...@@ -7435,7 +7435,7 @@ public class ImageDtt { ...@@ -7435,7 +7435,7 @@ public class ImageDtt {
} }
public double [] tileInterCamCorrs( public double [] tileInterCamCorrs( // not used in lwir
final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
// maximums. That reduces the residual disparity, but works continuously when it is known the maximum should be near zero // maximums. That reduces the residual disparity, but works continuously when it is known the maximum should be near zero
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
...@@ -7646,7 +7646,7 @@ public class ImageDtt { ...@@ -7646,7 +7646,7 @@ public class ImageDtt {
* @return {disparity, disp_hor, disp_vert, disp_diagm, disp_diago, strength, str_hor, str_vert, str_diagm, str_diago} * @return {disparity, disp_hor, disp_vert, disp_diagm, disp_diago, strength, str_hor, str_vert, str_diagm, str_diago}
* indexed by DISP_*_INDEX and STR_*_INDEX constants * indexed by DISP_*_INDEX and STR_*_INDEX constants
*/ */
public double [] tileCorrs( public double [] tileCorrs( // USED in lwir
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final boolean get4dirs, // calculate disparity/strength for each of the 4 directions final boolean get4dirs, // calculate disparity/strength for each of the 4 directions
...@@ -7676,7 +7676,7 @@ public class ImageDtt { ...@@ -7676,7 +7676,7 @@ public class ImageDtt {
col_weights, // double [] col_weights, col_weights, // double [] col_weights,
fatzero); // double fat_zero) fatzero); // double fat_zero)
if (ml_center_corr != null) { if (ml_center_corr != null) { // USED in lwir
corr2d.corrCenterValues( corr2d.corrCenterValues(
ml_hwidth, // int hwidth, ml_hwidth, // int hwidth,
clt_parameters.img_dtt.corr_offset, //double offset, clt_parameters.img_dtt.corr_offset, //double offset,
...@@ -7717,7 +7717,7 @@ public class ImageDtt { ...@@ -7717,7 +7717,7 @@ public class ImageDtt {
// use clt_mismatch for that // use clt_mismatch for that
double strength = 0.0; double strength = 0.0;
double disparity = 0.0; double disparity = 0.0;
if (ixy != null) { if (ixy != null) { // USED in lwir
strength = strip_combo[ixy[0]+clt_parameters.transform_size-1]; // strength at integer max on axis strength = strip_combo[ixy[0]+clt_parameters.transform_size-1]; // strength at integer max on axis
disparity = -ixy[0]; disparity = -ixy[0];
result[STR_FULL_INDEX] = strength; result[STR_FULL_INDEX] = strength;
...@@ -7735,7 +7735,7 @@ public class ImageDtt { ...@@ -7735,7 +7735,7 @@ public class ImageDtt {
} }
// removed HOR/VERT // removed HOR/VERT
// proceed only if CM correlation result is non-null // for compatibility with old code we need it to run regardless of the strength of the normal correlation // proceed only if CM correlation result is non-null // for compatibility with old code we need it to run regardless of the strength of the normal correlation
if (corr_stat != null) { if (corr_stat != null) { // USED in lwir
disparity = -corr_stat[0]; disparity = -corr_stat[0];
result[DISP_FULL_INDEX] = disparity; result[DISP_FULL_INDEX] = disparity;
// see if strength is enough to proceed with LMA/poly (otherwise keep disp/strength // see if strength is enough to proceed with LMA/poly (otherwise keep disp/strength
...@@ -7763,7 +7763,7 @@ public class ImageDtt { ...@@ -7763,7 +7763,7 @@ public class ImageDtt {
lma_disparity_strength[0],lma_disparity_strength[1])); lma_disparity_strength[0],lma_disparity_strength[1]));
} }
// if enabled overwrite - replace DISPARITY_INDEX_CM and DISPARITY_STRENGTH_INDEX // if enabled overwrite - replace DISPARITY_INDEX_CM and DISPARITY_STRENGTH_INDEX
if (clt_parameters.rig.use_poly) { if (clt_parameters.rig.use_poly) { // not used in lwir
disparity = lma_disparity_strength[0]; disparity = lma_disparity_strength[0];
strength = lma_disparity_strength[1]; strength = lma_disparity_strength[1];
result[STR_FULL_INDEX] = strength; result[STR_FULL_INDEX] = strength;
...@@ -7776,7 +7776,7 @@ public class ImageDtt { ...@@ -7776,7 +7776,7 @@ public class ImageDtt {
// Correction for far foreground objects // Correction for far foreground objects
// if ((clt_parameters.img_dtt.fo_correct && (strength > 0 * clt_parameters.img_dtt.fo_min_strength)) || get4dirs) { // if ((clt_parameters.img_dtt.fo_correct && (strength > 0 * clt_parameters.img_dtt.fo_min_strength)) || get4dirs) {
// no fo_correct for the rig! // no fo_correct for the rig!
if (get4dirs) { if (get4dirs) { // USED in lwir
// try all dirs: // try all dirs:
dir_corr_strength = corr2d.corr4dirsLMA( dir_corr_strength = corr2d.corr4dirsLMA(
clt_parameters.img_dtt, // ImageDttParameters clt_parameters.img_dtt, clt_parameters.img_dtt, // ImageDttParameters clt_parameters.img_dtt,
...@@ -7796,31 +7796,31 @@ public class ImageDtt { ...@@ -7796,31 +7796,31 @@ public class ImageDtt {
dir_corr_strength[0][0],dir_corr_strength[0][1],dir_corr_strength[1][0],dir_corr_strength[1][1], dir_corr_strength[0][0],dir_corr_strength[0][1],dir_corr_strength[1][0],dir_corr_strength[1][1],
dir_corr_strength[2][0],dir_corr_strength[2][1],dir_corr_strength[3][0],dir_corr_strength[3][1])); dir_corr_strength[2][0],dir_corr_strength[2][1],dir_corr_strength[3][0],dir_corr_strength[3][1]));
} }
if (dir_corr_strength[0] != null) { if (dir_corr_strength[0] != null) { // USED in lwir
result[DISP_HOR_INDEX] = dir_corr_strength[0][0]; result[DISP_HOR_INDEX] = dir_corr_strength[0][0];
result[STR_HOR_INDEX] = dir_corr_strength[0][1]; result[STR_HOR_INDEX] = dir_corr_strength[0][1];
} else { } else { // USED in lwir
result[DISP_HOR_INDEX] = Double.NaN; result[DISP_HOR_INDEX] = Double.NaN;
result[STR_HOR_INDEX] = 0.0; result[STR_HOR_INDEX] = 0.0;
} }
if (dir_corr_strength[1] != null) { if (dir_corr_strength[1] != null) { // USED in lwir
result[DISP_VERT_INDEX] = dir_corr_strength[1][0]; result[DISP_VERT_INDEX] = dir_corr_strength[1][0];
result[STR_VERT_INDEX] = dir_corr_strength[1][1]; result[STR_VERT_INDEX] = dir_corr_strength[1][1];
} else { } else { // USED in lwir
result[DISP_VERT_INDEX] = Double.NaN; result[DISP_VERT_INDEX] = Double.NaN;
result[STR_VERT_INDEX] = 0.0; result[STR_VERT_INDEX] = 0.0;
} }
if (dir_corr_strength[2] != null) { if (dir_corr_strength[2] != null) { // USED in lwir
result[DISP_DIAGM_INDEX] = dir_corr_strength[2][0]; result[DISP_DIAGM_INDEX] = dir_corr_strength[2][0];
result[STR_DIAGM_INDEX] = dir_corr_strength[2][1]; result[STR_DIAGM_INDEX] = dir_corr_strength[2][1];
} else { } else { // USED in lwir
result[DISP_DIAGM_INDEX] = Double.NaN; result[DISP_DIAGM_INDEX] = Double.NaN;
result[STR_DIAGM_INDEX] = 0.0; result[STR_DIAGM_INDEX] = 0.0;
} }
if (dir_corr_strength[3] != null) { if (dir_corr_strength[3] != null) { // USED in lwir
result[DISP_DIAGO_INDEX] = dir_corr_strength[3][0]; result[DISP_DIAGO_INDEX] = dir_corr_strength[3][0];
result[STR_DIAGO_INDEX] = dir_corr_strength[3][1]; result[STR_DIAGO_INDEX] = dir_corr_strength[3][1];
} else { } else { // USED in lwir
result[DISP_DIAGO_INDEX] = Double.NaN; result[DISP_DIAGO_INDEX] = Double.NaN;
result[STR_DIAGO_INDEX] = 0.0; result[STR_DIAGO_INDEX] = 0.0;
...@@ -7855,7 +7855,7 @@ public class ImageDtt { ...@@ -7855,7 +7855,7 @@ public class ImageDtt {
} }
public void generateTextureTiles( public void generateTextureTiles(// not used in lwir
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double extra_disparity, final double extra_disparity,
final int quad, // number of subcameras final int quad, // number of subcameras
...@@ -7996,7 +7996,7 @@ public class ImageDtt { ...@@ -7996,7 +7996,7 @@ public class ImageDtt {
// public double [][][][][][] clt_bi_quad( // public double [][][][][][] clt_bi_quad(
public double [][][][][][][] clt_bi_quad_dbg( public double [][][][][][][] clt_bi_quad_dbg(// not used in lwir
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
...@@ -8805,7 +8805,7 @@ public class ImageDtt { ...@@ -8805,7 +8805,7 @@ public class ImageDtt {
return clt_bidata; return clt_bidata;
} }
public double [][][][][][][] clt_bi_quad( public double [][][][][][][] clt_bi_quad(// USED in lwir
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles final boolean notch_mode, // use notch filter for inter-camera correlation to detect poles
...@@ -8856,7 +8856,7 @@ public class ImageDtt { ...@@ -8856,7 +8856,7 @@ public class ImageDtt {
final int nTilesInChn=tilesX*tilesY; final int nTilesInChn=tilesX*tilesY;
// clt_data does not need to be for the whole image (no, it is used for textures) // clt_data does not need to be for the whole image (no, it is used for textures)
final double [][][][][][][] clt_bidata = (keep_clt_data)? (new double[2][][][][][][]):null; final double [][][][][][][] clt_bidata = (keep_clt_data)? (new double[2][][][][][][]):null;
if (clt_bidata != null) { if (clt_bidata != null) {// not used in lwir
clt_bidata[0] = new double[quad_main][numcol][tilesY][tilesX][][]; clt_bidata[0] = new double[quad_main][numcol][tilesY][tilesX][][];
clt_bidata[1] = new double[quad_aux][numcol][tilesY][tilesX][][]; clt_bidata[1] = new double[quad_aux][numcol][tilesY][tilesX][][];
} }
...@@ -8871,7 +8871,7 @@ public class ImageDtt { ...@@ -8871,7 +8871,7 @@ public class ImageDtt {
col_weights[2] = 1.0;// green color/mono col_weights[2] = 1.0;// green color/mono
col_weights[0] = 0; col_weights[0] = 0;
col_weights[1] = 0; col_weights[1] = 0;
} else { } else {// not used in lwir
col_weights[2] = 1.0/(1.0 + clt_parameters.corr_red + clt_parameters.corr_blue); // green color col_weights[2] = 1.0/(1.0 + clt_parameters.corr_red + clt_parameters.corr_blue); // green color
col_weights[0] = clt_parameters.corr_red * col_weights[2]; col_weights[0] = clt_parameters.corr_red * col_weights[2];
col_weights[1] = clt_parameters.corr_blue * col_weights[2]; col_weights[1] = clt_parameters.corr_blue * col_weights[2];
...@@ -8924,10 +8924,10 @@ public class ImageDtt { ...@@ -8924,10 +8924,10 @@ public class ImageDtt {
final double [] filter_direct= new double[transform_len]; final double [] filter_direct= new double[transform_len];
if (clt_parameters.getCorrSigma(isMonochrome()) == 0) { if (clt_parameters.getCorrSigma(isMonochrome()) == 0) {// not used in lwir
filter_direct[0] = 1.0; filter_direct[0] = 1.0;
for (int i= 1; i<filter_direct.length;i++) filter_direct[i] =0; for (int i= 1; i<filter_direct.length;i++) filter_direct[i] =0;
} else { } else {// USED in lwir
for (int i = 0; i < clt_parameters.transform_size; i++){ for (int i = 0; i < clt_parameters.transform_size; i++){
for (int j = 0; j < clt_parameters.transform_size; j++){ for (int j = 0; j < clt_parameters.transform_size; j++){
filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.getCorrSigma(isMonochrome()))); // FIXME: should be sigma*sigma ! filter_direct[i * clt_parameters.transform_size+j] = Math.exp(-(i*i+j*j)/(2*clt_parameters.getCorrSigma(isMonochrome()))); // FIXME: should be sigma*sigma !
...@@ -8967,13 +8967,13 @@ public class ImageDtt { ...@@ -8967,13 +8967,13 @@ public class ImageDtt {
} }
// add optional initialization of debug layers here // add optional initialization of debug layers here
if (disparity_bimap != null){ if (disparity_bimap != null){
for (int i = 0; i < disparity_bimap.length;i++){ for (int i = 0; i < disparity_bimap.length;i++){// USED in lwir
disparity_bimap[i] = new double [tilesY*tilesX]; disparity_bimap[i] = new double [tilesY*tilesX];
} }
} }
if (ers_delay != null) { if (ers_delay != null) {
ers_delay[0] = new double [quad_main][]; ers_delay[0] = new double [quad_main][]; // not used in lwir
for (int i = 0; i < quad_main; i++) ers_delay[0][i] = new double [tilesX*tilesY]; for (int i = 0; i < quad_main; i++) ers_delay[0][i] = new double [tilesX*tilesY];
ers_delay[1] = new double [quad_aux][]; ers_delay[1] = new double [quad_aux][];
for (int i = 0; i < quad_aux; i++) ers_delay[1][i] = new double [tilesX*tilesY]; for (int i = 0; i < quad_aux; i++) ers_delay[1][i] = new double [tilesX*tilesY];
...@@ -9051,7 +9051,7 @@ public class ImageDtt { ...@@ -9051,7 +9051,7 @@ public class ImageDtt {
} }
double [][] disp_dist_main = new double[2 * quad_main][]; // used to correct 3D correlations double [][] disp_dist_main = new double[2 * quad_main][]; // used to correct 3D correlations
double [][] disp_dist_aux = new double[2 * quad_aux][]; // used to correct 3D correlations double [][] disp_dist_aux = new double[2 * quad_aux][]; // used to correct 3D correlations
if (calc_main) { if (calc_main) {// not used in lwir
centersXY_main = geometryCorrection_main.getPortsCoordinatesAndDerivatives( centersXY_main = geometryCorrection_main.getPortsCoordinatesAndDerivatives(
geometryCorrection_main, // GeometryCorrection gc_main, geometryCorrection_main, // GeometryCorrection gc_main,
false, // boolean use_rig_offsets, false, // boolean use_rig_offsets,
...@@ -9064,7 +9064,7 @@ public class ImageDtt { ...@@ -9064,7 +9064,7 @@ public class ImageDtt {
disparity_main); // + disparity_corr); disparity_main); // + disparity_corr);
} }
if (calc_aux) { if (calc_aux) {
if (calc_main) { // use rig and main coordinates if (calc_main) { // use rig and main coordinates // not used in lwir
centersXY_aux = geometryCorrection_aux.getPortsCoordinatesAndDerivatives( centersXY_aux = geometryCorrection_aux.getPortsCoordinatesAndDerivatives(
geometryCorrection_main, // GeometryCorrection gc_main, geometryCorrection_main, // GeometryCorrection gc_main,
true, // boolean use_rig_offsets, true, // boolean use_rig_offsets,
...@@ -9075,7 +9075,7 @@ public class ImageDtt { ...@@ -9075,7 +9075,7 @@ public class ImageDtt {
centerX, centerX,
centerY, centerY,
disparity_aux); // + disparity_corr); disparity_aux); // + disparity_corr);
} else { } else {// USED in lwir
centersXY_aux = geometryCorrection_aux.getPortsCoordinatesAndDerivatives( centersXY_aux = geometryCorrection_aux.getPortsCoordinatesAndDerivatives(
geometryCorrection_aux, // GeometryCorrection gc_main, geometryCorrection_aux, // GeometryCorrection gc_main,
false, // boolean use_rig_offsets, false, // boolean use_rig_offsets,
...@@ -9090,7 +9090,7 @@ public class ImageDtt { ...@@ -9090,7 +9090,7 @@ public class ImageDtt {
} }
} }
// acquisition time of the tiles centers in scanline times // acquisition time of the tiles centers in scanline times
if (ers_delay != null) { if (ers_delay != null) {// not used in lwir
for (int i = 0; i < quad_main; i++) ers_delay[0][i][nTile] = centersXY_main[i][1]-geometryCorrection_main.woi_tops[i]; for (int i = 0; i < quad_main; i++) ers_delay[0][i][nTile] = centersXY_main[i][1]-geometryCorrection_main.woi_tops[i];
for (int i = 0; i < quad_aux; i++) ers_delay[1][i][nTile] = centersXY_aux[i][1]- geometryCorrection_aux.woi_tops[i]; for (int i = 0; i < quad_aux; i++) ers_delay[1][i][nTile] = centersXY_aux[i][1]- geometryCorrection_aux.woi_tops[i];
} }
...@@ -9137,7 +9137,7 @@ public class ImageDtt { ...@@ -9137,7 +9137,7 @@ public class ImageDtt {
centersXY_aux[3][0]+"\t"+centersXY_aux[3][1]+"\t"); centersXY_aux[3][0]+"\t"+centersXY_aux[3][1]+"\t");
} }
for (int i = 0; i < quad_main; i++) { // quad_main == 0 if not calculated for (int i = 0; i < quad_main; i++) { // quad_main == 0 if not calculated // not used in lwir
clt_data_main[i][chn] = new double [4][]; clt_data_main[i][chn] = new double [4][];
fract_shiftsXY_main[i] = extract_correct_tile( // return a pair of residual offsets fract_shiftsXY_main[i] = extract_correct_tile( // return a pair of residual offsets
image_data_main[i], image_data_main[i],
...@@ -9158,7 +9158,7 @@ public class ImageDtt { ...@@ -9158,7 +9158,7 @@ public class ImageDtt {
} }
for (int i = 0; i < quad_aux; i++) { // quad_aux == 0 if not calculated for (int i = 0; i < quad_aux; i++) { // quad_aux == 0 if not calculated // not used in lwir
clt_data_aux[i][chn] = new double [4][]; clt_data_aux[i][chn] = new double [4][];
fract_shiftsXY_aux[i] = extract_correct_tile( // return a pair of residual offsets fract_shiftsXY_aux[i] = extract_correct_tile( // return a pair of residual offsets
image_data_aux[i], image_data_aux[i],
...@@ -9210,7 +9210,7 @@ public class ImageDtt { ...@@ -9210,7 +9210,7 @@ public class ImageDtt {
} }
// apply residual shift // apply residual shift
for (int i = 0; i < quad_main; i++) { for (int i = 0; i < quad_main; i++) {// not used in lwir
fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations
clt_data_main[i][chn], // double [][] clt_tile, clt_data_main[i][chn], // double [][] clt_tile,
clt_parameters.transform_size, clt_parameters.transform_size,
...@@ -9219,7 +9219,7 @@ public class ImageDtt { ...@@ -9219,7 +9219,7 @@ public class ImageDtt {
((globalDebugLevel > 1) && (chn==0) && (tileX >= debug_tileX - 2) && (tileX <= debug_tileX + 2) && ((globalDebugLevel > 1) && (chn==0) && (tileX >= debug_tileX - 2) && (tileX <= debug_tileX + 2) &&
(tileY >= debug_tileY - 2) && (tileY <= debug_tileY+2))); (tileY >= debug_tileY - 2) && (tileY <= debug_tileY+2)));
} }
for (int i = 0; i < quad_aux; i++) { for (int i = 0; i < quad_aux; i++) {// USED in lwir
fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations fract_shift( // fractional shift in transform domain. Currently uses sin/cos - change to tables with 2? rotations
clt_data_aux[i][chn], // double [][] clt_tile, clt_data_aux[i][chn], // double [][] clt_tile,
clt_parameters.transform_size, clt_parameters.transform_size,
...@@ -9255,7 +9255,7 @@ public class ImageDtt { ...@@ -9255,7 +9255,7 @@ public class ImageDtt {
if (disparity_bimap != null){ // not null - calculate correlations if (disparity_bimap != null){ // not null - calculate correlations
double [] tile_corrs_main = new double[0]; //null; double [] tile_corrs_main = new double[0]; //null;
double [] tile_corrs_aux = new double[0]; //null; double [] tile_corrs_aux = new double[0]; //null;
if (calc_main) { if (calc_main) {// not used in lwir
tile_corrs_main = tileCorrs( tile_corrs_main = tileCorrs(
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
...@@ -9272,7 +9272,7 @@ public class ImageDtt { ...@@ -9272,7 +9272,7 @@ public class ImageDtt {
extra_disparity_main = tile_corrs_main[DISP_FULL_INDEX]; extra_disparity_main = tile_corrs_main[DISP_FULL_INDEX];
if (Double.isNaN(extra_disparity_main)) extra_disparity_main = 0; if (Double.isNaN(extra_disparity_main)) extra_disparity_main = 0;
} }
if (calc_aux) { if (calc_aux) {// USED in lwir
tile_corrs_aux = tileCorrs( tile_corrs_aux = tileCorrs(
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero fatzero, // final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
...@@ -9290,7 +9290,7 @@ public class ImageDtt { ...@@ -9290,7 +9290,7 @@ public class ImageDtt {
if (Double.isNaN(extra_disparity_aux)) extra_disparity_aux = 0; if (Double.isNaN(extra_disparity_aux)) extra_disparity_aux = 0;
} }
for (int i = 0; i < tile_corrs_main.length; i++) { for (int i = 0; i < tile_corrs_main.length; i++) {// not used in lwir
int dest = SNGL_TO_BI[0][i]; int dest = SNGL_TO_BI[0][i];
if (disparity_bimap[dest] != null) disparity_bimap[dest][nTile] = tile_corrs_main[i]; if (disparity_bimap[dest] != null) disparity_bimap[dest][nTile] = tile_corrs_main[i];
} }
...@@ -9310,7 +9310,7 @@ public class ImageDtt { ...@@ -9310,7 +9310,7 @@ public class ImageDtt {
} }
double [] inter_cam_corr = null; double [] inter_cam_corr = null;
double [] inter_corrs_dxy = null; double [] inter_corrs_dxy = null;
if (calc_both) { if (calc_both) {// not used in lwir
inter_cam_corr = corr2d.correlateInterCamerasFD( inter_cam_corr = corr2d.correlateInterCamerasFD(
clt_data_main, // double [][][][] clt_data_tile_main, clt_data_main, // double [][][][] clt_data_tile_main,
clt_data_aux, // double [][][][] clt_data_tile_aux, clt_data_aux, // double [][][][] clt_data_tile_aux,
...@@ -9354,7 +9354,7 @@ public class ImageDtt { ...@@ -9354,7 +9354,7 @@ public class ImageDtt {
// save data for the main camera // save data for the main camera
for (int nlayer = 0; nlayer < ML_TOP_AUX_INDEX; nlayer++) { for (int nlayer = 0; nlayer < ML_TOP_AUX_INDEX; nlayer++) {
// save main camera data // save main camera data
if (calc_main) { if (calc_main) {// not used in lwir
corr2d.saveMlTile( corr2d.saveMlTile(
tileX, // int tileX, tileX, // int tileX,
tileY, // int tileY, tileY, // int tileY,
...@@ -9365,7 +9365,7 @@ public class ImageDtt { ...@@ -9365,7 +9365,7 @@ public class ImageDtt {
tilesX); // int tilesX); tilesX); // int tilesX);
} }
// save aux_camera data // save aux_camera data
if (calc_aux) { if (calc_aux) {// USED in lwir
corr2d.saveMlTile( corr2d.saveMlTile(
tileX, // int tileX, tileX, // int tileX,
tileY, // int tileY, tileY, // int tileY,
...@@ -9377,7 +9377,7 @@ public class ImageDtt { ...@@ -9377,7 +9377,7 @@ public class ImageDtt {
} }
} }
// save inter-camera correlation // save inter-camera correlation
if (calc_both ) { if (calc_both ) {// not used in lwir
corr2d.saveMlTile( corr2d.saveMlTile(
tileX, // int tileX, tileX, // int tileX,
tileY, // int tileY, tileY, // int tileY,
...@@ -9389,7 +9389,7 @@ public class ImageDtt { ...@@ -9389,7 +9389,7 @@ public class ImageDtt {
} }
// save other data (just 1 value) // save other data (just 1 value)
corr2d.saveMlTilePixel( corr2d.saveMlTilePixel(// USED in lwir
tileX, // int tileX, tileX, // int tileX,
tileY, // int tileY, tileY, // int tileY,
ml_hwidth, // int ml_hwidth, ml_hwidth, // int ml_hwidth,
...@@ -9399,7 +9399,7 @@ public class ImageDtt { ...@@ -9399,7 +9399,7 @@ public class ImageDtt {
disparity_main, // target disparitydouble ml_value, disparity_main, // target disparitydouble ml_value,
tilesX); // int tilesX); tilesX); // int tilesX);
if (calc_both && (ml_data_dbg1 != null)) { if (calc_both && (ml_data_dbg1 != null)) { // not used in lwir
tileInterCamCorrs( tileInterCamCorrs(
false, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide false, // final boolean no_int_x0, // do not offset window to integer - used when averaging low textures to avoid "jumps" for very wide
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
...@@ -9430,12 +9430,12 @@ public class ImageDtt { ...@@ -9430,12 +9430,12 @@ public class ImageDtt {
} // if (disparity_map != null){ // not null - calculate correlations } // if (disparity_map != null){ // not null - calculate correlations
if (tcorr_combo != null) { // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate if (tcorr_combo != null) { // [type][tilesY][tilesX][(2*transform_size-1)*(2*transform_size-1)] // if null - will not calculate
for (int i = 0; i < tcorr_combo.length; i++) { for (int i = 0; i < tcorr_combo.length; i++) {// not used in lwir
clt_corr_combo[i][tileY][tileX] = tcorr_combo[i]; clt_corr_combo[i][tileY][tileX] = tcorr_combo[i];
} }
} }
if (calc_main && (texture_tiles_main !=null)) { if (calc_main && (texture_tiles_main !=null)) {// not used in lwir
generateTextureTiles ( generateTextureTiles (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
extra_disparity_main, // final double extra_disparity, extra_disparity_main, // final double extra_disparity,
...@@ -9454,7 +9454,7 @@ public class ImageDtt { ...@@ -9454,7 +9454,7 @@ public class ImageDtt {
tileY, // final int tileY, tileY, // final int tileY,
tile_lma_debug_level); // final int debugLevel); tile_lma_debug_level); // final int debugLevel);
} }
if (calc_aux && (texture_tiles_aux !=null)) { if (calc_aux && (texture_tiles_aux !=null)) {// not used in lwir
generateTextureTiles ( generateTextureTiles (
clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters, clt_parameters, // final EyesisCorrectionParameters.CLTParameters clt_parameters,
extra_disparity_aux, // final double extra_disparity, extra_disparity_aux, // final double extra_disparity,
...@@ -9474,7 +9474,7 @@ public class ImageDtt { ...@@ -9474,7 +9474,7 @@ public class ImageDtt {
tile_lma_debug_level); // final int debugLevel); tile_lma_debug_level); // final int debugLevel);
} }
// Save channel tiles to result // Save channel tiles to result
if (clt_bidata != null) { if (clt_bidata != null) {// not used in lwir
for (int i = 0; i < quad_main; i++) for (int j = 0; j < numcol; j++){ for (int i = 0; i < quad_main; i++) for (int j = 0; j < numcol; j++){
clt_bidata[0][i][j][tileY][tileX] = clt_data_main[i][j]; clt_bidata[0][i][j][tileY][tileX] = clt_data_main[i][j];
} }
...@@ -9489,7 +9489,7 @@ public class ImageDtt { ...@@ -9489,7 +9489,7 @@ public class ImageDtt {
startAndJoin(threads); startAndJoin(threads);
// If it was low-texture mode, use lt_corr to average bi-quad inter-correlation between neighbor tiles and then calculate disparity/strength // If it was low-texture mode, use lt_corr to average bi-quad inter-correlation between neighbor tiles and then calculate disparity/strength
if (calc_both && (lt_corr != null)) { if (calc_both && (lt_corr != null)) {// not used in lwir
//notch_mode //notch_mode
// prepare weights for neighbors // prepare weights for neighbors
final int lt_rad_x = notch_mode? 0: lt_rad; final int lt_rad_x = notch_mode? 0: lt_rad;
...@@ -9598,7 +9598,7 @@ public class ImageDtt { ...@@ -9598,7 +9598,7 @@ public class ImageDtt {
return clt_bidata; return clt_bidata;
} }
public void clt_bi_macro( // not yet operational public void clt_bi_macro( // not yet operational // not used in lwir
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero final double fatzero, // May use correlation fat zero from 2 different parameters - fat_zero and rig.ml_fatzero
final int macro_scale, final int macro_scale,
......
...@@ -122,32 +122,32 @@ public class QuadCLT { ...@@ -122,32 +122,32 @@ public class QuadCLT {
public double [][] ds_from_main = null; public double [][] ds_from_main = null;
// magic scale should be set before using TileProcessor (calculated disparities depend on it) // magic scale should be set before using TileProcessor (calculated disparities depend on it)
public boolean isMonochrome() {return is_mono;} public boolean isMonochrome() {return is_mono;} // USED in lwir
public boolean isAux() {return is_aux;} public boolean isAux() {return is_aux;} // USED in lwir
public String sAux() {return isAux()?"-AUX":"";} public String sAux() {return isAux()?"-AUX":"";} // USED in lwir
public boolean isLwir() {return !Double.isNaN(lwir_offset);} // clt_kernels public boolean isLwir() {return !Double.isNaN(lwir_offset);} // clt_kernels // USED in lwir
public double getLwirOffset() {return lwir_offset;} public double getLwirOffset() {return lwir_offset;} // USED in lwir
public double [] getColdHot() { public double [] getColdHot() { // USED in lwir
return lwir_cold_hot; return lwir_cold_hot;
} }
public void setColdHot(double [] cold_hot) { public void setColdHot(double [] cold_hot) { // USED in lwir
lwir_cold_hot = cold_hot; lwir_cold_hot = cold_hot;
} }
public void setColdHot(double cold, double hot) { public void setColdHot(double cold, double hot) { // not used in lwir
lwir_cold_hot = new double[2]; lwir_cold_hot = new double[2];
lwir_cold_hot[0] = cold; lwir_cold_hot[0] = cold;
lwir_cold_hot[1] = hot; lwir_cold_hot[1] = hot;
} }
public void resetGroundTruthByRig() { public void resetGroundTruthByRig() { // not used in lwir
tp.rig_disparity_strength = null; tp.rig_disparity_strength = null;
} }
public double [][] getGroundTruthByRig(){ public double [][] getGroundTruthByRig(){ // not used in lwir
if (tp == null) return null; if (tp == null) return null;
return tp.rig_disparity_strength; return tp.rig_disparity_strength;
} }
public void setTiles (ImagePlus imp, // set tp.tilesX, tp.tilesY public void setTiles (ImagePlus imp, // set tp.tilesX, tp.tilesY // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
int threadsMax int threadsMax
){ ){
...@@ -157,7 +157,7 @@ public class QuadCLT { ...@@ -157,7 +157,7 @@ public class QuadCLT {
threadsMax); threadsMax);
} }
public void setTiles ( public void setTiles ( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
int tilesX, int tilesX,
int tilesY, int tilesY,
...@@ -179,7 +179,7 @@ public class QuadCLT { ...@@ -179,7 +179,7 @@ public class QuadCLT {
} }
// used for aux camera // used for aux camera
public boolean setupImageData( public boolean setupImageData( // not used in lwir
String image_name, String image_name,
String [] sourceFiles, String [] sourceFiles,
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -253,7 +253,7 @@ public class QuadCLT { ...@@ -253,7 +253,7 @@ public class QuadCLT {
// public void setProperties(){ // public void setProperties(){
// setProperties(this.properties_prefix); // setProperties(this.properties_prefix);
// } // }
public void setProperties(String prefix, Properties properties){ // save public void setProperties(String prefix, Properties properties){ // save // USED in lwir
if (properties == null) { if (properties == null) {
properties = this.properties; properties = this.properties;
} }
...@@ -268,7 +268,7 @@ public class QuadCLT { ...@@ -268,7 +268,7 @@ public class QuadCLT {
} }
GeometryCorrection gc = geometryCorrection; GeometryCorrection gc = geometryCorrection;
if (gc == null) { // if it was not yet created if (gc == null) { // if it was not yet created
gc = new GeometryCorrection(this.extrinsic_vect); gc = new GeometryCorrection(this.extrinsic_vect); // not used in lwir
} }
for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){ for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){
String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i]; String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i];
...@@ -281,7 +281,7 @@ public class QuadCLT { ...@@ -281,7 +281,7 @@ public class QuadCLT {
} }
public void copyPropertiesFrom(Properties other_properties, String other_prefix, String this_prefix){ // save public void copyPropertiesFrom(Properties other_properties, String other_prefix, String this_prefix){ // save // not used in lwir
// System.out.println("copyPropertiesFrom(other_properties, "+other_prefix+", this_prefix"+")"); // System.out.println("copyPropertiesFrom(other_properties, "+other_prefix+", this_prefix"+")");
for (int n = 0; n < fine_corr.length; n++){ for (int n = 0; n < fine_corr.length; n++){
for (int d = 0; d < fine_corr[n].length; d++){ for (int d = 0; d < fine_corr[n].length; d++){
...@@ -314,13 +314,13 @@ public class QuadCLT { ...@@ -314,13 +314,13 @@ public class QuadCLT {
// System.out.println("Done copyPropertiesFrom"); // System.out.println("Done copyPropertiesFrom");
} }
public GeometryCorrection getGeometryCorrection() { public GeometryCorrection getGeometryCorrection() { // USED in lwir
return geometryCorrection; return geometryCorrection;
} }
public double [][][][][][] getCLTKernels(){ public double [][][][][][] getCLTKernels(){ // USED in lwir
return clt_kernels; return clt_kernels;
} }
public void listGeometryCorrection(boolean full){ public void listGeometryCorrection(boolean full){ // not used in lwir
GeometryCorrection gc = geometryCorrection; GeometryCorrection gc = geometryCorrection;
if (gc == null) { // if it was not yet created if (gc == null) { // if it was not yet created
gc = new GeometryCorrection(this.extrinsic_vect); gc = new GeometryCorrection(this.extrinsic_vect);
...@@ -328,7 +328,7 @@ public class QuadCLT { ...@@ -328,7 +328,7 @@ public class QuadCLT {
gc.listGeometryCorrection(full); gc.listGeometryCorrection(full);
} }
public void getProperties(String prefix){ // restore public void getProperties(String prefix){ // restore // USED in lwir
// System.out.println("getProperties("+prefix+")"); // System.out.println("getProperties("+prefix+")");
for (int n = 0; n < fine_corr.length; n++){ for (int n = 0; n < fine_corr.length; n++){
for (int d = 0; d < fine_corr[n].length; d++){ for (int d = 0; d < fine_corr[n].length; d++){
...@@ -342,14 +342,14 @@ public class QuadCLT { ...@@ -342,14 +342,14 @@ public class QuadCLT {
for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){ for (int i = 0; i < GeometryCorrection.CORR_NAMES.length; i++){
String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i]; String name = prefix+"extrinsic_corr_"+GeometryCorrection.CORR_NAMES[i];
if (properties.getProperty(name)!=null) { if (properties.getProperty(name)!=null) {
if (this.extrinsic_vect == null) { if (this.extrinsic_vect == null) { // not used in lwir
// only create non-null array if there are saved values // only create non-null array if there are saved values
this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length]; this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length];
} }
this.extrinsic_vect[i] = Double.parseDouble(properties.getProperty(name)); this.extrinsic_vect[i] = Double.parseDouble(properties.getProperty(name));
// System.out.println("getProperties():"+i+": getProperty("+name+") -> "+properties.getProperty(name)+""); // System.out.println("getProperties():"+i+": getProperty("+name+") -> "+properties.getProperty(name)+"");
if (geometryCorrection != null){ if (geometryCorrection != null){ // not used in lwir
// if (geometryCorrection.getCorrVector().toArray() == null) { // if (geometryCorrection.getCorrVector().toArray() == null) {
// geometryCorrection.resetCorrVector(); // make it array of zeros // geometryCorrection.resetCorrVector(); // make it array of zeros
// } // }
...@@ -364,7 +364,7 @@ public class QuadCLT { ...@@ -364,7 +364,7 @@ public class QuadCLT {
if (geometryCorrection == null) { if (geometryCorrection == null) {
double [] extrinsic_vect_saved = this.extrinsic_vect.clone(); double [] extrinsic_vect_saved = this.extrinsic_vect.clone();
boolean OK = initGeometryCorrection(0); // int debugLevel); boolean OK = initGeometryCorrection(0); // int debugLevel);
if (!OK) { if (!OK) { // not used in lwir
throw new IllegalArgumentException ("Failed to initialize geometry correction"); throw new IllegalArgumentException ("Failed to initialize geometry correction");
} }
// Substitute vector generated in initGeometryCorrection with the saved from properties one: // Substitute vector generated in initGeometryCorrection with the saved from properties one:
...@@ -379,18 +379,18 @@ public class QuadCLT { ...@@ -379,18 +379,18 @@ public class QuadCLT {
} }
} }
public void setKernelImageFile(ImagePlus img_kernels){ public void setKernelImageFile(ImagePlus img_kernels){ // not used in lwir
eyesisKernelImage = img_kernels; eyesisKernelImage = img_kernels;
} }
public boolean kernelImageSet(){ public boolean kernelImageSet(){ // not used in lwir
return eyesisKernelImage != null; return eyesisKernelImage != null;
} }
public boolean CLTKernelsAvailable(){ public boolean CLTKernelsAvailable(){ // USED in lwir
return clt_kernels != null; return clt_kernels != null;
} }
public boolean geometryCorrectionAvailable(){ public boolean geometryCorrectionAvailable(){ // USED in lwir
return (geometryCorrection != null) && geometryCorrection.isInitialized(); return (geometryCorrection != null) && geometryCorrection.isInitialized();
} }
public void resetGeometryCorrection() { public void resetGeometryCorrection() {
...@@ -398,7 +398,7 @@ public class QuadCLT { ...@@ -398,7 +398,7 @@ public class QuadCLT {
// extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length]; // extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length];
extrinsic_vect = null; extrinsic_vect = null;
} }
public boolean initGeometryCorrection(int debugLevel){ public boolean initGeometryCorrection(int debugLevel){ // USED in lwir
// keep rig offsets if edited // keep rig offsets if edited
if (geometryCorrection == null) { if (geometryCorrection == null) {
geometryCorrection = new GeometryCorrection(extrinsic_vect); geometryCorrection = new GeometryCorrection(extrinsic_vect);
...@@ -425,7 +425,7 @@ public class QuadCLT { ...@@ -425,7 +425,7 @@ public class QuadCLT {
(sensors[0].pixelCorrectionHeight != sensors[i].pixelCorrectionHeight) || (sensors[0].pixelCorrectionHeight != sensors[i].pixelCorrectionHeight) ||
(sensors[0].pixelSize != sensors[i].pixelSize)){ (sensors[0].pixelSize != sensors[i].pixelSize)){
System.out.println("initGeometryCorrection(): All sensors have to have the same distortion model, but channels 0 and "+i+" mismatch"); System.out.println("initGeometryCorrection(): All sensors have to have the same distortion model, but channels 0 and "+i+" mismatch");
return false; return false; // not used in lwir
} }
} }
...@@ -513,7 +513,7 @@ public class QuadCLT { ...@@ -513,7 +513,7 @@ public class QuadCLT {
System.out.println("Adjusted camera to orient X Y along the sides of a square"); System.out.println("Adjusted camera to orient X Y along the sides of a square");
} else { } else {
System.out.println("============= Cannot adustSquare() as it requires exactly 4 sensors, "+numSensors+" provided =========="); System.out.println("============= Cannot adustSquare() as it requires exactly 4 sensors, "+numSensors+" provided ==========");
return false; return false; // not used in lwir
} }
// Print parameters // Print parameters
if (debugLevel > 0){ if (debugLevel > 0){
...@@ -528,7 +528,7 @@ public class QuadCLT { ...@@ -528,7 +528,7 @@ public class QuadCLT {
//GeometryCorrection //GeometryCorrection
public double [][][][][] calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel public double [][][][][] calculateCLTKernel ( // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel // not used in lwir
final PixelMapping.SensorData sensor, // to calculate extra shift final PixelMapping.SensorData sensor, // to calculate extra shift
final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
final int kernelSize, // 64 final int kernelSize, // 64
...@@ -765,7 +765,7 @@ public class QuadCLT { ...@@ -765,7 +765,7 @@ public class QuadCLT {
return clt_kernels; return clt_kernels;
} }
public double [][] flattenCLTKernels ( // per color, save 4 kernelas and displacement as (2*dtt_size+1)*(2*dtt_size) tiles in an image (last row - 4 values shift x,y) public double [][] flattenCLTKernels ( // per color, save 4 kernelas and displacement as (2*dtt_size+1)*(2*dtt_size) tiles in an image (last row - 4 values shift x,y) // not used in lwir
final double [][][][][] kernels, // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel final double [][][][][] kernels, // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -843,7 +843,7 @@ public class QuadCLT { ...@@ -843,7 +843,7 @@ public class QuadCLT {
return clt_flat; return clt_flat;
} }
public void showCLTKernels( public void showCLTKernels( // not used in lwir
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
final int globalDebugLevel) // update status info final int globalDebugLevel) // update status info
...@@ -860,7 +860,7 @@ public class QuadCLT { ...@@ -860,7 +860,7 @@ public class QuadCLT {
} }
} }
public void showCLTKernels( public void showCLTKernels( // not used in lwir
int chn, int chn,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -884,7 +884,7 @@ public class QuadCLT { ...@@ -884,7 +884,7 @@ public class QuadCLT {
titles); titles);
} }
// USED in lwir
public double [][][][][] extractCLTKernels ( // per color, save 4 kernelas and displacement as (2*dtt_size+1)*(2*dtt_size) tiles in an image (last row - shift x,y) public double [][][][][] extractCLTKernels ( // per color, save 4 kernelas and displacement as (2*dtt_size+1)*(2*dtt_size) tiles in an image (last row - shift x,y)
final float [][] flat_kernels, // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel final float [][] flat_kernels, // per color/per tileY/ per tileX/per quadrant (plus offset as 5-th)/per pixel
final int width, final int width,
...@@ -955,7 +955,7 @@ public class QuadCLT { ...@@ -955,7 +955,7 @@ public class QuadCLT {
} }
public boolean createCLTKernels( public boolean createCLTKernels( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
int srcKernelSize, int srcKernelSize,
int threadsMax, // maximal number of threads to launch int threadsMax, // maximal number of threads to launch
...@@ -1048,7 +1048,7 @@ public class QuadCLT { ...@@ -1048,7 +1048,7 @@ public class QuadCLT {
public boolean readCLTKernels( public boolean readCLTKernels( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
int threadsMax, // maximal number of threads to launch int threadsMax, // maximal number of threads to launch
boolean updateStatus, boolean updateStatus,
...@@ -1137,7 +1137,7 @@ public class QuadCLT { ...@@ -1137,7 +1137,7 @@ public class QuadCLT {
// mostly for testing // mostly for testing
//eyesisKernelImage //eyesisKernelImage
public double [] extractOneKernelFromStack( public double [] extractOneKernelFromStack( // not used in lwir
final int kernelSize, // 64 final int kernelSize, // 64
final int chn, final int chn,
final int xTile, // horizontal number of kernel to extract final int xTile, // horizontal number of kernel to extract
...@@ -1153,7 +1153,7 @@ public class QuadCLT { ...@@ -1153,7 +1153,7 @@ public class QuadCLT {
yTile); // vertical number of kernel to extract yTile); // vertical number of kernel to extract
} }
public double [] extractOneKernelFromStack( public double [] extractOneKernelFromStack( // not used in lwir
final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels final ImageStack kernelStack, // first stack with 3 colors/slices convolution kernels
final int kernelSize, // 64 final int kernelSize, // 64
final int chn, final int chn,
...@@ -1172,7 +1172,7 @@ public class QuadCLT { ...@@ -1172,7 +1172,7 @@ public class QuadCLT {
return kernel; return kernel;
} }
// to be used in threaded method // to be used in threaded method
private void extractOneKernel(float [] pixels, // array of combined square kernels, each private void extractOneKernel(float [] pixels, // array of combined square kernels, each // not used in lwir
double [] kernel, // will be filled, should have correct size before call double [] kernel, // will be filled, should have correct size before call
int numHor, // number of kernels in a row int numHor, // number of kernels in a row
int xTile, // horizontal number of kernel to extract int xTile, // horizontal number of kernel to extract
...@@ -1192,7 +1192,7 @@ public class QuadCLT { ...@@ -1192,7 +1192,7 @@ public class QuadCLT {
for (i=0;i<size;i++) for (j=0;j<size;j++) kernel [i*size+j]=pixels[base+i*pixelsWidth+j]; for (i=0;i<size;i++) for (j=0;j<size;j++) kernel [i*size+j]=pixels[base+i*pixelsWidth+j];
} }
public double [] reformatKernel( public double [] reformatKernel( // not used in lwir
double [] src_kernel,// will be blured in-place double [] src_kernel,// will be blured in-place
int src_size, // typical 64 int src_size, // typical 64
int dst_size, // typical 15 // destination size int dst_size, // typical 15 // destination size
...@@ -1214,7 +1214,7 @@ public class QuadCLT { ...@@ -1214,7 +1214,7 @@ public class QuadCLT {
} }
// to be used in threaded method // to be used in threaded method
private void reformatKernel( private void reformatKernel( // not used in lwir
double [] src_kernel, // will be blured in-place double [] src_kernel, // will be blured in-place
double [] dst_kernel, double [] dst_kernel,
int src_size, int src_size,
...@@ -1242,7 +1242,7 @@ public class QuadCLT { ...@@ -1242,7 +1242,7 @@ public class QuadCLT {
} }
} }
} }
public double []reformatKernel2( // averages by exactly 2 (decimate==2) public double []reformatKernel2( // averages by exactly 2 (decimate==2) // not used in lwir
double [] src_kernel, // double [] src_kernel, //
int src_size, int src_size,
int dst_size){ int dst_size){
...@@ -1255,7 +1255,7 @@ public class QuadCLT { ...@@ -1255,7 +1255,7 @@ public class QuadCLT {
return dst_kernel; return dst_kernel;
} }
private void reformatKernel2( // averages by exactly 2 (decimate==2) private void reformatKernel2( // averages by exactly 2 (decimate==2) // not used in lwir
double [] src_kernel, // double [] src_kernel, //
double [] dst_kernel, double [] dst_kernel,
int src_size, int src_size,
...@@ -1290,14 +1290,14 @@ public class QuadCLT { ...@@ -1290,14 +1290,14 @@ public class QuadCLT {
} }
} }
public void resetCLTKernels() // and geometry corection too public void resetCLTKernels() // and geometry correction too // not used in lwir
{ {
clt_kernels = null; clt_kernels = null;
geometryCorrection=null; geometryCorrection=null;
} }
public ImageStack YPrPbToRGB(double [][] yPrPb, public ImageStack YPrPbToRGB(double [][] yPrPb, // USED in lwir
double Kr, // 0.299; double Kr, // 0.299;
double Kb, // 0.114; double Kb, // 0.114;
int width int width
...@@ -1337,7 +1337,7 @@ public class QuadCLT { ...@@ -1337,7 +1337,7 @@ public class QuadCLT {
} }
public double [][] YPrPbToRBG(double [][] yPrPb, public double [][] YPrPbToRBG(double [][] yPrPb, // not used in lwir
double Kr, // 0.299; double Kr, // 0.299;
double Kb, // 0.114; double Kb, // 0.114;
int width int width
...@@ -1370,13 +1370,13 @@ public class QuadCLT { ...@@ -1370,13 +1370,13 @@ public class QuadCLT {
return rbg; return rbg;
} }
public void debayer_rbg( public void debayer_rbg( // not used in lwir
ImageStack stack_rbg){ ImageStack stack_rbg){
debayer_rbg(stack_rbg, 1.0); debayer_rbg(stack_rbg, 1.0);
} }
// Simple in-place debayer by (bi) linear approximation, assumes [0R/00], [00/B0], [G0/0G] slices // Simple in-place debayer by (bi) linear approximation, assumes [0R/00], [00/B0], [G0/0G] slices
public void debayer_rbg( public void debayer_rbg( // not used in lwir
ImageStack stack_rbg, ImageStack stack_rbg,
double scale) double scale)
{ {
...@@ -1462,7 +1462,7 @@ public class QuadCLT { ...@@ -1462,7 +1462,7 @@ public class QuadCLT {
} }
} }
public void processCLTChannelImages( public void processCLTChannelImages( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -1560,7 +1560,7 @@ public class QuadCLT { ...@@ -1560,7 +1560,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public ImagePlus processCLTChannelImage( public ImagePlus processCLTChannelImage( // not used in lwir
ImagePlus imp_src, // should have properties "name"(base for saving results), "channel","path" ImagePlus imp_src, // should have properties "name"(base for saving results), "channel","path"
// EyesisCorrectionParameters.DCTParameters dct_parameters, // EyesisCorrectionParameters.DCTParameters dct_parameters,
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -2005,7 +2005,7 @@ public class QuadCLT { ...@@ -2005,7 +2005,7 @@ public class QuadCLT {
} }
// Processing sets of 4 images together // Processing sets of 4 images together
public void processCLTSets( public void processCLTSets( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
// EyesisCorrectionParameters.NonlinParameters nonlinParameters, // EyesisCorrectionParameters.NonlinParameters nonlinParameters,
...@@ -2246,7 +2246,7 @@ public class QuadCLT { ...@@ -2246,7 +2246,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public ImagePlus processCLTSetImage( public ImagePlus processCLTSetImage( // not used in lwir
ImagePlus imp_src, // should have properties "name"(base for saving results), "channel","path" ImagePlus imp_src, // should have properties "name"(base for saving results), "channel","path"
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
...@@ -2610,7 +2610,7 @@ public class QuadCLT { ...@@ -2610,7 +2610,7 @@ public class QuadCLT {
return result; return result;
} }
public void processCLTQuads( public void processCLTQuads( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -2840,7 +2840,7 @@ public class QuadCLT { ...@@ -2840,7 +2840,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public ImagePlus [] processCLTQuad( public ImagePlus [] processCLTQuad( // not used in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path" ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path"
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
...@@ -3146,34 +3146,34 @@ public class QuadCLT { ...@@ -3146,34 +3146,34 @@ public class QuadCLT {
return results; return results;
} }
class SetChannels{ class SetChannels{ // USED in lwir
String set_name; // set name (timestamp) String set_name; // set name (timestamp)
int [] file_number; // array of file numbers for channels int [] file_number; // array of file numbers for channels
public SetChannels(String name, int[] fn){ public SetChannels(String name, int[] fn){ // USED in lwir
set_name = name; set_name = name;
file_number = fn; file_number = fn;
} }
public String name() { public String name() { // USED in lwir
return set_name; return set_name;
} }
public int [] fileNumber() { public int [] fileNumber() { // USED in lwir
return file_number; return file_number;
} }
public int fileNumber(int i) { public int fileNumber(int i) { // not used in lwir
return file_number[i]; return file_number[i];
} }
} }
SetChannels [] setChannels( SetChannels [] setChannels( // USED in lwir
int debugLevel) { int debugLevel) {
return setChannels(null, debugLevel); return setChannels(null, debugLevel);
} }
public int [] fileChannelToSensorChannels(int file_channel) { public int [] fileChannelToSensorChannels(int file_channel) { // USED in lwir
if (!eyesisCorrections.pixelMapping.subcamerasUsed()) { // not an Eyesis-type system if (!eyesisCorrections.pixelMapping.subcamerasUsed()) { // not an Eyesis-type system
// Here use firstSubCameraConfig - subcamera, corresponding to sensors[0] of this PixelMapping instance (1 for Eyesis, 2 for Rig/LWIR) // Here use firstSubCameraConfig - subcamera, corresponding to sensors[0] of this PixelMapping instance (1 for Eyesis, 2 for Rig/LWIR)
return eyesisCorrections.pixelMapping.channelsForSubCamera(file_channel - correctionsParameters.firstSubCameraConfig); return eyesisCorrections.pixelMapping.channelsForSubCamera(file_channel - correctionsParameters.firstSubCameraConfig);
} else if (correctionsParameters.isJP4()){ } else if (correctionsParameters.isJP4()){ // not used in lwir
// Here use firstSubCamera - first filename index to be processed by this PixelMapping instance (1 for Eyesis, 2 for Rig/LWIR) // Here use firstSubCamera - first filename index to be processed by this PixelMapping instance (1 for Eyesis, 2 for Rig/LWIR)
int subCamera= file_channel- correctionsParameters.firstSubCamera; // to match those in the sensor files int subCamera= file_channel- correctionsParameters.firstSubCamera; // to match those in the sensor files
return eyesisCorrections.pixelMapping.channelsForSubCamera(subCamera); return eyesisCorrections.pixelMapping.channelsForSubCamera(subCamera);
...@@ -3183,7 +3183,7 @@ public class QuadCLT { ...@@ -3183,7 +3183,7 @@ public class QuadCLT {
} }
} }
SetChannels [] setChannels( SetChannels [] setChannels( // USED in lwir
String single_set_name, // process only files that contain specified series (timestamp) in the name String single_set_name, // process only files that contain specified series (timestamp) in the name
int debugLevel) { int debugLevel) {
String [] sourceFiles=correctionsParameters.getSourcePaths(); String [] sourceFiles=correctionsParameters.getSourcePaths();
...@@ -3207,7 +3207,7 @@ public class QuadCLT { ...@@ -3207,7 +3207,7 @@ public class QuadCLT {
} }
if (numFilesToProcess==0){ if (numFilesToProcess==0){
System.out.println("No files to process (of "+sourceFiles.length+")"); System.out.println("No files to process (of "+sourceFiles.length+")");
return null; return null; // not used in lwir
} else { } else {
if (debugLevel>0) System.out.println(numFilesToProcess+ " files to process (of "+sourceFiles.length+"), "+numImagesToProcess+" images to process"); if (debugLevel>0) System.out.println(numFilesToProcess+ " files to process (of "+sourceFiles.length+"), "+numImagesToProcess+" images to process");
} }
...@@ -3216,7 +3216,7 @@ public class QuadCLT { ...@@ -3216,7 +3216,7 @@ public class QuadCLT {
for (int nFile=0;nFile<enabledFiles.length;nFile++){ // enabledFiles not used anymore? for (int nFile=0;nFile<enabledFiles.length;nFile++){ // enabledFiles not used anymore?
if ( (sourceFiles[nFile]!=null) && if ( (sourceFiles[nFile]!=null) &&
(sourceFiles[nFile].length()>1) && (sourceFiles[nFile].length()>1) &&
((single_set_name == null) || (correctionsParameters.getNameFromTiff(sourceFiles[nFile]).contains(single_set_name)))) { ((single_set_name == null) || (correctionsParameters.getNameFromTiff(sourceFiles[nFile]).contains(single_set_name)))) { // not used in lwir
int [] channels= fileChannelToSensorChannels(correctionsParameters.getChannelFromSourceTiff(sourceFiles[nFile])); int [] channels= fileChannelToSensorChannels(correctionsParameters.getChannelFromSourceTiff(sourceFiles[nFile]));
if (channels!=null){ if (channels!=null){
for (int i=0;i<channels.length;i++) if (eyesisCorrections.isChannelEnabled(channels[i])){ for (int i=0;i<channels.length;i++) if (eyesisCorrections.isChannelEnabled(channels[i])){
...@@ -3256,7 +3256,7 @@ public class QuadCLT { ...@@ -3256,7 +3256,7 @@ public class QuadCLT {
} }
int getTotalFiles(SetChannels [] sc) { int getTotalFiles(SetChannels [] sc) { // USED in lwir
int nf = 0; int nf = 0;
for (int i = 0; i < sc.length; i++) nf+=sc[i].fileNumber().length; for (int i = 0; i < sc.length; i++) nf+=sc[i].fileNumber().length;
return nf; return nf;
...@@ -3275,7 +3275,7 @@ public class QuadCLT { ...@@ -3275,7 +3275,7 @@ public class QuadCLT {
* @param debugLevel debug (verbosity) level * @param debugLevel debug (verbosity) level
* @return array of per-channel ImagePlus objects to process (with saturation_imp) * @return array of per-channel ImagePlus objects to process (with saturation_imp)
*/ */
public ImagePlus[] conditionImageSet( public ImagePlus[] conditionImageSet( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, // ColorProcParameters colorProcParameters, //
String [] sourceFiles, String [] sourceFiles,
...@@ -3317,7 +3317,7 @@ public class QuadCLT { ...@@ -3317,7 +3317,7 @@ public class QuadCLT {
if (this.correctionsParameters.pixelDefects && (eyesisCorrections.defectsXY!=null)&& (eyesisCorrections.defectsXY[srcChannel]!=null)){ if (this.correctionsParameters.pixelDefects && (eyesisCorrections.defectsXY!=null)&& (eyesisCorrections.defectsXY[srcChannel]!=null)){
// apply pixel correction // apply pixel correction
int numApplied= eyesisCorrections.correctDefects( int numApplied= eyesisCorrections.correctDefects( // not used in lwir
imp_srcs[srcChannel], imp_srcs[srcChannel],
srcChannel, srcChannel,
debugLevel); debugLevel);
...@@ -3374,14 +3374,14 @@ public class QuadCLT { ...@@ -3374,14 +3374,14 @@ public class QuadCLT {
if (this.correctionsParameters.vignetting && correct_vignetting){ if (this.correctionsParameters.vignetting && correct_vignetting){
if ((eyesisCorrections.channelVignettingCorrection==null) || (srcChannel<0) || (srcChannel>=eyesisCorrections.channelVignettingCorrection.length) || (eyesisCorrections.channelVignettingCorrection[srcChannel]==null)){ if ((eyesisCorrections.channelVignettingCorrection==null) || (srcChannel<0) || (srcChannel>=eyesisCorrections.channelVignettingCorrection.length) || (eyesisCorrections.channelVignettingCorrection[srcChannel]==null)){
System.out.println("No vignetting data for channel "+srcChannel); System.out.println("No vignetting data for channel "+srcChannel);
return null; return null; // not used in lwir
} }
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels(); /// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
if (pixels.length!=eyesisCorrections.channelVignettingCorrection[srcChannel].length){ if (pixels.length!=eyesisCorrections.channelVignettingCorrection[srcChannel].length){
System.out.println("Vignetting data for channel "+srcChannel+" has "+eyesisCorrections.channelVignettingCorrection[srcChannel].length+" pixels, image "+sourceFiles[nFile]+" has "+pixels.length); System.out.println("Vignetting data for channel "+srcChannel+" has "+eyesisCorrections.channelVignettingCorrection[srcChannel].length+" pixels, image "+sourceFiles[nFile]+" has "+pixels.length);
return null; return null; // not used in lwir
} }
// TODO: Move to do it once: // TODO: Move to do it once:
double min_non_zero = 0.0; double min_non_zero = 0.0;
...@@ -3411,7 +3411,7 @@ public class QuadCLT { ...@@ -3411,7 +3411,7 @@ public class QuadCLT {
} }
} }
} else { // assuming GR/BG pattern } else { // assuming GR/BG pattern // not used in lwir
System.out.println("Applying fixed color gain correction parameters: Gr="+ System.out.println("Applying fixed color gain correction parameters: Gr="+
clt_parameters.novignetting_r+", Gg="+clt_parameters.novignetting_g+", Gb="+clt_parameters.novignetting_b); clt_parameters.novignetting_r+", Gg="+clt_parameters.novignetting_g+", Gb="+clt_parameters.novignetting_b);
/// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels(); /// float [] pixels=(float []) imp_srcs[srcChannel].getProcessor().getPixels();
...@@ -3520,7 +3520,7 @@ public class QuadCLT { ...@@ -3520,7 +3520,7 @@ public class QuadCLT {
} }
public void processCLTQuadCorrs( public void processCLTQuadCorrs( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -3600,7 +3600,7 @@ public class QuadCLT { ...@@ -3600,7 +3600,7 @@ public class QuadCLT {
} }
public void channelGainsEqualize( public void channelGainsEqualize( // USED in lwir
boolean gain_equalize, boolean gain_equalize,
boolean colors_equalize, boolean colors_equalize,
boolean nosat_equalize, boolean nosat_equalize,
...@@ -3620,7 +3620,7 @@ public class QuadCLT { ...@@ -3620,7 +3620,7 @@ public class QuadCLT {
saturated, saturated,
setName, // just for debug messages == setNames.get(nSet) setName, // just for debug messages == setNames.get(nSet)
debugLevel); debugLevel);
} else { } else { // not used in lwir
channelGainsEqualize_old( channelGainsEqualize_old(
gain_equalize, gain_equalize,
colors_equalize, colors_equalize,
...@@ -3632,7 +3632,7 @@ public class QuadCLT { ...@@ -3632,7 +3632,7 @@ public class QuadCLT {
debugLevel); debugLevel);
} }
} }
public void channelGainsEqualize_old( public void channelGainsEqualize_old( // not used in lwir
boolean gain_equalize, boolean gain_equalize,
boolean colors_equalize, boolean colors_equalize,
boolean nosat_equalize, boolean nosat_equalize,
...@@ -3706,7 +3706,7 @@ public class QuadCLT { ...@@ -3706,7 +3706,7 @@ public class QuadCLT {
} }
} }
public void channelGainsEqualize_new( public void channelGainsEqualize_new( // USED in lwir
boolean gain_equalize, boolean gain_equalize,
boolean colors_equalize, boolean colors_equalize,
boolean nosat_equalize, boolean nosat_equalize,
...@@ -3777,7 +3777,7 @@ public class QuadCLT { ...@@ -3777,7 +3777,7 @@ public class QuadCLT {
double avr_g = 0.5 * (avr_pix[srcChannel][1] + avr_pix[srcChannel][2]); double avr_g = 0.5 * (avr_pix[srcChannel][1] + avr_pix[srcChannel][2]);
for (int j=0;j < scales.length; j++){ for (int j=0;j < scales.length; j++){
scales[j] = 1.0; scales[j] = 1.0;
if (gain_equalize){ if (gain_equalize){ // not used in lwir
scales[j] *= avr_G/avr_g; scales[j] *= avr_G/avr_g;
} }
if (colors_equalize){ if (colors_equalize){
...@@ -3809,7 +3809,7 @@ public class QuadCLT { ...@@ -3809,7 +3809,7 @@ public class QuadCLT {
} }
} }
} }
public double [] channelLwirEqualize( public double [] channelLwirEqualize( // USED in lwir
int [] channelFiles, int [] channelFiles,
ImagePlus [] imp_srcs, ImagePlus [] imp_srcs,
boolean remove_dc, boolean remove_dc,
...@@ -3854,7 +3854,7 @@ public class QuadCLT { ...@@ -3854,7 +3854,7 @@ public class QuadCLT {
} }
} }
double avg = total_s/total_w; double avg = total_s/total_w;
if (!remove_dc) { if (!remove_dc) { // not used in lwir
for (int srcChannel=0; srcChannel < channelFiles.length; srcChannel++) if (channelFiles[srcChannel] >=0){ for (int srcChannel=0; srcChannel < channelFiles.length; srcChannel++) if (channelFiles[srcChannel] >=0){
avr_pix[srcChannel][0] -= avg; avr_pix[srcChannel][0] -= avg;
} }
...@@ -3877,7 +3877,7 @@ public class QuadCLT { ...@@ -3877,7 +3877,7 @@ public class QuadCLT {
} }
public ImagePlus [] processCLTQuadCorr( public ImagePlus [] processCLTQuadCorr( // USED in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path" 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
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -3971,7 +3971,7 @@ public class QuadCLT { ...@@ -3971,7 +3971,7 @@ public class QuadCLT {
} }
} // clt_parameters.corr_mismatch = false } // clt_parameters.corr_mismatch = false
if (clt_parameters.corr_mismatch || apply_corr || infinity_corr){ // added infinity_corr if (clt_parameters.corr_mismatch || apply_corr || infinity_corr){ // added infinity_corr
clt_mismatch = new double [12][]; // What is 12? clt_mismatch = new double [12][]; // What is 12?// not used in lwir
} }
} }
// Includes all 3 colors - will have zeros in unused // Includes all 3 colors - will have zeros in unused
...@@ -3990,7 +3990,7 @@ public class QuadCLT { ...@@ -3990,7 +3990,7 @@ public class QuadCLT {
double z_correction = clt_parameters.z_correction; double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(name)){ if (clt_parameters.z_corr_map.containsKey(name)){
z_correction +=clt_parameters.z_corr_map.get(name); z_correction +=clt_parameters.z_corr_map.get(name);// not used in lwir
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr( double [][][][][][] clt_data = image_dtt.clt_aberrations_quad_corr(
...@@ -4064,7 +4064,7 @@ public class QuadCLT { ...@@ -4064,7 +4064,7 @@ public class QuadCLT {
String [] rbga_weights_titles = {"red","blue","green","alpha","port0","port1","port2","port3","r-rms","b-rms","g-rms","w-rms"}; 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 // In monochrome mode only G is used ImageDtt.MONO_CHN(==2), others are null
if (texture_tiles != null){ if (texture_tiles != null){
if (clt_parameters.show_nonoverlap){ if (clt_parameters.show_nonoverlap){// not used in lwir
texture_nonoverlap = image_dtt.combineRBGATiles( texture_nonoverlap = image_dtt.combineRBGATiles(
texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null} texture_tiles, // array [tp.tilesY][tp.tilesX][4][4*transform_size] or [tp.tilesY][tp.tilesX]{null}
clt_parameters.transform_size, clt_parameters.transform_size,
...@@ -4101,7 +4101,7 @@ public class QuadCLT { ...@@ -4101,7 +4101,7 @@ public class QuadCLT {
} }
} }
if (!batch_mode && clt_parameters.show_overlap) { if (!batch_mode && clt_parameters.show_overlap) {// not used in lwir
sdfa_instance.showArrays( // all but r-rms, b-rms sdfa_instance.showArrays( // all but r-rms, b-rms
texture_overlap, texture_overlap,
tilesX * clt_parameters.transform_size, tilesX * clt_parameters.transform_size,
...@@ -4110,7 +4110,7 @@ public class QuadCLT { ...@@ -4110,7 +4110,7 @@ public class QuadCLT {
name+sAux() + "-TXTOL-D"+clt_parameters.disparity, name+sAux() + "-TXTOL-D"+clt_parameters.disparity,
(clt_parameters.keep_weights?rbga_weights_titles:rbga_titles)); (clt_parameters.keep_weights?rbga_weights_titles:rbga_titles));
} }
if (!batch_mode && clt_parameters.show_rgba_color) { if (!batch_mode && clt_parameters.show_rgba_color) {// not used in lwir
// for now - use just RGB. Later add option for RGBA // for now - use just RGB. Later add option for RGBA
double [][] texture_rgb = {texture_overlap[0],texture_overlap[1],texture_overlap[2]}; 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]}; double [][] texture_rgba = {texture_overlap[0],texture_overlap[1],texture_overlap[2],texture_overlap[3]};
...@@ -4148,7 +4148,7 @@ public class QuadCLT { ...@@ -4148,7 +4148,7 @@ public class QuadCLT {
} }
} }
if (infinity_corr && (disparity_map != null)){ 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("=== 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 ==="); 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(); double [] mismatch_strength = disparity_map[ImageDtt.DISPARITY_STRENGTH_INDEX].clone();
...@@ -4277,7 +4277,7 @@ public class QuadCLT { ...@@ -4277,7 +4277,7 @@ public class QuadCLT {
} }
if (!batch_mode && !infinity_corr && clt_parameters.corr_show && (debugLevel > -1)){ if (!batch_mode && !infinity_corr && clt_parameters.corr_show && (debugLevel > -1)){ // not used in lwir
double [][] corr_rslt = new double [clt_corr_combo.length][]; double [][] corr_rslt = new double [clt_corr_combo.length][];
String [] titles = new String[clt_corr_combo.length]; // {"combo","sum"}; 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< titles.length; i++) titles[i] = ImageDtt.TCORR_TITLES[i];
...@@ -4299,7 +4299,7 @@ public class QuadCLT { ...@@ -4299,7 +4299,7 @@ public class QuadCLT {
titles ); titles );
} }
if (!batch_mode && !infinity_corr && (clt_corr_partial!=null)){ if (!batch_mode && !infinity_corr && (clt_corr_partial!=null)){ // not used in lwir
if (debugLevel > -1){ // -1 if (debugLevel > -1){ // -1
String [] allColorNames = {"red","blue","green","combo"}; String [] allColorNames = {"red","blue","green","combo"};
String [] titles = new String[clt_corr_partial.length]; String [] titles = new String[clt_corr_partial.length];
...@@ -4444,14 +4444,14 @@ public class QuadCLT { ...@@ -4444,14 +4444,14 @@ public class QuadCLT {
for (int i = 0; i<slice_seq.length; i++){ for (int i = 0; i<slice_seq.length; i++){
if (imps_RGB[slice_seq[i]] != null) { if (imps_RGB[slice_seq[i]] != null) {
array_stack.addSlice("port_"+slice_seq[i], imps_RGB[slice_seq[i]].getProcessor().getPixels()); array_stack.addSlice("port_"+slice_seq[i], imps_RGB[slice_seq[i]].getProcessor().getPixels());
} else { } else { // not used in lwir
array_stack.addSlice("port_"+slice_seq[i], results[slice_seq[i]].getProcessor().getPixels()); array_stack.addSlice("port_"+slice_seq[i], results[slice_seq[i]].getProcessor().getPixels());
} }
} }
ImagePlus imp_stack = new ImagePlus(name+sAux()+"-SHIFTED-D"+clt_parameters.disparity, array_stack); ImagePlus imp_stack = new ImagePlus(name+sAux()+"-SHIFTED-D"+clt_parameters.disparity, array_stack);
imp_stack.getProcessor().resetMinAndMax(); imp_stack.getProcessor().resetMinAndMax();
if (!batch_mode) { if (!batch_mode) {
imp_stack.updateAndDraw(); imp_stack.updateAndDraw(); // not used in lwir
} }
//imp_stack.getProcessor().resetMinAndMax(); //imp_stack.getProcessor().resetMinAndMax();
//imp_stack.show(); //imp_stack.show();
...@@ -4497,7 +4497,7 @@ public class QuadCLT { ...@@ -4497,7 +4497,7 @@ public class QuadCLT {
return results; return results;
} }
double [][] resizeGridTexture( double [][] resizeGridTexture( // USED in lwir
double [][] imgData, double [][] imgData,
int tileSize, int tileSize,
int tilesX, int tilesX,
...@@ -4522,7 +4522,7 @@ public class QuadCLT { ...@@ -4522,7 +4522,7 @@ public class QuadCLT {
} }
return rslt; return rslt;
} }
public int [] getLwirHistogram( public int [] getLwirHistogram( // USED in lwir
double [] data, double [] data,
double hard_cold, double hard_cold,
double hard_hot, double hard_hot,
...@@ -4537,7 +4537,7 @@ public class QuadCLT { ...@@ -4537,7 +4537,7 @@ public class QuadCLT {
} }
return hist; return hist;
} }
public int [] addHist( public int [] addHist( // USED in lwir
int [] this_hist, int [] this_hist,
int [] other_hist) { int [] other_hist) {
for (int i = 0; i < this_hist.length; i++) { for (int i = 0; i < this_hist.length; i++) {
...@@ -4547,7 +4547,7 @@ public class QuadCLT { ...@@ -4547,7 +4547,7 @@ public class QuadCLT {
} }
// get low/high (soft min/max) from the histogram // get low/high (soft min/max) from the histogram
// returns value between 0.0 (low histogram limit and 1.0 - high histgram limit // returns value between 0.0 (low histogram limit and 1.0 - high histgram limit
public double getMarginFromHist( public double getMarginFromHist( // USED in lwir
int [] hist, // histogram int [] hist, // histogram
double cumul_val, // cummulative number of items to be ignored double cumul_val, // cummulative number of items to be ignored
boolean high_marg) { // false - find low margin(output ~0.0) , true - find high margin (output ~1.0) boolean high_marg) { // false - find low margin(output ~0.0) , true - find high margin (output ~1.0)
...@@ -4562,7 +4562,7 @@ public class QuadCLT { ...@@ -4562,7 +4562,7 @@ public class QuadCLT {
n+= hist[bin]; n+= hist[bin];
if (n > cumul_val) break; if (n > cumul_val) break;
} }
if (n <= cumul_val) { if (n <= cumul_val) { // not used in lwir
v = 0.0; // cumul_val > total number of samples v = 0.0; // cumul_val > total number of samples
} else { } else {
v = s* (bin + 1 - (cumul_val - n_prev)/(n - n_prev)); v = s* (bin + 1 - (cumul_val - n_prev)/(n - n_prev));
...@@ -4574,7 +4574,7 @@ public class QuadCLT { ...@@ -4574,7 +4574,7 @@ public class QuadCLT {
n+= hist[bin]; n+= hist[bin];
if (n > cumul_val) break; if (n > cumul_val) break;
} }
if (n <= cumul_val) { if (n <= cumul_val) { // not used in lwir
v = 1.0; // cumul_val > total number of samples v = 1.0; // cumul_val > total number of samples
} else { } else {
v = s * (bin + (cumul_val - n_prev)/(n - n_prev)); v = s * (bin + (cumul_val - n_prev)/(n - n_prev));
...@@ -4583,7 +4583,7 @@ public class QuadCLT { ...@@ -4583,7 +4583,7 @@ public class QuadCLT {
return v; return v;
} }
public double [] autorange( public double [] autorange( // USED in lwir
double [][][] iclt_data, // [iQuad][ncol][i] - normally only [][2][] is non-null double [][][] iclt_data, // [iQuad][ncol][i] - normally only [][2][] is non-null
double hard_cold,// matches data, DC (this.lwir_offset) subtracted double hard_cold,// matches data, DC (this.lwir_offset) subtracted
double hard_hot, // matches data, DC (this.lwir_offset) subtracted double hard_hot, // matches data, DC (this.lwir_offset) subtracted
...@@ -4630,7 +4630,7 @@ public class QuadCLT { ...@@ -4630,7 +4630,7 @@ public class QuadCLT {
// float // float
public ImagePlus linearStackToColor( public ImagePlus linearStackToColor( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -4681,7 +4681,7 @@ public class QuadCLT { ...@@ -4681,7 +4681,7 @@ public class QuadCLT {
// double data // double data
public ImagePlus linearStackToColor( public ImagePlus linearStackToColor( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -4802,7 +4802,7 @@ public class QuadCLT { ...@@ -4802,7 +4802,7 @@ public class QuadCLT {
// Convert a single value pixels to color (r,b,g) values to be processed instead of the normal colors // Convert a single value pixels to color (r,b,g) values to be processed instead of the normal colors
public ImagePlus linearStackToColor( public ImagePlus linearStackToColor( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -4843,7 +4843,7 @@ public class QuadCLT { ...@@ -4843,7 +4843,7 @@ public class QuadCLT {
stack, stack,
debugLevel)){ debugLevel)){
if (debugLevel > -1) System.out.println("fixSliceSequence() returned false"); if (debugLevel > -1) System.out.println("fixSliceSequence() returned false");
return null; return null;// not used in lwir
} }
if (debugLevel > 1) System.out.println("before colors.2"); if (debugLevel > 1) System.out.println("before colors.2");
// if (debugLevel > -1) System.out.println("before colors.2"); // if (debugLevel > -1) System.out.println("before colors.2");
...@@ -4906,7 +4906,7 @@ public class QuadCLT { ...@@ -4906,7 +4906,7 @@ public class QuadCLT {
} }
while (stack.getSize() > 3) stack.deleteLastSlice(); while (stack.getSize() > 3) stack.deleteLastSlice();
if (debugLevel > 1) System.out.println("Trimming color stack"); if (debugLevel > 1) System.out.println("Trimming color stack");
} else { } else {// not used in lwir
titleFull=name+sAux()+"-YPrPb"+suffix; titleFull=name+sAux()+"-YPrPb"+suffix;
if (debugLevel > 1) System.out.println("Using full stack, including YPbPr"); if (debugLevel > 1) System.out.println("Using full stack, including YPbPr");
} }
...@@ -4920,7 +4920,7 @@ public class QuadCLT { ...@@ -4920,7 +4920,7 @@ public class QuadCLT {
result.show(); result.show();
} }
if (!toRGB && !this.correctionsParameters.jpeg){ // toRGB set for equirectangular if (!toRGB && !this.correctionsParameters.jpeg){ // toRGB set for equirectangular// not used in lwir
if (debugLevel > 1) System.out.println("!toRGB && !this.correctionsParameters.jpeg"); if (debugLevel > 1) System.out.println("!toRGB && !this.correctionsParameters.jpeg");
if (saveShowIntermediate) eyesisCorrections.saveAndShow(result, this.correctionsParameters); if (saveShowIntermediate) eyesisCorrections.saveAndShow(result, this.correctionsParameters);
return result; return result;
...@@ -4949,7 +4949,7 @@ public class QuadCLT { ...@@ -4949,7 +4949,7 @@ public class QuadCLT {
CompositeImage compositeImage=eyesisCorrections.convertToComposite(result); CompositeImage compositeImage=eyesisCorrections.convertToComposite(result);
if (!this.correctionsParameters.jpeg && bpp16){ // RGB48 was the end result if (!this.correctionsParameters.jpeg && bpp16){ // RGB48 was the end result // not used in lwir
if (debugLevel > 1) System.out.println("if (!this.correctionsParameters.jpeg && !advanced)"); if (debugLevel > 1) System.out.println("if (!this.correctionsParameters.jpeg && !advanced)");
if (saveShowIntermediate) eyesisCorrections.saveAndShow(compositeImage, this.correctionsParameters); if (saveShowIntermediate) eyesisCorrections.saveAndShow(compositeImage, this.correctionsParameters);
return compositeImage; // return result; return compositeImage; // return result;
...@@ -4973,7 +4973,7 @@ public class QuadCLT { ...@@ -4973,7 +4973,7 @@ public class QuadCLT {
public void apply_fine_corr( public void apply_fine_corr( // not used in lwir
double [][][] corr, double [][][] corr,
int debugLevel) int debugLevel)
{ {
...@@ -5001,16 +5001,16 @@ public class QuadCLT { ...@@ -5001,16 +5001,16 @@ public class QuadCLT {
} }
} }
} }
public void show_fine_corr() public void show_fine_corr() // not used in lwir
{ {
show_fine_corr(""); show_fine_corr("");
} }
public void show_fine_corr(String prefix) public void show_fine_corr(String prefix) // not used in lwir
{ {
show_fine_corr( this.fine_corr, prefix); show_fine_corr( this.fine_corr, prefix);
} }
public void show_fine_corr( public void show_fine_corr( // not used in lwir
double [][][] corr, double [][][] corr,
String prefix) String prefix)
{ {
...@@ -5031,12 +5031,12 @@ public class QuadCLT { ...@@ -5031,12 +5031,12 @@ public class QuadCLT {
} }
public void reset_fine_corr() public void reset_fine_corr() // not used in lwir
{ {
this.fine_corr = new double [4][2][6]; // reset all coefficients to 0 this.fine_corr = new double [4][2][6]; // reset all coefficients to 0
} }
public void showExtrinsicCorr(String name) public void showExtrinsicCorr(String name) // not used in lwir
{ {
System.out.println("Extrinsic corrections "+name); System.out.println("Extrinsic corrections "+name);
if (geometryCorrection == null){ if (geometryCorrection == null){
...@@ -5047,7 +5047,7 @@ public class QuadCLT { ...@@ -5047,7 +5047,7 @@ public class QuadCLT {
} }
} }
public boolean editRig() public boolean editRig() // not used in lwir
{ {
if (!is_aux) { if (!is_aux) {
System.out.println("Rig offsets can only be edited for the auxiliary camera, not for the main one"); System.out.println("Rig offsets can only be edited for the auxiliary camera, not for the main one");
...@@ -5072,7 +5072,7 @@ public class QuadCLT { ...@@ -5072,7 +5072,7 @@ public class QuadCLT {
*/ */
public void resetExtrinsicCorr( public void resetExtrinsicCorr( // not used in lwir
CLTParameters clt_parameters) CLTParameters clt_parameters)
{ {
// this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length]; // this.extrinsic_vect = new double [GeometryCorrection.CORR_NAMES.length];
...@@ -5085,7 +5085,7 @@ public class QuadCLT { ...@@ -5085,7 +5085,7 @@ public class QuadCLT {
} }
} }
public void cltDisparityScans( public void cltDisparityScans( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -5323,7 +5323,7 @@ public class QuadCLT { ...@@ -5323,7 +5323,7 @@ public class QuadCLT {
} }
public ImagePlus [] cltDisparityScan( public ImagePlus [] cltDisparityScan( // not used in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path" 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
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -5630,7 +5630,7 @@ public class QuadCLT { ...@@ -5630,7 +5630,7 @@ public class QuadCLT {
return results; return results;
} }
public void process_infinity_corr( //from existing image public void process_infinity_corr( //from existing image // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
int debugLevel int debugLevel
) { ) {
...@@ -5705,7 +5705,7 @@ public class QuadCLT { ...@@ -5705,7 +5705,7 @@ public class QuadCLT {
} }
public void processLazyEye( public void processLazyEye( // not used in lwir
boolean dry_run, boolean dry_run,
CLTParameters clt_parameters, CLTParameters clt_parameters,
int debugLevel int debugLevel
...@@ -5782,7 +5782,7 @@ public class QuadCLT { ...@@ -5782,7 +5782,7 @@ public class QuadCLT {
} }
public double [][] process_disparity_scan( public double [][] process_disparity_scan( // not used in lwir
double [][] disparities_maps, double [][] disparities_maps,
double disp_step, double disp_step,
double disp_start, double disp_start,
...@@ -5863,7 +5863,7 @@ public class QuadCLT { ...@@ -5863,7 +5863,7 @@ public class QuadCLT {
return rslt; return rslt;
} }
public void showCLTPlanes( public void showCLTPlanes( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -5891,7 +5891,7 @@ public class QuadCLT { ...@@ -5891,7 +5891,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startStepTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public double [][] assignCLTPlanes( public double [][] assignCLTPlanes( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -5921,7 +5921,7 @@ public class QuadCLT { ...@@ -5921,7 +5921,7 @@ public class QuadCLT {
} }
public void out3d_old( public void out3d_old( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -5948,7 +5948,7 @@ public class QuadCLT { ...@@ -5948,7 +5948,7 @@ public class QuadCLT {
public void processCLTQuads3d( public void processCLTQuads3d( // not used in lwir
boolean adjust_extrinsics, boolean adjust_extrinsics,
boolean adjust_poly, boolean adjust_poly,
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
...@@ -6129,7 +6129,7 @@ public class QuadCLT { ...@@ -6129,7 +6129,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public double [][] depthMapMainToAux( public double [][] depthMapMainToAux(// USED in lwir
double [][] ds, double [][] ds,
GeometryCorrection geometryCorrection_main, GeometryCorrection geometryCorrection_main,
GeometryCorrection geometryCorrection_aux, GeometryCorrection geometryCorrection_aux,
...@@ -6141,7 +6141,7 @@ public class QuadCLT { ...@@ -6141,7 +6141,7 @@ public class QuadCLT {
boolean for_adjust, // for LY adjustment: only keep d,s and remove samples with high variations boolean for_adjust, // for LY adjustment: only keep d,s and remove samples with high variations
int debug_level int debug_level
){ ){
class DS{ class DS{// USED in lwir
double disparity; // gt disparity double disparity; // gt disparity
double strength; // gt strength double strength; // gt strength
int tx; // gt tile x int tx; // gt tile x
...@@ -6158,7 +6158,7 @@ public class QuadCLT { ...@@ -6158,7 +6158,7 @@ public class QuadCLT {
} }
@Override @Override
public String toString() { public String toString() { // not used in lwir
return String.format("Disparity (str) = % 6f (%5f), tx=%d ty=%d fx=%5f fy=%5f\n", disparity, strength,tx,ty,fx,fy); return String.format("Disparity (str) = % 6f (%5f), tx=%d ty=%d fx=%5f fy=%5f\n", disparity, strength,tx,ty,fx,fy);
} }
} }
...@@ -6290,7 +6290,7 @@ public class QuadCLT { ...@@ -6290,7 +6290,7 @@ public class QuadCLT {
} }
public boolean preExpandCLTQuad3d( public boolean preExpandCLTQuad3d( // USED in lwir
ImagePlus [] imp_quad, // should have properties "name"(base for saving results), "channel","path" 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
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -6753,7 +6753,7 @@ public class QuadCLT { ...@@ -6753,7 +6753,7 @@ public class QuadCLT {
return true; return true;
} }
ArrayList <CLTPass3d> prepareDisparityScan( ArrayList <CLTPass3d> prepareDisparityScan( // USED in lwir
double scan_start, double scan_start,
double scan_step, double scan_step,
int scan_count){ int scan_count){
...@@ -6779,7 +6779,7 @@ public class QuadCLT { ...@@ -6779,7 +6779,7 @@ public class QuadCLT {
* @param debugLevel * @param debugLevel
* @return true on success, false - on failure * @return true on success, false - on failure
*/ */
public boolean extrinsicsCLT( public boolean extrinsicsCLT( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
boolean adjust_poly, boolean adjust_poly,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
...@@ -7124,7 +7124,7 @@ public class QuadCLT { ...@@ -7124,7 +7124,7 @@ public class QuadCLT {
} }
public double [][] getRigDSFromTwoQuadCL( public double [][] getRigDSFromTwoQuadCL( // not used in lwir
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int debugLevel) { final int debugLevel) {
...@@ -7165,7 +7165,7 @@ public class QuadCLT { ...@@ -7165,7 +7165,7 @@ public class QuadCLT {
* @param debugLevel * @param debugLevel
* @return true on success, false on failure * @return true on success, false on failure
*/ */
public boolean extrinsicsCLTfromGT( public boolean extrinsicsCLTfromGT( // USED in lwir
// TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth // TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
GeometryCorrection geometryCorrection_main, // only used for aux camera if coordinates are for main (null for LWIR) GeometryCorrection geometryCorrection_main, // only used for aux camera if coordinates are for main (null for LWIR)
double [][] rig_disp_strength, double [][] rig_disp_strength,
...@@ -7316,11 +7316,11 @@ public class QuadCLT { ...@@ -7316,11 +7316,11 @@ public class QuadCLT {
clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5 clt_parameters.corr_magic_scale, // double magic_coeff, // still not understood coefficent that reduces reported disparity value. Seems to be around 8.5
debugLevelInner - 1); // + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel) debugLevelInner - 1); // + (clt_parameters.fine_dbg ? 1:0)); // int debugLevel)
if (new_corr == null) { if (new_corr == null) {
return false; return false; // not used in lwir
} }
comp_diff = 0.0; comp_diff = 0.0;
int num_pars = 0; int num_pars = 0;
if (adjust_poly) { if (adjust_poly) { // not used in lwir
apply_fine_corr( apply_fine_corr(
new_corr, new_corr,
debugLevelInner + 2); debugLevelInner + 2);
...@@ -7343,7 +7343,7 @@ public class QuadCLT { ...@@ -7343,7 +7343,7 @@ public class QuadCLT {
if (comp_diff < min_poly_update) { // add other parameter to exit from poly if (comp_diff < min_poly_update) { // add other parameter to exit from poly
break; break;
} }
} else { } else { // USED in lwir
for (int i = 0; i < new_corr[0][0].length; i++){ for (int i = 0; i < new_corr[0][0].length; i++){
comp_diff += new_corr[0][0][i] * new_corr[0][0][i]; comp_diff += new_corr[0][0][i] * new_corr[0][0][i];
} }
...@@ -7374,7 +7374,7 @@ public class QuadCLT { ...@@ -7374,7 +7374,7 @@ public class QuadCLT {
public boolean expandCLTQuad3d( public boolean expandCLTQuad3d( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -7558,7 +7558,7 @@ public class QuadCLT { ...@@ -7558,7 +7558,7 @@ public class QuadCLT {
System.out.println("**** processCLTQuad3d(): nothing to expand ***"); System.out.println("**** processCLTQuad3d(): nothing to expand ***");
System.out.println("!clt_parameters.ex_over_bgnd="+clt_parameters.ex_over_bgnd+" over_infinity="+over_infinity); System.out.println("!clt_parameters.ex_over_bgnd="+clt_parameters.ex_over_bgnd+" over_infinity="+over_infinity);
if (!clt_parameters.ex_over_bgnd || over_infinity) last_pass = true; if (!clt_parameters.ex_over_bgnd || over_infinity) last_pass = true;
else { else { // not used in lwir
over_infinity = true; over_infinity = true;
if (debugLevel > -1){ if (debugLevel > -1){
System.out.println("===== processCLTQuad3d(): trying to expand over previously identified background (may be by error)===="); System.out.println("===== processCLTQuad3d(): trying to expand over previously identified background (may be by error)====");
...@@ -7618,7 +7618,7 @@ public class QuadCLT { ...@@ -7618,7 +7618,7 @@ public class QuadCLT {
// called after composite scan is added to the list? composite scan is inside // called after composite scan is added to the list? composite scan is inside
public int zMapExpansionStep( public int zMapExpansionStep( // USED in lwir
final ArrayList <CLTPass3d> passes,// List, first, last - to search for the already tried disparity final ArrayList <CLTPass3d> passes,// List, first, last - to search for the already tried disparity
final CLTParameters clt_parameters, // for refinePassSetup() final CLTParameters clt_parameters, // for refinePassSetup()
final int firstPass, final int firstPass,
...@@ -7923,11 +7923,11 @@ public class QuadCLT { ...@@ -7923,11 +7923,11 @@ public class QuadCLT {
dbg_y, dbg_y,
debugLevel); debugLevel);
num_extended = numLeftRemoved[0]; //0,0 num_extended = numLeftRemoved[0]; //0,0
if (clt_parameters.show_expand || (clt_parameters.show_variant && (numLeftRemoved[1] > 1 ))) tp.showScan( if (clt_parameters.show_expand || (clt_parameters.show_variant && (numLeftRemoved[1] > 1 ))) tp.showScan( // not used in lwir
tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan, tp.clt_3d_passes.get(refine_pass), // CLTPass3d scan,
"prepareExpandVariant-"+numLeftRemoved[1]+"-"+refine_pass); //String title) "prepareExpandVariant-"+numLeftRemoved[1]+"-"+refine_pass); //String title)
} }
if ((num_extended == 0) && expand_legacy) { // if both are on, will use legacy if neighbors failed if ((num_extended == 0) && expand_legacy) { // if both are on, will use legacy if neighbors failed // not used in lwir
boolean show_ex_debug = show_retry_far || (clt_parameters.show_retry_far && last_pass) || dbg_pass; boolean show_ex_debug = show_retry_far || (clt_parameters.show_retry_far && last_pass) || dbg_pass;
num_extended = tp.setupExtendDisparity( num_extended = tp.setupExtendDisparity(
...@@ -8046,7 +8046,7 @@ public class QuadCLT { ...@@ -8046,7 +8046,7 @@ public class QuadCLT {
} }
// Separate method to detect and remove periodic structures // Separate method to detect and remove periodic structures
public boolean showPeriodic( public boolean showPeriodic( // not used in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int threadsMax, // maximal number of threads to launch final int threadsMax, // maximal number of threads to launch
final boolean updateStatus, final boolean updateStatus,
...@@ -8104,7 +8104,7 @@ public class QuadCLT { ...@@ -8104,7 +8104,7 @@ public class QuadCLT {
//***************************************************************** //*****************************************************************
// public ImagePlus output3d( // public ImagePlus output3d(
public boolean output3d( public boolean output3d( // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -8117,7 +8117,7 @@ public class QuadCLT { ...@@ -8117,7 +8117,7 @@ public class QuadCLT {
final int tilesX = tp.getTilesX(); final int tilesX = tp.getTilesX();
final int tilesY = tp.getTilesY(); final int tilesY = tp.getTilesY();
if (this.image_data == null){ if (this.image_data == null){
return false; return false; // not used in lwir
} }
double infinity_disparity = geometryCorrection.getDisparityFromZ(clt_parameters.infinityDistance); double infinity_disparity = geometryCorrection.getDisparityFromZ(clt_parameters.infinityDistance);
X3dOutput x3dOutput = null; X3dOutput x3dOutput = null;
...@@ -8302,7 +8302,7 @@ public class QuadCLT { ...@@ -8302,7 +8302,7 @@ public class QuadCLT {
threadsMax, // maximal number of threads to launch threadsMax, // maximal number of threads to launch
updateStatus, updateStatus,
batch_mode ? -5: debugLevel); batch_mode ? -5: debugLevel);
if (texturePath == null) { if (texturePath == null) { // not used in lwir
continue; // empty image continue; // empty image
} }
CLTPass3d scan = tp.clt_3d_passes.get(scanIndex); CLTPass3d scan = tp.clt_3d_passes.get(scanIndex);
...@@ -8375,7 +8375,7 @@ public class QuadCLT { ...@@ -8375,7 +8375,7 @@ public class QuadCLT {
public void generateClusterX3d( public void generateClusterX3d( // USED in lwir
X3dOutput x3dOutput, // output x3d if not null X3dOutput x3dOutput, // output x3d if not null
WavefrontExport wfOutput, // output WSavefront if not null WavefrontExport wfOutput, // output WSavefront if not null
String texturePath, String texturePath,
...@@ -8393,7 +8393,7 @@ public class QuadCLT { ...@@ -8393,7 +8393,7 @@ public class QuadCLT {
) throws IOException ) throws IOException
{ {
if (bounds == null) { if (bounds == null) {
return; return; // not used in lwir
} }
int [][] indices = tp.getCoordIndices( // starting with 0, -1 - not selected int [][] indices = tp.getCoordIndices( // starting with 0, -1 - not selected
bounds, bounds,
...@@ -8463,7 +8463,7 @@ public class QuadCLT { ...@@ -8463,7 +8463,7 @@ public class QuadCLT {
} }
public ImagePlus getBackgroundImage( public ImagePlus getBackgroundImage( // USED in lwir
boolean no_image_save, boolean no_image_save,
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
...@@ -8584,7 +8584,7 @@ public class QuadCLT { ...@@ -8584,7 +8584,7 @@ public class QuadCLT {
if (bgnd_tiles_grown2[tileY * tilesX + tileX]) { if (bgnd_tiles_grown2[tileY * tilesX + tileX]) {
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX]; texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX];
num_bgnd++; num_bgnd++;
}else{ }else{ // not used in lwir
texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_bgnd[tileY][tileX]= texture_tiles[tileY][tileX].clone();
texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero; texture_tiles_bgnd[tileY][tileX][alpha_index] = alpha_zero;
} }
...@@ -8594,7 +8594,7 @@ public class QuadCLT { ...@@ -8594,7 +8594,7 @@ public class QuadCLT {
} }
if (num_bgnd < clt_parameters.min_bgnd_tiles){ if (num_bgnd < clt_parameters.min_bgnd_tiles){
return null; // no background to generate return null; // no background to generate // not used in lwir
} }
ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux())); ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux()));
double [][] texture_overlap = image_dtt.combineRBGATiles( double [][] texture_overlap = image_dtt.combineRBGATiles(
...@@ -8671,7 +8671,7 @@ public class QuadCLT { ...@@ -8671,7 +8671,7 @@ public class QuadCLT {
public String getPassImage( // get image form a single pass, return relative path for x3d public String getPassImage( // get image form a single pass, return relative path for x3d // USED in lwir
CLTParameters clt_parameters, CLTParameters clt_parameters,
ColorProcParameters colorProcParameters, ColorProcParameters colorProcParameters,
EyesisCorrectionParameters.RGBParameters rgbParameters, EyesisCorrectionParameters.RGBParameters rgbParameters,
...@@ -8690,12 +8690,12 @@ public class QuadCLT { ...@@ -8690,12 +8690,12 @@ public class QuadCLT {
boolean [] borderTiles = scan.border_tiles; boolean [] borderTiles = scan.border_tiles;
double [][][][] texture_tiles = scan.texture_tiles; double [][][][] texture_tiles = scan.texture_tiles;
scan.updateSelection(); // update .selected field (all selected, including border) and Rectangle bounds scan.updateSelection(); // update .selected field (all selected, including border) and Rectangle bounds
if (scan.getTextureBounds() == null) { if (scan.getTextureBounds() == null) { // not used in lwir
System.out.println("getPassImage(): Empty image!"); System.out.println("getPassImage(): Empty image!");
return null; return null;
} }
double [][]alphaFade = tp.getAlphaFade(clt_parameters.transform_size); double [][]alphaFade = tp.getAlphaFade(clt_parameters.transform_size);
if ((debugLevel > 0) && (scanIndex == 1)) { if ((debugLevel > 0) && (scanIndex == 1)) { // not used in lwir
String [] titles = new String[16]; String [] titles = new String[16];
for (int i = 0; i<titles.length;i++) titles[i]=""+i; for (int i = 0; i<titles.length;i++) titles[i]=""+i;
sdfa_instance.showArrays(alphaFade, 2*clt_parameters.transform_size,2*clt_parameters.transform_size,true,"alphaFade",titles); sdfa_instance.showArrays(alphaFade, 2*clt_parameters.transform_size,2*clt_parameters.transform_size,true,"alphaFade",titles);
...@@ -8710,7 +8710,7 @@ public class QuadCLT { ...@@ -8710,7 +8710,7 @@ public class QuadCLT {
if (texture_tiles[tileY][tileX] != null) { if (texture_tiles[tileY][tileX] != null) {
if (borderTiles[tileY * tilesX + tileX]) { if (borderTiles[tileY * tilesX + tileX]) {
texture_tiles_cluster[tileY][tileX]= texture_tiles[tileY][tileX].clone(); texture_tiles_cluster[tileY][tileX]= texture_tiles[tileY][tileX].clone();
if (clt_parameters.shAggrFade) { if (clt_parameters.shAggrFade) { // not used in lwir
texture_tiles_cluster[tileY][tileX][alpha_index] = alpha_zero; texture_tiles_cluster[tileY][tileX][alpha_index] = alpha_zero;
} else { } else {
if ((debugLevel > -1) && (scanIndex == 1)) { if ((debugLevel > -1) && (scanIndex == 1)) {
...@@ -8766,7 +8766,7 @@ public class QuadCLT { ...@@ -8766,7 +8766,7 @@ public class QuadCLT {
int width = resize ? (clt_parameters.transform_size * scan.getTextureBounds().width): (clt_parameters.transform_size * tilesX); int width = resize ? (clt_parameters.transform_size * scan.getTextureBounds().width): (clt_parameters.transform_size * tilesX);
int height = resize ? (clt_parameters.transform_size * scan.getTextureBounds().height): (clt_parameters.transform_size * tilesY); int height = resize ? (clt_parameters.transform_size * scan.getTextureBounds().height): (clt_parameters.transform_size * tilesY);
if ((width <= 0) || (height <= 0)) { if ((width <= 0) || (height <= 0)) {
System.out.println("***** BUG in getPassImage(): width="+width+", height="+height+", resize="+resize+" ****"); System.out.println("***** BUG in getPassImage(): width="+width+", height="+height+", resize="+resize+" ****"); // not used in lwir
} }
ImagePlus imp_texture_cluster = linearStackToColor( ImagePlus imp_texture_cluster = linearStackToColor(
...@@ -8804,7 +8804,7 @@ public class QuadCLT { ...@@ -8804,7 +8804,7 @@ public class QuadCLT {
public ImagePlus resizeForBackdrop( public ImagePlus resizeForBackdrop( // USED in lwir
ImagePlus imp, ImagePlus imp,
boolean fillBlack, boolean fillBlack,
boolean noalpha, // only with fillBlack, otherwise ignored boolean noalpha, // only with fillBlack, otherwise ignored
...@@ -8855,7 +8855,7 @@ public class QuadCLT { ...@@ -8855,7 +8855,7 @@ public class QuadCLT {
indx++; indx++;
} }
} }
} else { } else { // not used in lwir
for (int i = 0; i < height; i++){ for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){ for (int j = 0; j < width; j++){
pixels[offset+ i * width2 + j] = src_pixels[indx++]; pixels[offset+ i * width2 + j] = src_pixels[indx++];
...@@ -8871,7 +8871,7 @@ public class QuadCLT { ...@@ -8871,7 +8871,7 @@ public class QuadCLT {
//[tp.tilesY][tp.tilesX]["RGBA".length()][] //[tp.tilesY][tp.tilesX]["RGBA".length()][]
//linearStackToColor //linearStackToColor
public CLTPass3d CLTBackgroundMeas( // measure background public CLTPass3d CLTBackgroundMeas( // measure background // USED in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -8907,7 +8907,7 @@ public class QuadCLT { ...@@ -8907,7 +8907,7 @@ public class QuadCLT {
double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][]; double [][][][] texture_tiles = new double [tilesY][tilesX][][]; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux())); ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux()));
double z_correction = clt_parameters.z_correction; double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){ if (clt_parameters.z_corr_map.containsKey(image_name)){ // not used in lwir
z_correction +=clt_parameters.z_corr_map.get(image_name); z_correction +=clt_parameters.z_corr_map.get(image_name);
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
...@@ -8978,7 +8978,7 @@ public class QuadCLT { ...@@ -8978,7 +8978,7 @@ public class QuadCLT {
return scan_rslt; return scan_rslt;
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // USED in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -9000,7 +9000,7 @@ public class QuadCLT { ...@@ -9000,7 +9000,7 @@ public class QuadCLT {
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // not used in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
CLTParameters clt_parameters, CLTParameters clt_parameters,
...@@ -9023,7 +9023,7 @@ public class QuadCLT { ...@@ -9023,7 +9023,7 @@ public class QuadCLT {
updateStatus, // final boolean updateStatus, updateStatus, // final boolean updateStatus,
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // not used in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int scanIndex, final int scanIndex,
...@@ -9045,7 +9045,7 @@ public class QuadCLT { ...@@ -9045,7 +9045,7 @@ public class QuadCLT {
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // USED in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
CLTParameters clt_parameters, CLTParameters clt_parameters,
final int scanIndex, final int scanIndex,
...@@ -9068,7 +9068,7 @@ public class QuadCLT { ...@@ -9068,7 +9068,7 @@ public class QuadCLT {
debugLevel); // final int debugLevel); debugLevel); // final int debugLevel);
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // USED in lwir
// final String image_name, // final String image_name,
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
...@@ -9089,7 +9089,7 @@ public class QuadCLT { ...@@ -9089,7 +9089,7 @@ public class QuadCLT {
int [][] tile_op = scan.tile_op; int [][] tile_op = scan.tile_op;
// Should not happen ! // Should not happen !
double [][] disparity_array = scan.disparity; double [][] disparity_array = scan.disparity;
if (scan.disparity == null) { if (scan.disparity == null) { // not used in lwir
System.out.println ("** BUG: should not happen - scan.disparity == null ! **"); System.out.println ("** BUG: should not happen - scan.disparity == null ! **");
System.out.println ("Trying to recover"); System.out.println ("Trying to recover");
double [] backup_disparity = scan.getDisparity(0); double [] backup_disparity = scan.getDisparity(0);
...@@ -9141,7 +9141,7 @@ public class QuadCLT { ...@@ -9141,7 +9141,7 @@ public class QuadCLT {
ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux())); ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux()));
// final double disparity_corr = (clt_parameters.z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/clt_parameters.z_correction); // 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; double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){ if (clt_parameters.z_corr_map.containsKey(image_name)){ // not used in lwir
z_correction +=clt_parameters.z_corr_map.get(image_name); z_correction +=clt_parameters.z_corr_map.get(image_name);
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
...@@ -9212,7 +9212,7 @@ public class QuadCLT { ...@@ -9212,7 +9212,7 @@ public class QuadCLT {
} }
public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity public CLTPass3d CLTMeasure( // perform single pass according to prepared tiles operations and disparity // USED in lwir
final double [][][] image_data, // first index - number of image in a quad final double [][][] image_data, // first index - number of image in a quad
final boolean [][] saturation_imp, // (near) saturated pixels or null final boolean [][] saturation_imp, // (near) saturated pixels or null
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
...@@ -9274,7 +9274,7 @@ public class QuadCLT { ...@@ -9274,7 +9274,7 @@ public class QuadCLT {
double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][]; double [][][][] texture_tiles = save_textures ? new double [tilesY][tilesX][][] : null; // ["RGBA".length()][];
ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux())); ImageDtt image_dtt = new ImageDtt(isMonochrome(),clt_parameters.getScaleStrength(isAux()));
double z_correction = clt_parameters.z_correction; double z_correction = clt_parameters.z_correction;
if (clt_parameters.z_corr_map.containsKey(image_name)){ if (clt_parameters.z_corr_map.containsKey(image_name)){ // not used in lwir
z_correction +=clt_parameters.z_corr_map.get(image_name); z_correction +=clt_parameters.z_corr_map.get(image_name);
} }
final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction); final double disparity_corr = (z_correction == 0) ? 0.0 : geometryCorrection.getDisparityFromZ(1.0/z_correction);
...@@ -9345,7 +9345,7 @@ public class QuadCLT { ...@@ -9345,7 +9345,7 @@ public class QuadCLT {
public ImagePlus [] conditionImageSetBatch( // used in batchCLT3d public ImagePlus [] conditionImageSetBatch( // used in batchCLT3d // not used in lwir
final int nSet, // index of the 4-image set final int nSet, // index of the 4-image set
final CLTParameters clt_parameters, final CLTParameters clt_parameters,
final int [][] fileIndices, // =new int [numImagesToProcess][2]; // file index, channel number final int [][] fileIndices, // =new int [numImagesToProcess][2]; // file index, channel number
...@@ -9571,7 +9571,7 @@ public class QuadCLT { ...@@ -9571,7 +9571,7 @@ public class QuadCLT {
return imp_srcs; return imp_srcs;
} }
public void batchCLT3d( // Same can be ran for aux? public void batchCLT3d( // Same can be ran for aux? // not used in lwir
TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth TwoQuadCLT twoQuadCLT, //maybe null in no-rig mode, otherwise may contain rig measurements to be used as infinity ground truth
CLTParameters clt_parameters, CLTParameters clt_parameters,
EyesisCorrectionParameters.DebayerParameters debayerParameters, EyesisCorrectionParameters.DebayerParameters debayerParameters,
...@@ -9853,7 +9853,7 @@ public class QuadCLT { ...@@ -9853,7 +9853,7 @@ public class QuadCLT {
IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")"); IJ.d2s(0.000000001*(System.nanoTime()-this.startTime),3)+" sec, --- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
} }
public boolean setGpsLla( public boolean setGpsLla( // USED in lwir
String source_file) String source_file)
{ {
ImagePlus imp=(new JP46_Reader_camera(false)).open( ImagePlus imp=(new JP46_Reader_camera(false)).open(
...@@ -9873,11 +9873,11 @@ public class QuadCLT { ...@@ -9873,11 +9873,11 @@ public class QuadCLT {
if (imp.getProperty("ALTITUDE") != null) gps_lla[2] =Double.parseDouble((String) imp.getProperty("ALTITUDE")); if (imp.getProperty("ALTITUDE") != null) gps_lla[2] =Double.parseDouble((String) imp.getProperty("ALTITUDE"));
return true; return true;
} }
return false; return false; // not used in lwir
} }
public boolean writeKml( public boolean writeKml( // USED in lwir
int debugLevel ) int debugLevel )
{ {
String [] sourceFiles_main=correctionsParameters.getSourcePaths(); String [] sourceFiles_main=correctionsParameters.getSourcePaths();
...@@ -9915,7 +9915,7 @@ public class QuadCLT { ...@@ -9915,7 +9915,7 @@ public class QuadCLT {
return true; return true;
} }
public boolean createThumbNailImage( public boolean createThumbNailImage( // USED in lwir
ImagePlus imp, ImagePlus imp,
String dir, String dir,
String name, String name,
...@@ -9964,7 +9964,7 @@ public class QuadCLT { ...@@ -9964,7 +9964,7 @@ public class QuadCLT {
public boolean writeRatingFile( public boolean writeRatingFile( // USED in lwir
int debugLevel int debugLevel
) )
{ {
......
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