Commit 9cff4da3 authored by Andrey Filippov's avatar Andrey Filippov

preparing to VegetationLMA

parent fceab18b
...@@ -331,6 +331,7 @@ public class VegetationModel { ...@@ -331,6 +331,7 @@ public class VegetationModel {
} }
/* */ /* */
double [][][] veg_to_terr = new double [num_scenes][][]; double [][][] veg_to_terr = new double [num_scenes][][];
double [][][] terr_to_terr = new double [num_scenes][][];
Rectangle window1 = new Rectangle(0,0,640,512); Rectangle window1 = new Rectangle(0,0,640,512);
Rectangle window2 = out_window; Rectangle window2 = out_window;
boolean map_diff1 = true; boolean map_diff1 = true;
...@@ -345,6 +346,14 @@ public class VegetationModel { ...@@ -345,6 +346,14 @@ public class VegetationModel {
window2, // final Rectangle window2, window2, // final Rectangle window2,
map_diff2, // final boolean map_diff2, map_diff2, // final boolean map_diff2,
map_diff_out); // final boolean map_diff_out) map_diff_out); // final boolean map_diff_out)
terr_to_terr[nscene] = combineMaps(
terrain_pix[nscene], // final double [][] map1,
window1, // final Rectangle window1,
map_diff1, // final boolean map_diff1,
terrain_inv[nscene], // final double [][] map2,
window2, // final Rectangle window2,
map_diff2, // final boolean map_diff2,
map_diff_out); // final boolean map_diff_out)
} }
/* */ /* */
...@@ -397,6 +406,11 @@ public class VegetationModel { ...@@ -397,6 +406,11 @@ public class VegetationModel {
tilesX*tileSize, // final int width, tilesX*tileSize, // final int width,
quadCLTs, // QuadCLT [] quadCLTs, // just for names quadCLTs, // QuadCLT [] quadCLTs, // just for names
"combo_offset.tiff"); // String title) { // with .tiff "combo_offset.tiff"); // String title) { // with .tiff
showOffsetsCombo(
terr_to_terr, // final double [][][] map_combo,
tilesX*tileSize, // final int width,
quadCLTs, // QuadCLT [] quadCLTs, // just for names
"combo_terr-terr.tiff"); // String title) { // with .tiff
/* */ /* */
} }
...@@ -458,13 +472,17 @@ public class VegetationModel { ...@@ -458,13 +472,17 @@ public class VegetationModel {
} }
/* */ /* */
double [][] vegetation_mapped = new double [num_scenes][]; double [][] vegetation_mapped = new double [num_scenes][];
double scale_map = 1.0; // 0.5;
for (int nscene = 0; nscene < num_scenes; nscene++) { for (int nscene = 0; nscene < num_scenes; nscene++) {
vegetation_mapped[nscene] = applyMap( vegetation_mapped[nscene] = applyMap(
terrain_render[nscene][0], // final double [] img, // vegetation_render[nscene][0], // final double [] img,
terrain_vegetation_all[1][num_scenes], // final double [] img, // average vegetation
tilesX * tileSize, // final int img_width, tilesX * tileSize, // final int img_width,
veg_to_terr[nscene], // final double [][] map, veg_to_terr[nscene], // final double [][] map,
window1, // final Rectangle window, window1, // final Rectangle window,
map_diff_out); // final boolean map_diff) map_diff_out, // final boolean map_diff)
scale_map); // final double scale) { // debug feature, only works with differential map
} }
if (show_debug) { if (show_debug) {
...@@ -477,7 +495,7 @@ public class VegetationModel { ...@@ -477,7 +495,7 @@ public class VegetationModel {
ShowDoubleFloatArrays.showArraysHyperstack( ShowDoubleFloatArrays.showArraysHyperstack(
render3, // double[][][] pixels, render3, // double[][][] pixels,
tilesX * tileSize, // int width, tilesX * tileSize, // int width,
"terrain_vegetation_mapped.tiff", // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy, "terrain_vegetation_mapped-scale"+scale_map+".tiff", // String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles_scene, // String [] titles, // all slices*frames titles or just slice titles or null titles_scene, // String [] titles, // all slices*frames titles or just slice titles or null
titles_frame, // String [] frame_titles, // frame titles or null titles_frame, // String [] frame_titles, // frame titles or null
true); // boolean show) true); // boolean show)
...@@ -596,6 +614,7 @@ public class VegetationModel { ...@@ -596,6 +614,7 @@ public class VegetationModel {
* @param window Rectangle with {width, height} specifying output image size and (in * @param window Rectangle with {width, height} specifying output image size and (in
* differential mode only) {x,y} corresponds to absolute origin * differential mode only) {x,y} corresponds to absolute origin
* @param map_diff true for differential mode, false - for absolute. * @param map_diff true for differential mode, false - for absolute.
* @param scale debug feature, only works with differential map
* @return warped image in line-scan order, may have NaN-s. * @return warped image in line-scan order, may have NaN-s.
*/ */
public static double [] applyMap( public static double [] applyMap(
...@@ -603,7 +622,8 @@ public class VegetationModel { ...@@ -603,7 +622,8 @@ public class VegetationModel {
final int img_width, final int img_width,
final double [][] map, final double [][] map,
final Rectangle window, final Rectangle window,
final boolean map_diff) { final boolean map_diff,
final double scale) { // debug feature, only works with differential map
final int img_height = img.length /img_width; final int img_height = img.length /img_width;
final int num_pixels = window.width*window.height; final int num_pixels = window.width*window.height;
final double [] render_out = new double [num_pixels]; final double [] render_out = new double [num_pixels];
...@@ -619,8 +639,10 @@ public class VegetationModel { ...@@ -619,8 +639,10 @@ public class VegetationModel {
int iy = nPix / window.width; int iy = nPix / window.width;
double [] pxy = map[nPix].clone(); double [] pxy = map[nPix].clone();
if (map_diff) { if (map_diff) {
pxy[0] += 0.5 + ix - window.x; pxy[0] *= scale;
pxy[1] += 0.5 + iy - window.y; pxy[1] *= scale;
pxy[0] += ix - window.x; // + 0.5;
pxy[1] += iy - window.y; // + 0.5;
} }
// pxy[0] += window2.x; // pxy[0] += window2.x;
// pxy[1] += window2.y; // pxy[1] += window2.y;
...@@ -701,8 +723,8 @@ public class VegetationModel { ...@@ -701,8 +723,8 @@ public class VegetationModel {
int iy = nPix / window1.width; int iy = nPix / window1.width;
double [] pxy = map1[nPix].clone(); double [] pxy = map1[nPix].clone();
if (map_diff1) { if (map_diff1) {
pxy[0] += 0.5 + ix - window1.x; pxy[0] += ix - window1.x; // + 0.5;
pxy[1] += 0.5 + iy - window1.y; pxy[1] += iy - window1.y; // + 0.5;
} }
pxy[0] += window2.x; pxy[0] += window2.x;
pxy[1] += window2.y; pxy[1] += window2.y;
...@@ -724,8 +746,8 @@ public class VegetationModel { ...@@ -724,8 +746,8 @@ public class VegetationModel {
corners[dy][dx] = corners[dy][dx].clone(); corners[dy][dx] = corners[dy][dx].clone();
corner = corners[dy][dx]; corner = corners[dy][dx];
if (map_diff2) { if (map_diff2) {
corner[0] += x0 + dx + 0.5 - window2.x; corner[0] += x0 + dx - window2.x; // + 0.5;
corner[1] += y0 + dy + 0.5 - window2.y; corner[1] += y0 + dy - window2.y; // + 0.5;
} }
} }
} }
...@@ -741,8 +763,8 @@ public class VegetationModel { ...@@ -741,8 +763,8 @@ public class VegetationModel {
( fx)*( fy)*corners[1][1][i]; ( fx)*( fy)*corners[1][1][i];
} }
if (map_diff_out) { if (map_diff_out) {
cxy[0] -= 0.5 + ix - window1.x; cxy[0] -= ix - window1.x; // + 0.5;
cxy[1] -= 0.5 + iy - window1.y; cxy[1] -= iy - window1.y; // + 0.5;
} }
combo_map[nPix] = cxy; combo_map[nPix] = cxy;
} }
...@@ -819,8 +841,8 @@ public class VegetationModel { ...@@ -819,8 +841,8 @@ public class VegetationModel {
corners_cw[dir][ynx] = map_in[in_indx][ynx]; corners_cw[dir][ynx] = map_in[in_indx][ynx];
} }
if (in_diff) { if (in_diff) {
corners_cw[dir][0] += 0.5 + ix1; corners_cw[dir][0] += ix1; // + 0.5;
corners_cw[dir][1] += 0.5 + iy1; corners_cw[dir][1] += iy1; // + 0.5;
} }
corners_cw[dir][0] += out_window.x; corners_cw[dir][0] += out_window.x;
corners_cw[dir][1] += out_window.y; corners_cw[dir][1] += out_window.y;
...@@ -907,8 +929,8 @@ public class VegetationModel { ...@@ -907,8 +929,8 @@ public class VegetationModel {
map_out[oindx][0] = ix0 + u; map_out[oindx][0] = ix0 + u;
map_out[oindx][1] = iy0 + v; map_out[oindx][1] = iy0 + v;
if (out_diff) { if (out_diff) {
map_out[oindx][0] -= ox-out_window.x-0.5; map_out[oindx][0] -= ox-out_window.x; // -0.5;
map_out[oindx][1] -= oy-out_window.y-0.5; map_out[oindx][1] -= oy-out_window.y; // -0.5;
} }
} }
} }
......
...@@ -176,7 +176,7 @@ public class OpticalFlow { ...@@ -176,7 +176,7 @@ public class OpticalFlow {
* @param debug_level debug level * @param debug_level debug level
*/ */
public void fillTilesNans( public static void fillTilesNans(
final double [][][] nan_tiles, final double [][][] nan_tiles,
final QuadCLT qthis, final QuadCLT qthis,
final int num_passes, final int num_passes,
......
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