Commit 151ea276 authored by Andrey Filippov's avatar Andrey Filippov

Minor changes here and there during program use/debugging

parent 67ee5db2
......@@ -28,8 +28,8 @@ public class ThermalColor {
double k = out_range/PALETTE_RANGE;
double value = (v-min)/(max-min) * (this.palette.length - 1);
int ivalue = (int) (value);
if (ivalue < 0) return this.palette[0];
if (ivalue >= (this.palette.length -1)) return this.palette[this.palette.length -1];
if (value < 0) return this.palette[0];
if (value >= (this.palette.length -1)) return this.palette[this.palette.length -1];
double a = (value-ivalue); // 0..1
double [] rslt = {
k*((1 - a) * this.palette[ivalue][0] + a * this.palette[ivalue+1][0]),
......
......@@ -116,7 +116,7 @@ public class IntersceneLmaParameters {
gd.addMessage("Interframe LMA parameters selection");
gd.addCheckbox ("3D mode (use disparity)", this.ilma_3d,
"Use disparity for interscene matching (as for UAS imagery)" );
gd.addNumericField("Disp[arity weight", this.ilma_disparity_weight, 6,8,"",
gd.addNumericField("Disparity weight", this.ilma_disparity_weight, 6,8,"",
"Disparity component weight compared to dX and dY");
gd.addCheckbox ("LMA in 3D mode", this.ilma_3d_lma,
"Use LMA disparity for interscene matching (as for UAS imagery)" );
......
......@@ -223,6 +223,7 @@ public class QuadCLTCPU {
// cac
public double [][] getGround(
boolean use_lma,
double disparity_offset,
double discard_low, // fraction of all pixels
double discard_high, // fraction of all pixels
double discard_adisp, // discard above/below this fraction of average height
......@@ -234,22 +235,24 @@ public class QuadCLTCPU {
int debug_level
) {
double [] z_tilts = null;
final int tilesX=getTileProcessor().getTilesX();
final int tilesY=getTileProcessor().getTilesY();
double hist_rlow = 0.4;
double normal_damping = 0.001; // pull to horizontal if not enough data
// final int tilesX=getTileProcessor().getTilesX();
// final int tilesY=getTileProcessor().getTilesY();
double hist_rlow = 0.5;
double hist_rhigh = 2.0;
int min_good = 20; //number of good tiles
int min_good_quad = 20; // number of good tiles per quadrantto calculate tilts
int gap_frac2= 20;
/// int min_good_quad = 20; // number of good tiles per quadrant to calculate tilts
/// int gap_frac2= 20;
double rel_hight = 0.2; // when calculating scale, ignore objects far from plane
int num_bins = 1000;
double [][] dls = getDLS();
if (dls==null) {
return null;
}
double [][] ds = new double [][] {dls[use_lma?1:0], dls[2]};
double [][] ds = new double [][] {dls[use_lma?1:0].clone(), dls[2]};
double sw=0, swd=0;
for (int i = 0; i < ds[0].length; i++) if (!Double.isNaN(ds[0][i])){
ds[0][i] -= disparity_offset;
sw += ds[1][i];
swd += ds[0][i] * ds[1][i];
}
......@@ -318,7 +321,9 @@ public class QuadCLTCPU {
}
return null; // too few good
}
double z_avg= getGeometryCorrection().getZFromDisparity(swd/sw);
// double z_avg= getGeometryCorrection().getZFromDisparity(swd/sw);
/*
int gap_x_0 = tilesX/2 - tilesX/gap_frac2;
int gap_x_1 = tilesX/2 + tilesX/gap_frac2;
int gap_y_0 = tilesY/2 - tilesY/gap_frac2;
......@@ -348,9 +353,11 @@ public class QuadCLTCPU {
System.out.println("There are less than 3 quadrants ("+num_good_quads+") having more than "+min_good_quad+" tiles");
System.out.println("Using only level "+z_avg+", ignoring tilt.");
}
z_tilts = new double[] {z_avg, 0.0, 0.0}; // no tilts
z_tilts = new double[] {-z_avg, 0.0, 0.0}; // no tilts
// return new double[] {z_avg, 0.0, 0.0}; // no tilts
} else {
*/
// fit plane
double [] ref_disparity = ds[0].clone();
for (int i = 0; i < ref_disparity.length; i++) {
......@@ -381,17 +388,18 @@ public class QuadCLTCPU {
mindx++;
}
PolynomialApproximation pa = new PolynomialApproximation();
double [] damping = new double [] {normal_damping, normal_damping};
double[][] approx2d = pa.quadraticApproximation(
mdata,
true, // boolean forceLinear, // use linear approximation
null, // double [] damping, null OK
damping, // double [] damping, null OK
-1); // debug level
z_tilts= new double [] { approx2d[0][2], approx2d[0][0], approx2d[0][1]};
if (debug_level > -3) {
System.out.println("Found ground plane: level="+z_tilts[0]+", tiltX="+z_tilts[1]+", tiltY="+z_tilts[2]);
}
}
/* } */
// ground - negative Z. picture right - positive X, picture up - positive Y
// positive tiltX - to the right higher ground (lower altitude above it) or camera tilted left
// positive tiltY - picture up - higher ground (or camera tilted back)
......@@ -402,11 +410,16 @@ public class QuadCLTCPU {
// It is approximate for small angles. OK for now
double [][] to_ground_xyxatr = ErsCorrection.invertXYZATR(ground_xyxatr);
// recalculate coordinates for all pixels including weak ones
double [] ref_disparity = dls[0].clone();
// double []
ref_disparity = dls[0].clone();
for (int i = 0; i < ref_disparity.length; i++) {
if (Double.isNaN(ref_disparity[i])) ref_disparity[i] = 0.0;
else {
ref_disparity[i] -= disparity_offset;
}
}
double [][] wxyz = OpticalFlow.transformToWorldXYZ(
// double [][]
wxyz = OpticalFlow.transformToWorldXYZ(
ref_disparity, // final double [] disparity_ref, // invalid tiles - NaN in disparity
(QuadCLT) this, // final QuadCLT quadClt, // now - may be null - for testing if scene is rotated ref
THREADS_MAX); // int threadsMax)
......@@ -432,8 +445,11 @@ public class QuadCLTCPU {
if (y < y_min_max[0]) y_min_max[0] = y;
else if (y > y_min_max[1]) y_min_max[1] = y;
}
if ((x_min_max == null) || (y_min_max == null)) {
return null; // no points at all?
}
if (x0y0!=null) {
x0y0[0] = x_min_max[0];
x0y0[0] = x_min_max[0]; // null
x0y0[1] = y_min_max[0];
}
int scale = 0;
......@@ -8387,6 +8403,9 @@ public class QuadCLTCPU {
double [][] rgba = new double [num_slices][];
for (int i = 0; i < 3; i++) rgba[i] = new double [texture_data[main_color_index].length];
for (int i = 0; i < rbg_in[main_color_index].length; i++) {
if (i==160000) {
System.out.println ("i="+i);
}
double [] rgb = tc.getRGB(texture_data[main_color_index][i]);
rgba[0][i] = rgb[0]; // red
rgba[1][i] = rgb[1]; // green
......@@ -15421,6 +15440,7 @@ public class QuadCLTCPU {
public boolean writeLwirPreview(
final CLTParameters clt_parameters,
double [] data,
double [] minmax, // null for auto
QuadCLT scene,
int tex_palette,
String suffix,
......@@ -15429,6 +15449,7 @@ public class QuadCLTCPU {
clt_parameters,
data,
getTileProcessor().getTilesX() *getTileProcessor().getTileSize(),
minmax, // double [] minmax, // null for auto
scene,
tex_palette,
suffix,
......@@ -15438,6 +15459,7 @@ public class QuadCLTCPU {
final CLTParameters clt_parameters,
double [] data,
int width,
double [] minmax, // null for auto
QuadCLT scene,
int tex_palette,
String suffix,
......@@ -15449,7 +15471,15 @@ public class QuadCLTCPU {
for (int i = 0; i < rendered_texture[0].length; i++) {
rendered_texture[1][i] = Double.isNaN(rendered_texture[0][i])? 0.0: 1.0;
}
double [] minmax = scene.getColdHot(); // used in linearStackToColor (from this current scene)
// double [] minmax = scene.getColdHot(); // used in linearStackToColor (from this current scene)
if (!suffix.equals("")) {
if (minmax == null) { // to replace standard preview file name
minmax = scene.getColdHot(); // used in linearStackToColor (from this current scene)
suffix +="-AUTORANGE";
} else {
suffix +="-RANGE"+(minmax[1]-minmax[0]);
}
}
// int width = getTileProcessor().getTilesX() *getTileProcessor().getTileSize();
int height = data.length/width;
String set_name = getImageName();
......
......@@ -69,7 +69,7 @@ public class Render3D {
this.out_width = out_width;
this.out_height = out_height;
this.toground = toground;
this.tocam = ErsCorrection.invertXYZATR(this.toground);
this.tocam = ErsCorrection.invertXYZATR(this.toground); // null
// double [][] test1 = ErsCorrection.invertXYZATR(this.tocam); //OK
// double [][] test2 = ErsCorrection.invertXYZATR(test1); // OK
// ground plane x0, y0 in camera coordinates
......
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