Commit 02a4440e authored by Andrey Filippov's avatar Andrey Filippov

Documenting, cleaning up

parent b4600e81
...@@ -3172,7 +3172,7 @@ public class CLTParameters { ...@@ -3172,7 +3172,7 @@ public class CLTParameters {
gd.addNumericField("Lazy eye cluster size", this.tileStep, 0, 6, "tiles", gd.addNumericField("Lazy eye cluster size", this.tileStep, 0, 6, "tiles",
"Process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters"); "Process tileStep x tileStep cluster of tiles when adjusting lazy eye parameters");
gd.addNumericField("Consolidate multiple clusterts around given for low-contrast infinity", this.super_radius, 0, 6, "clusters", gd.addNumericField("Consolidate multiple clusterts around given for low-contrast infinity", this.super_radius, 0, 6, "clusters",
"e.g. for clouds in tghe sky 0 - none, 1 - 3x3, 2 - 5x5"); "e.g. for clouds in the sky 0 - none, 1 - 3x3, 2 - 5x5");
gd.addNumericField("Bit mask - which of 4 transforms to combine after iclt", this.iclt_mask, 0); gd.addNumericField("Bit mask - which of 4 transforms to combine after iclt", this.iclt_mask, 0);
gd.addNumericField("Tile X to extract (0..163)", this.tileX, 0); gd.addNumericField("Tile X to extract (0..163)", this.tileX, 0);
gd.addNumericField("Tile Y to extract (0..122)", this.tileY, 0); gd.addNumericField("Tile Y to extract (0..122)", this.tileY, 0);
...@@ -3628,7 +3628,7 @@ public class CLTParameters { ...@@ -3628,7 +3628,7 @@ public class CLTParameters {
gd.addNumericField("Maximal motion blur to reduce weight",this.tex_mb, 5,7,"pix", gd.addNumericField("Maximal motion blur to reduce weight",this.tex_mb, 5,7,"pix",
"Reduce texture weight if motion blur exceeds this (as square of MB length)."); "Reduce texture weight if motion blur exceeds this (as square of MB length).");
gd.addNumericField("Max disparity for meshe generation", this.tex_max_disparity_lim, 5,7,"pix", gd.addNumericField("Max disparity for mesh generation", this.tex_max_disparity_lim, 5,7,"pix",
"Do not allow stray disparities above this."); "Do not allow stray disparities above this.");
gd.addNumericField("Minimal disparity for FG trimming", this.tex_min_trim_disparity, 5,7,"pix", gd.addNumericField("Minimal disparity for FG trimming", this.tex_min_trim_disparity, 5,7,"pix",
"Do not try to trim texture outlines with lower disparities."); "Do not try to trim texture outlines with lower disparities.");
......
...@@ -142,7 +142,7 @@ public class IntersceneMatchParameters { ...@@ -142,7 +142,7 @@ public class IntersceneMatchParameters {
public double cold_scale = 0.2; // <=1.0. 1.0 - disables temperature dependence public double cold_scale = 0.2; // <=1.0. 1.0 - disables temperature dependence
public double sky_seed = 5.0; // start with product of strength by diff_second below this public double sky_seed = 5.0; // start with product of strength by diff_second below this
public double lma_seed = 2.0; // seed - disparity_lma limit double sky_lim = 15.0; // then expand to product of strength by diff_second below this public double lma_seed = 2.0; // seed - disparity_lma limit double sky_lim = 15.0; // then expand to product of strength by diff_second below this
public int sky_shrink = 3; public int sky_shrink = 2;
public int seed_rows = 5; // sky should appear in this top rows public int seed_rows = 5; // sky should appear in this top rows
public double sky_lim = 15.0; // then expand to product of strength by diff_second below this public double sky_lim = 15.0; // then expand to product of strength by diff_second below this
public int sky_expand_extra = 0; // 1? public int sky_expand_extra = 0; // 1?
......
...@@ -4878,7 +4878,7 @@ public class OpticalFlow { ...@@ -4878,7 +4878,7 @@ public class OpticalFlow {
// generates 3-d modes, colors, stereos, tiffs/videos // generates 3-d modes, colors, stereos, tiffs/videos
if (generate_mapped || reuse_video) { if (generate_mapped || reuse_video) { // modifies combo_dsn_final ?
int tilesX = quadCLTs[ref_index].getTileProcessor().getTilesX(); int tilesX = quadCLTs[ref_index].getTileProcessor().getTilesX();
int tilesY = quadCLTs[ref_index].getTileProcessor().getTilesY(); int tilesY = quadCLTs[ref_index].getTileProcessor().getTilesY();
double [] disparity_fg = null; double [] disparity_fg = null;
...@@ -4895,7 +4895,7 @@ public class OpticalFlow { ...@@ -4895,7 +4895,7 @@ public class OpticalFlow {
0, // int num_slices, // (0 - all) 0, // int num_slices, // (0 - all)
null); // int [] wh); null); // int [] wh);
} }
double [][] dls = { double [][] dls = {
combo_dsn_final[COMBO_DSN_INDX_DISP], combo_dsn_final[COMBO_DSN_INDX_DISP],
combo_dsn_final[COMBO_DSN_INDX_LMA], combo_dsn_final[COMBO_DSN_INDX_LMA],
combo_dsn_final[COMBO_DSN_INDX_STRENGTH] combo_dsn_final[COMBO_DSN_INDX_STRENGTH]
...@@ -5328,7 +5328,7 @@ public class OpticalFlow { ...@@ -5328,7 +5328,7 @@ public class OpticalFlow {
// debugging 3D model // debugging 3D model
if (export3d) { if (export3d) { //combo_dsn_final had strength 1.0e-4 where it should not? Reset it?
boolean ok_3d = TexturedModel.output3d( // quadCLTs have same image name, and everything else boolean ok_3d = TexturedModel.output3d( // quadCLTs have same image name, and everything else
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
colorProcParameters, // ColorProcParameters colorProcParameters, colorProcParameters, // ColorProcParameters colorProcParameters,
...@@ -10472,7 +10472,8 @@ public class OpticalFlow { ...@@ -10472,7 +10472,8 @@ public class OpticalFlow {
sigma); // double sigma); sigma); // double sigma);
dbg_img[11] = disp.clone(); dbg_img[11] = disp.clone();
double [][] ds = {disp, dls[2]}; double [][] ds = {disp, dls[2]};
if (blue_sky != null) { // Temporary, dix - pass blue_sky to fillDisparityStrength() if (blue_sky != null) { // Temporary, fix - pass blue_sky to fillDisparityStrength()
ds[1] = ds[1].clone();
for (int i = 0; i < clean_lma.length; i++) if (blue_sky[i]){ for (int i = 0; i < clean_lma.length; i++) if (blue_sky[i]){
ds[0][i] = 0.0; ds[0][i] = 0.0;
ds[1][i] = 0.0001; ds[1][i] = 0.0001;
......
...@@ -1653,7 +1653,7 @@ public class TexturedModel { ...@@ -1653,7 +1653,7 @@ public class TexturedModel {
final int jpeg_quality = clt_parameters.tex_jpeg_quality; //95; // JPEG quality for textures final int jpeg_quality = clt_parameters.tex_jpeg_quality; //95; // JPEG quality for textures
final boolean showTri = !batch_mode && (debugLevel > -1) && (clt_parameters.show_triangles); final boolean showTri = !batch_mode && (debugLevel > -1) && (clt_parameters.show_triangles);
final boolean disp_hires_tri = clt_parameters.tex_disp_hires_tri; final boolean disp_hires_tri = !batch_mode && clt_parameters.tex_disp_hires_tri;
final int dbg_scale_mesh = clt_parameters.tex_dbg_scale_mesh; // 4; // <=0 - do not show final int dbg_scale_mesh = clt_parameters.tex_dbg_scale_mesh; // 4; // <=0 - do not show
...@@ -1678,6 +1678,11 @@ public class TexturedModel { ...@@ -1678,6 +1678,11 @@ public class TexturedModel {
final int width = tilesX * transform_size; final int width = tilesX * transform_size;
final int height = tp.getTilesY() * transform_size; final int height = tp.getTilesY() * transform_size;
// get multi-scene disparity map for FG and BG and filter it // get multi-scene disparity map for FG and BG and filter it
if (combo_dsn_final != null) {
System.out.println("output3d(): combo_dsn_final is not null - setting it to null");
System.out.println("As there was a problem with (wrong?) blue sky setting strength to 0.0001");
combo_dsn_final = null;
}
if (combo_dsn_final == null) { if (combo_dsn_final == null) {
combo_dsn_final =scenes[ref_index].readDoubleArrayFromModelDirectory( combo_dsn_final =scenes[ref_index].readDoubleArrayFromModelDirectory(
"-INTER-INTRA-LMA", // String suffix, "-INTER-INTRA-LMA", // String suffix,
...@@ -2000,9 +2005,8 @@ public class TexturedModel { ...@@ -2000,9 +2005,8 @@ public class TexturedModel {
tp.getTilesY(), // int tilesY, tp.getTilesY(), // int tilesY,
ref_scene.getGeometryCorrection(), // GeometryCorrection geometryCorrection, ref_scene.getGeometryCorrection(), // GeometryCorrection geometryCorrection,
clt_parameters.correct_distortions, // requires backdrop image to be corrected also clt_parameters.correct_distortions, // requires backdrop image to be corrected also
dbg_mesh_imgs[nslice], // double [] tri_img, // ((dbg_mesh_imgs != null) ? dbg_mesh_imgs[nslice]:null), // double [] tri_img, //
dbg_scaled_width, // int tri_img_width, dbg_scaled_width, // int tri_img_width,
// showTri, // (scanIndex < next_pass + 1) && clt_parameters.show_triangles,
// FIXME: make a separate parameter: // FIXME: make a separate parameter:
infinity_disparity, // 0.25 * clt_parameters.bgnd_range, // 0.3 infinity_disparity, // 0.25 * clt_parameters.bgnd_range, // 0.3
clt_parameters.grow_disp_max, // other_range, // 2.0 'other_range - difference from the specified (*_CM) clt_parameters.grow_disp_max, // other_range, // 2.0 'other_range - difference from the specified (*_CM)
...@@ -2010,7 +2014,6 @@ public class TexturedModel { ...@@ -2010,7 +2014,6 @@ public class TexturedModel {
clt_parameters.maxZtoXY, // double maxZtoXY, // 10.0. <=0 - do not use clt_parameters.maxZtoXY, // double maxZtoXY, // 10.0. <=0 - do not use
clt_parameters.maxZ, clt_parameters.maxZ,
clt_parameters.limitZ, clt_parameters.limitZ,
// dbg_disp_tri_slice, // double [][] dbg_disp_tri_slice,
debugLevel + 1, // int debug_level) > 0 debugLevel + 1, // int debug_level) > 0
clt_parameters.tex_dbg_plot_center, // boolean dbg_plot_center, // = true; clt_parameters.tex_dbg_plot_center, // boolean dbg_plot_center, // = true;
clt_parameters.tex_dbg_line_color, // double dbg_line_color, // = 1.0; clt_parameters.tex_dbg_line_color, // double dbg_line_color, // = 1.0;
......
...@@ -392,6 +392,11 @@ public class TileNeibs{ ...@@ -392,6 +392,11 @@ public class TileNeibs{
return -1; // should not happen return -1; // should not happen
} }
/**
* Invert selection in a single or multithreaded environment.
* @param tiles array to invert
* @return inverted array
*/
public static boolean [] invertSelection( public static boolean [] invertSelection(
final boolean [] tiles) { final boolean [] tiles) {
final boolean [] itiles = new boolean [tiles.length]; final boolean [] itiles = new boolean [tiles.length];
...@@ -399,6 +404,12 @@ public class TileNeibs{ ...@@ -399,6 +404,12 @@ public class TileNeibs{
return itiles; return itiles;
} }
/**
* Invert selection in a single or multithreaded environment. May be in-place if tiles and itiles
* are the same array.
* @param tiles input array to be inverted
* @param itiles output array of the same size as the input one. May be the same as tiles
*/
public static void invertSelection( public static void invertSelection(
final boolean [] tiles, final boolean [] tiles,
final boolean [] itiles final boolean [] itiles
...@@ -423,6 +434,12 @@ public class TileNeibs{ ...@@ -423,6 +434,12 @@ public class TileNeibs{
} }
} }
/**
* And boolean array to another boolean array in a single or multithreaded environment.
* dst_tiles &= src_tiles
* @param src_tiles array to AND to another one
* @param dst_tiles array to be modified by AND-ing with the first one
*/
public static void andSelection( public static void andSelection(
final boolean [] src_tiles, final boolean [] src_tiles,
final boolean [] dst_tiles final boolean [] dst_tiles
...@@ -448,10 +465,16 @@ public class TileNeibs{ ...@@ -448,10 +465,16 @@ public class TileNeibs{
} }
/**
* Shrink boolean array (single or multithreaded depending on is
* it called from the main thread or not)
* @param shrink see definitons for growSelection()
* @param tiles selection array (should be [sizeX * sizeY])
* @param prohibit optional (may be null) array of prohibited tiles (for both originating and destination)
*/
public void shrinkSelection( public void shrinkSelection(
int shrink, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more final int shrink, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
final boolean [] tiles, final boolean [] tiles,
final boolean [] prohibit) final boolean [] prohibit)
{ {
final boolean [] itiles = invertSelection(tiles); final boolean [] itiles = invertSelection(tiles);
...@@ -463,6 +486,14 @@ public class TileNeibs{ ...@@ -463,6 +486,14 @@ public class TileNeibs{
} }
/**
* Select outmost pixels of the selection (single or multithreaded depending on is
* it called from the main thread or not)
* @param shrink see definitons for growSelection()
* @param tiles selection array (should be [sizeX * sizeY])
* @param prohibit optional (may be null) array of prohibited tiles
* @return tile selection of the outmost tiles of the input tiles
*/
public boolean [] getEdgeSelection( public boolean [] getEdgeSelection(
int shrink, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more int shrink, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
boolean [] tiles, boolean [] tiles,
...@@ -807,6 +838,14 @@ public class TileNeibs{ ...@@ -807,6 +838,14 @@ public class TileNeibs{
} }
} }
/**
* Grow pixel selection in multiple threads.
* @param grow amount of growth: 1 - 1 pixel in ortho (up/down, right/left) directions,
* 2 - ortho+diagonal, 3 - 2 steps in ortho, etc.
* @param tiles boolean array to grow (should be [sizeX * sizeY])
* @param prohibit optional array (may be null) that prohibits growth (for both originating and
* destination tiles).
*/
public void growSelectionMulti( // multithreaded version public void growSelectionMulti( // multithreaded version
int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
final boolean [] tiles, final boolean [] tiles,
...@@ -925,12 +964,26 @@ public class TileNeibs{ ...@@ -925,12 +964,26 @@ public class TileNeibs{
/**
* Find out if the current thread is main.
* @return true for the main thread, false - for others
*/
public static boolean isMainThread() { public static boolean isMainThread() {
return Thread.currentThread().getName().equals("main"); return Thread.currentThread().getName().equals("main");
} }
/**
* Grow pixel selection in either a single thread (if the method is called from one of
* concurrent threads (already used by multiple callers) or in multiple threads if the
* current thread is "main"
* @param grow amount of growth: 1 - 1 pixel in ortho (up/down, right/left) directions,
* 2 - ortho+diagonal, 3 - 2 steps in ortho, etc.
* @param tiles boolean array to grow (should be [sizeX * sizeY])
* @param prohibit optional array (may be null) that prohibits growth (for both originating and
* destination tiles).
*/
public void growSelection( public void growSelection(
int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more int grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
final boolean [] tiles, final boolean [] tiles,
......
...@@ -8591,10 +8591,6 @@ ImageDtt.startAndJoin(threads); ...@@ -8591,10 +8591,6 @@ ImageDtt.startAndJoin(threads);
} }
public double [] convolveTiles( public double [] convolveTiles(
double [] tiles, double [] tiles,
double [][] kernel_in) // should be odd * odd, with non-zero sum (result will be normalized double [][] kernel_in) // should be odd * odd, with non-zero sum (result will be normalized
...@@ -8639,7 +8635,23 @@ ImageDtt.startAndJoin(threads); ...@@ -8639,7 +8635,23 @@ ImageDtt.startAndJoin(threads);
return -1; return -1;
} }
/**
* Fill NaN values in 2D array from neighbors using Laplassian==0
* @param data data array (in line-scan order) with NaN values to be filled,
* non-NaN values will not be modified.
* @param prohibit optional (may be null) boolean array of the same size specifying
* prohibited pixels.
* @param width data width (height = data.length/width)
* @param grow limit area to process by expanding defined pixel area.
* @param diagonal_weight weight of 4 diagonal neighbors relative to 4 ortho ones.
* @param num_passes maximal number of iterations.
* @param max_rchange max relative (to data RMS) step change to exit iterations.
* @param threadsMax maximal number of concurrent threads to launch.
* @return data array made of input data with replaced NaN limited by
* optional prohibit array and amount of growth.
*/
public static double [] fillNaNs( public static double [] fillNaNs(
final double [] data, final double [] data,
final boolean [] prohibit, final boolean [] prohibit,
...@@ -8657,8 +8669,8 @@ ImageDtt.startAndJoin(threads); ...@@ -8657,8 +8669,8 @@ ImageDtt.startAndJoin(threads);
final int tiles = width * height; final int tiles = width * height;
final boolean [] fixed = new boolean [tiles]; // Original non-NaN, will not be modified final boolean [] fixed = new boolean [tiles]; // Original non-NaN, will not be modified
int num_fixed = 0; int num_fixed = 0;
double davg = 0.0; // average of all fixed samples double davg = 0.0; // average of all fixed samples
double davg2 = 0.0; // average of all fixed samples double davg2 = 0.0; // average of all fixed samples
for (int i = 0; i < tiles; i++) { for (int i = 0; i < tiles; i++) {
if (!Double.isNaN(data[i])) { if (!Double.isNaN(data[i])) {
fixed[i] = true; fixed[i] = true;
...@@ -8687,14 +8699,6 @@ ImageDtt.startAndJoin(threads); ...@@ -8687,14 +8699,6 @@ ImageDtt.startAndJoin(threads);
int last_grown = tn.getLastGrown(); // actual grown (0 <= last_grown <= grow) int last_grown = tn.getLastGrown(); // actual grown (0 <= last_grown <= grow)
final int scan0 = last_grown/2 + 2; // ( 3* grow) / 2; final int scan0 = last_grown/2 + 2; // ( 3* grow) / 2;
/*
growTiles(
grow, // grow tile selection by 1 over non-background tiles 1: 4 directions, 2 - 8 directions, 3 - 8 by 1, 4 by 1 more
grown,
null,
width,
height);
*/
int num_active = 0; int num_active = 0;
for (int i = 0; i < tiles; i++) { for (int i = 0; i < tiles; i++) {
if (grown[i] && !fixed[i]) num_active++; if (grown[i] && !fixed[i]) num_active++;
...@@ -8709,7 +8713,6 @@ ImageDtt.startAndJoin(threads); ...@@ -8709,7 +8713,6 @@ ImageDtt.startAndJoin(threads);
for (int i = 0; i < tiles; i++) { for (int i = 0; i < tiles; i++) {
if (grown[i] && !fixed[i]) { if (grown[i] && !fixed[i]) {
active [num_active++] = i; active [num_active++] = i;
// data_io[0][i] = davg; // initial value - needed?
} }
} }
final Thread[] threads = ImageDtt.newThreadArray(threadsMax); final Thread[] threads = ImageDtt.newThreadArray(threadsMax);
......
...@@ -2094,12 +2094,10 @@ public class TriMesh { ...@@ -2094,12 +2094,10 @@ public class TriMesh {
} }
return -1; return -1;
} }
// used in old code - change to the new one?
public static void generateClusterX3d( public static void generateClusterX3d(
boolean full_texture, // true - full size image, false - bounds only boolean full_texture, // true - full size image, false - bounds only
int subdivide_mesh, // 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels int subdivide_mesh, // 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels
// boolean [] alpha, // boolean alpha - true - opaque, false - transparent. Full/bounds
// matching selection
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
ArrayList<TriMesh> tri_meshes, ArrayList<TriMesh> tri_meshes,
...@@ -2125,7 +2123,6 @@ public class TriMesh { ...@@ -2125,7 +2123,6 @@ public class TriMesh {
int debug_level int debug_level
) throws IOException ) throws IOException
{ {
// int debug_level = 1;
if (bounds == null) { if (bounds == null) {
return; // not used in lwir return; // not used in lwir
} }
...@@ -2314,14 +2311,12 @@ public class TriMesh { ...@@ -2314,14 +2311,12 @@ public class TriMesh {
double maxZtoXY, // 10.0. <=0 - do not use double maxZtoXY, // 10.0. <=0 - do not use
double maxZ, // far clip (0 - do not clip). Negative - limit by max double maxZ, // far clip (0 - do not clip). Negative - limit by max
boolean limitZ, boolean limitZ,
// double [][] dbg_disp_tri_slice,
int debug_level, int debug_level,
boolean dbg_plot_center, // = true; boolean dbg_plot_center, // = true;
double dbg_line_color, // = 1.0; double dbg_line_color, // = 1.0;
double dbg_center_color// = 3.0; double dbg_center_color// = 3.0;
) throws IOException ) throws IOException
{ {
// boolean show_triangles = tri_img != null;
if (bounds == null) { if (bounds == null) {
return; // not used in lwir return; // not used in lwir
} }
...@@ -2329,8 +2324,6 @@ public class TriMesh { ...@@ -2329,8 +2324,6 @@ public class TriMesh {
boolean display_src = debug_level > 1; boolean display_src = debug_level > 1;
boolean display_for_mesh = debug_level > 1; boolean display_for_mesh = debug_level > 1;
if (display_src) { if (display_src) {
double [][] dbg_img = new double [3][selected.length]; double [][] dbg_img = new double [3][selected.length];
for (int i = 0; i < dbg_img[0].length; i++) { for (int i = 0; i < dbg_img[0].length; i++) {
...@@ -2378,12 +2371,6 @@ public class TriMesh { ...@@ -2378,12 +2371,6 @@ public class TriMesh {
} }
} }
/*
int [][] indices = getCoordIndices( // starting with 0, -1 - not selected // updated 09.18.2022
bounds,
selected,
tilesX);
*/
int [] pnum_indices = new int[1]; int [] pnum_indices = new int[1];
/* /*
* Enumerate "large" and "small" tiles, where "large" are actual tiles and "small" are * Enumerate "large" and "small" tiles, where "large" are actual tiles and "small" are
......
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