Commit baed6b68 authored by Andrey Filippov's avatar Andrey Filippov

Improving code related to the synthetic images, adding comments.

parent ada7257a
...@@ -5827,15 +5827,6 @@ public class Eyesis_Correction implements PlugIn, ActionListener { ...@@ -5827,15 +5827,6 @@ public class Eyesis_Correction implements PlugIn, ActionListener {
SYNC_COMMAND, // // SyncCommand SYNC_COMMAND, SYNC_COMMAND, // // SyncCommand SYNC_COMMAND,
CLT_PARAMETERS, // CLTParameters clt_parameters, CLT_PARAMETERS, // CLTParameters clt_parameters,
DEBUG_LEVEL); // final int debugLevel DEBUG_LEVEL); // final int debugLevel
/*
} else if (label.equals("Test LDLT Cholesky")) {
ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) {
IJ.showMessage("Error", "No images selected");
return;
}
CholeskyLDLTMulti.testCholesky(imp_sel); // ImagePlus imp.);
*/
} else if (label.equals("Test LLT Cholesky")) { } else if (label.equals("Test LLT Cholesky")) {
ImagePlus imp_sel = WindowManager.getCurrentImage(); ImagePlus imp_sel = WindowManager.getCurrentImage();
if (imp_sel == null) { if (imp_sel == null) {
......
...@@ -989,9 +989,11 @@ min_str_neib_fpn 0.35 ...@@ -989,9 +989,11 @@ min_str_neib_fpn 0.35
public String synth_directory = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/restore_foliage/01/"; public String synth_directory = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/restore_foliage/01/";
public String synth_scene = "1697877490_630338"; public String synth_scene = "1697877490_630338";
public String synth_model = "-preview_segments-0-0-640-512-ACCUM.tiff"; public String synth_model = "-preview_segments-0-0-640-512-ACCUM.tiff";
// public String synth_source = "_warps.tiff"; public String synth_segments = ".vegetation-segments"; // serialized: number of models, array of models
public String synth_render = "_synth-render.tiff"; public String synth_render = "_synth-render.tiff";
public boolean synth_crop_real = true; // crop synthetic by real public boolean synth_crop_real = true; // crop synthetic by real
public String synth_scene_offs = "-0-0-640-512-SCENE_OFFSETS.tiff";
public boolean synth_add_offs = true; // crop synthetic by real
// public String ter_rendered_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/essential/1697877491_613999-terrain_vegetation_render.tiff"; // public String ter_rendered_path = "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/debug/vegetation/essential/1697877491_613999-terrain_vegetation_render.tiff";
...@@ -2491,9 +2493,11 @@ min_str_neib_fpn 0.35 ...@@ -2491,9 +2493,11 @@ min_str_neib_fpn 0.35
gd.addStringField ("Synthesis directory", synth_directory, 120, "Directory with the terrain/foliage model generation files."); gd.addStringField ("Synthesis directory", synth_directory, 120, "Directory with the terrain/foliage model generation files.");
gd.addStringField ("Scene name", synth_scene, 40, "Name (timestamp) of the model."); gd.addStringField ("Scene name", synth_scene, 40, "Name (timestamp) of the model.");
gd.addStringField ("Model suffix", synth_model, 120, "File name suffix for the model."); gd.addStringField ("Model suffix", synth_model, 120, "File name suffix for the model.");
// gd.addStringField ("Source suffix", synth_source, 120, "File name suffix for the camera images, warps and scales."); gd.addStringField ("Vegetation segments", synth_segments, 120, "File name suffix for partial terrain/vegetation segments.");
gd.addStringField ("Rendered suffix", synth_render, 120, "Result file name suffix for the rendered synthetic images."); gd.addStringField ("Rendered suffix", synth_render, 120, "Result file name suffix for the rendered synthetic images.");
gd.addCheckbox ("Crop by real", synth_crop_real, "Crop synthetic by real."); gd.addCheckbox ("Crop by real", synth_crop_real, "Crop synthetic by real.");
gd.addStringField ("Scene offsets", synth_scene_offs,120, "Filenam suffix with scene offsets.");
gd.addCheckbox ("Add scene offsets", synth_add_offs, "Add scene offsets (vignetting corrcetion).");
} }
public void dialogAnswers(GenericJTabbedDialog gd) { public void dialogAnswers(GenericJTabbedDialog gd) {
...@@ -3349,9 +3353,11 @@ min_str_neib_fpn 0.35 ...@@ -3349,9 +3353,11 @@ min_str_neib_fpn 0.35
synth_directory = gd.getNextString(); // String synth_directory = gd.getNextString(); // String
synth_scene = gd.getNextString(); // String synth_scene = gd.getNextString(); // String
synth_model = gd.getNextString(); // String synth_model = gd.getNextString(); // String
// synth_source = gd.getNextString(); // String synth_segments = gd.getNextString(); // String
synth_render = gd.getNextString(); // String synth_render = gd.getNextString(); // String
synth_crop_real = gd.getNextBoolean();// boolean synth_crop_real = gd.getNextBoolean();// boolean
synth_scene_offs = gd.getNextString(); // String
synth_add_offs = gd.getNextBoolean();// boolean
if (this.weight_zero_neibs > 1.0) this.weight_zero_neibs = 1.0; if (this.weight_zero_neibs > 1.0) this.weight_zero_neibs = 1.0;
} }
...@@ -4191,9 +4197,11 @@ min_str_neib_fpn 0.35 ...@@ -4191,9 +4197,11 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"synth_directory", synth_directory+""); // String properties.setProperty(prefix+"synth_directory", synth_directory+""); // String
properties.setProperty(prefix+"synth_scene", synth_scene+""); // String properties.setProperty(prefix+"synth_scene", synth_scene+""); // String
properties.setProperty(prefix+"synth_model", synth_model+""); // String properties.setProperty(prefix+"synth_model", synth_model+""); // String
// properties.setProperty(prefix+"synth_source", synth_source+""); // String properties.setProperty(prefix+"synth_segments", synth_segments+""); // String
properties.setProperty(prefix+"synth_render", synth_render+""); // String properties.setProperty(prefix+"synth_render", synth_render+""); // String
properties.setProperty(prefix+"synth_crop_real", synth_crop_real+""); // boolean properties.setProperty(prefix+"synth_crop_real", synth_crop_real+""); // boolean
properties.setProperty(prefix+"synth_scene_offs", synth_scene_offs+""); // String
properties.setProperty(prefix+"synth_add_offs", synth_add_offs+""); // boolean
} }
public void getProperties(String prefix,Properties properties){ public void getProperties(String prefix,Properties properties){
...@@ -5048,9 +5056,11 @@ min_str_neib_fpn 0.35 ...@@ -5048,9 +5056,11 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"synth_directory")!= null) synth_directory=(String) properties.getProperty(prefix+"synth_directory"); if (properties.getProperty(prefix+"synth_directory")!= null) synth_directory=(String) properties.getProperty(prefix+"synth_directory");
if (properties.getProperty(prefix+"synth_scene")!= null) synth_scene=(String) properties.getProperty(prefix+"synth_scene"); if (properties.getProperty(prefix+"synth_scene")!= null) synth_scene=(String) properties.getProperty(prefix+"synth_scene");
if (properties.getProperty(prefix+"synth_model")!= null) synth_model=(String) properties.getProperty(prefix+"synth_model"); if (properties.getProperty(prefix+"synth_model")!= null) synth_model=(String) properties.getProperty(prefix+"synth_model");
// if (properties.getProperty(prefix+"synth_source")!= null) synth_source=(String) properties.getProperty(prefix+"synth_source"); if (properties.getProperty(prefix+"synth_segments")!= null) synth_segments=(String) properties.getProperty(prefix+"synth_segments");
if (properties.getProperty(prefix+"synth_render")!= null) synth_render=(String) properties.getProperty(prefix+"synth_render"); if (properties.getProperty(prefix+"synth_render")!= null) synth_render=(String) properties.getProperty(prefix+"synth_render");
if (properties.getProperty(prefix+"synth_crop_real")!= null) synth_crop_real=Boolean.parseBoolean(properties.getProperty(prefix+"synth_crop_real")); if (properties.getProperty(prefix+"synth_crop_real")!= null) synth_crop_real=Boolean.parseBoolean(properties.getProperty(prefix+"synth_crop_real"));
if (properties.getProperty(prefix+"synth_scene_offs")!= null) synth_scene_offs=(String) properties.getProperty(prefix+"synth_scene_offs");
if (properties.getProperty(prefix+"synth_add_offs")!= null) synth_add_offs=Boolean.parseBoolean(properties.getProperty(prefix+"synth_add_offs"));
} }
@Override @Override
...@@ -5861,9 +5871,11 @@ min_str_neib_fpn 0.35 ...@@ -5861,9 +5871,11 @@ min_str_neib_fpn 0.35
imp.synth_directory = this.synth_directory; imp.synth_directory = this.synth_directory;
imp.synth_scene = this.synth_scene; imp.synth_scene = this.synth_scene;
imp.synth_model = this.synth_model; imp.synth_model = this.synth_model;
// imp.synth_source = this.synth_source; imp.synth_segments = this.synth_segments;
imp.synth_render = this.synth_render; imp.synth_render = this.synth_render;
imp.synth_crop_real = this.synth_crop_real; imp.synth_crop_real = this.synth_crop_real;
imp.synth_scene_offs = this.synth_scene_offs;
imp.synth_add_offs = this.synth_add_offs;
return imp; return imp;
} }
public static long getLongColor(Color color) { public static long getLongColor(Color color) {
......
...@@ -6456,8 +6456,15 @@ public class VegetationLMA { ...@@ -6456,8 +6456,15 @@ public class VegetationLMA {
for (int t = 0; t < SAVE_TYPES.length; t++) { for (int t = 0; t < SAVE_TYPES.length; t++) {
int n = SAVE_TYPES[t]; int n = SAVE_TYPES[t];
if (n ==TVAO_SCENE_OFFSET) {
tvao_data[n] = new double [num_scenes];
if ( data[t] != null) {
System.arraycopy(data[t], 0, tvao_data[n],0, num_scenes);
}
} else {
tvao_data[n] = data[t]; tvao_data[n] = data[t];
} }
}
for (int n = 0; n < tvao_data.length; n++) { for (int n = 0; n < tvao_data.length; n++) {
if (tvao_data[n] == null) { if (tvao_data[n] == null) {
tvao_data[n] = new double [width*height]; tvao_data[n] = new double [width*height];
...@@ -6735,7 +6742,7 @@ public class VegetationLMA { ...@@ -6735,7 +6742,7 @@ public class VegetationLMA {
terrain_offset, // terrain_offset, terrain_offset, // terrain_offset,
tvao[TVAO_SCENE_OFFSET], // double [] scene_offsets, tvao[TVAO_SCENE_OFFSET], // double [] scene_offsets,
// terrain, vegetation, alpha, elevation, terrain_elevation // terrain, vegetation, alpha, elevation, terrain_elevation
new double [][] {tvao[0],tvao[1],tvao[2],tvao[3],tvao[5]}, // double [][] tva) {} {} new double [][] {tvao[0],tvao[1],tvao[2],tvao[3],tvao[5]}, // double [][] tva) {} {} // skipping common terrain elevation
confidence, // double [] confidence confidence, // double [] confidence
has_vegetation); //boolean [] overlaid) has_vegetation); //boolean [] overlaid)
if (debugLevel>-2) { if (debugLevel>-2) {
......
...@@ -2,6 +2,7 @@ package com.elphel.imagej.vegetation; ...@@ -2,6 +2,7 @@ package com.elphel.imagej.vegetation;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
...@@ -2068,7 +2069,46 @@ public class VegetationModel { ...@@ -2068,7 +2069,46 @@ public class VegetationModel {
if (run_combine) { if (run_combine) {
VegetationSegment [] segments = vegetationLMA.readAllSegments( String synth_directory = clt_parameters.imp.synth_directory; // "/media/elphel/SSD3-4GB/lwir16-proc/berdich3/restore_foliage/01/";
if (!synth_directory.endsWith(Prefs.getFileSeparator())) {
synth_directory+=Prefs.getFileSeparator();
}
String synth_segments = clt_parameters.imp.synth_segments; // ".vegetation-segments"; // serialized: number of models, array of models
String synth_scene = clt_parameters.imp.synth_scene;
String segments_path = synth_directory + synth_scene + synth_segments;
// try to read segments from the serialized file (to force recalculation - just remove it)
VegetationSegment [] segments = null;
try {
segments = VegetationSegment.readVegetationSegments (
segments_path);
System.out.println("processVegetationLMA(): read serialized segment data from "+(segments.length)+" segments to "+segments_path);
System.out.println("To rebuild the segments - just remove "+segments_path+" and re-run the program");
} catch (ClassNotFoundException | IOException e1) {
System.out.println("processVegetationLMA(): failed to read segments data from "+segments_path+", will rebuild it.");
} // String path)
//fixing wrong scene_offsets
boolean fixed_scene_offsets= false;
int num_scenes = getSceneNames().length;
for (VegetationSegment segment:segments) {
if (segment.scene_offsets.length > num_scenes) {
double [] s_o = new double [num_scenes];
System.arraycopy(segment.scene_offsets, 0, s_o, 0, num_scenes);
segment.scene_offsets = s_o;
fixed_scene_offsets = true;
}
}
if (fixed_scene_offsets) {
try {
VegetationSegment.writeVegetationSegments(
segments_path, // String path,
segments);
System.out.println("processVegetationLMA(): Saved fixed scene_offsets serialized data for "+(segments.length)+" segments to "+segments_path);
} catch (IOException e) {
System.out.println("processVegetationLMA(): failed to save fixed scene_offsets segments data to "+segments_path);
} // VegetationSegment [] segments) throws IOException {
}
if (segments == null) {
segments = vegetationLMA.readAllSegments(
segments_dir, // String dir_path) segments_dir, // String dir_path)
segments_suffix, // String suffix); segments_suffix, // String suffix);
transparency_opaque, // double transparency_opaque, transparency_opaque, // double transparency_opaque,
...@@ -2081,11 +2121,25 @@ public class VegetationModel { ...@@ -2081,11 +2121,25 @@ public class VegetationModel {
debug_path, // String debug_path, debug_path, // String debug_path,
debug_save_improved, // boolean debug_save_improved, // Save debug image after successful LMA step."); debug_save_improved, // boolean debug_save_improved, // Save debug image after successful LMA step.");
debug_save_worsened); // boolean debug_save_worsened) { // Save debug image after unsuccessful LMA step."); debug_save_worsened); // boolean debug_save_worsened) { // Save debug image after unsuccessful LMA step.");
// String segments_path = model_directory+reference_scene+"-foliage_model.foliage-model";
try {
VegetationSegment.writeVegetationSegments(
segments_path, // String path,
segments);
System.out.println("processVegetationLMA(): Saved serialized data for "+(segments.length)+" segments to "+segments_path);
} catch (IOException e) {
System.out.println("processVegetationLMA(): failed to save segments data to "+segments_path);
} // VegetationSegment [] segments) throws IOException {
}
if (keep_partial) { // may require too much memory
VegetationSegment.combineSegments( VegetationSegment.combineSegments(
vegetationLMA, // VegetationLMA vegetationLMA, vegetationLMA, // VegetationLMA vegetationLMA,
segments, segments,
crop_combo, // boolean crop_combo, crop_combo, // boolean crop_combo,
keep_partial, // boolean keep_partial, true, // boolean keep_partial,
border_width, // int width); border_width, // int width);
um_sigma, // final double um_sigma, um_sigma, // final double um_sigma,
um_weight, //final double um_weight, um_weight, //final double um_weight,
...@@ -2097,6 +2151,35 @@ public class VegetationModel { ...@@ -2097,6 +2151,35 @@ public class VegetationModel {
boost_parallax_render, // double boost_parallax) { // increase weights of scenes with high parallax relative to the reference one boost_parallax_render, // double boost_parallax) { // increase weights of scenes with high parallax relative to the reference one
max_parallax_render, // final double max_parallax, max_parallax_render, // final double max_parallax,
num_exaggerate); // final int num_exaggerate) { // show amplified difference from filtering num_exaggerate); // final int num_exaggerate) { // show amplified difference from filtering
} else {
VegetationSegment.combineSegments(
vegetationLMA, // VegetationLMA vegetationLMA,
segments,
crop_combo, // boolean crop_combo,
// keep_partial, // boolean keep_partial,
border_width, // int width);
um_sigma, // final double um_sigma,
um_weight, //final double um_weight,
render_open, // boolean render_open, // render open areas (no vegetation offset)
render_no_alpha, // boolean render_no_alpha, // render where no opacity is available
alpha_min, // double alpha_min, // below - completely transparent vegetation
alpha_max, // double alpha_max, // above - completely opaque
weight_opaque, // double weight_opaque, // render through completely opaque vegetation
boost_parallax_render, // double boost_parallax) { // increase weights of scenes with high parallax relative to the reference one
max_parallax_render, // final double max_parallax,
num_exaggerate); // final int num_exaggerate) { // show amplified difference from filtering
}
ImagePlus imp_scene_offsets = VegetationSegment.combineSegmentsSceneOffsets(
vegetationLMA, // VegetationLMA vegetationLMA,
segments, // VegetationSegment [] segments,
crop_combo, // boolean crop_combo,
border_width, // int width);
num_scenes); // final int num_scenes
if (imp_scene_offsets != null) {
imp_scene_offsets.show();
}
return; return;
} }
Rectangle woi = woi_last_done; Rectangle woi = woi_last_done;
......
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