Commit 75c570c2 authored by Andrey Filippov's avatar Andrey Filippov

Tested LMA equalization, some bug fixes

parent f7f4a8dd
...@@ -159,6 +159,8 @@ public class ComboMatch { ...@@ -159,6 +159,8 @@ public class ComboMatch {
boolean create_overlaps = false; boolean create_overlaps = false;
boolean equalize_overlaps = false; boolean equalize_overlaps = false;
boolean create_map = false; boolean create_map = false;
boolean create_equalize = false;
// boolean show_combo_mask = false; // generate image mas (where it is defined)_ // boolean show_combo_mask = false; // generate image mas (where it is defined)_
// boolean use_alt = false; // boolean use_alt = false;
// boolean show_centers = true; // boolean show_centers = true;
...@@ -194,7 +196,7 @@ public class ComboMatch { ...@@ -194,7 +196,7 @@ public class ComboMatch {
} }
GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,700); GenericJTabbedDialog gd = new GenericJTabbedDialog("Set image pair",1200,800);
gd.addChoice ("Files list/data path (w/o extension):", files_lists_paths, files_lists_paths[default_list_choice]); gd.addChoice ("Files list/data path (w/o extension):", files_lists_paths, files_lists_paths[default_list_choice]);
gd.addCheckbox ("Use saved maps collection", use_saved_collection, "If false - use files list."); gd.addCheckbox ("Use saved maps collection", use_saved_collection, "If false - use files list.");
gd.addCheckbox ("Save maps collection", save_collection, "Save maps collection to be able to restore."); gd.addCheckbox ("Save maps collection", save_collection, "Save maps collection to be able to restore.");
...@@ -235,6 +237,7 @@ public class ComboMatch { ...@@ -235,6 +237,7 @@ public class ComboMatch {
gd.addCheckbox ("Create overlap pairs", create_overlaps, "Create scene pairs overlaps."); gd.addCheckbox ("Create overlap pairs", create_overlaps, "Create scene pairs overlaps.");
gd.addCheckbox ("Equalize overlap pairs", equalize_overlaps, "Equalize intensities in overlaps."); gd.addCheckbox ("Equalize overlap pairs", equalize_overlaps, "Equalize intensities in overlaps.");
gd.addCheckbox ("Create map", create_map, "Create combined map from pairwise matches."); gd.addCheckbox ("Create map", create_map, "Create combined map from pairwise matches.");
gd.addCheckbox ("Equalize intensities", create_equalize, "Create map intensities equalization from pairwise matches.");
// gd.addCheckbox ("Show combo image mask", show_combo_mask, "Display combo binary image."); // gd.addCheckbox ("Show combo image mask", show_combo_mask, "Display combo binary image.");
// gd.addCheckbox ("Show altitude combo image", use_alt, "Load and process altitude maps."); // gd.addCheckbox ("Show altitude combo image", use_alt, "Load and process altitude maps.");
gd.addNumericField("Remove fraction of worst matches", frac_remove, 3,7,"", "When fitting scenes remove this fraction of worst match."); gd.addNumericField("Remove fraction of worst matches", frac_remove, 3,7,"", "When fitting scenes remove this fraction of worst match.");
...@@ -263,6 +266,7 @@ public class ComboMatch { ...@@ -263,6 +266,7 @@ public class ComboMatch {
String orthoMapsCollection_path =files_lists_paths[choice_index]+".data"; String orthoMapsCollection_path =files_lists_paths[choice_index]+".data";
use_saved_collection = gd.getNextBoolean(); use_saved_collection = gd.getNextBoolean();
save_collection = gd.getNextBoolean(); save_collection = gd.getNextBoolean();
String orthoMapsCollection_savepath = save_collection?orthoMapsCollection_path:null;
process_correlation= gd.getNextBoolean(); process_correlation= gd.getNextBoolean();
num_tries_fit = (int) gd.getNextNumber(); num_tries_fit = (int) gd.getNextNumber();
update_match= gd.getNextBoolean(); update_match= gd.getNextBoolean();
...@@ -292,6 +296,7 @@ public class ComboMatch { ...@@ -292,6 +296,7 @@ public class ComboMatch {
create_overlaps = gd.getNextBoolean(); create_overlaps = gd.getNextBoolean();
equalize_overlaps = gd.getNextBoolean(); equalize_overlaps = gd.getNextBoolean();
create_map = gd.getNextBoolean(); create_map = gd.getNextBoolean();
create_equalize = gd.getNextBoolean();
frac_remove = gd.getNextNumber(); frac_remove = gd.getNextNumber();
metric_error= gd.getNextNumber(); metric_error= gd.getNextNumber();
if (use_marked_image ) { // will only be used if found and asked if (use_marked_image ) { // will only be used if found and asked
...@@ -778,20 +783,28 @@ public class ComboMatch { ...@@ -778,20 +783,28 @@ public class ComboMatch {
OrthoMultiLMA.buildOrthoMap( OrthoMultiLMA.buildOrthoMap(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
maps_collection, // OrthoMapsCollection maps_collection maps_collection, // OrthoMapsCollection maps_collection
orthoMapsCollection_path); // String orthoMapsCollection_path orthoMapsCollection_savepath); // String orthoMapsCollection_path
return true; return true;
} }
if (create_equalize) {
OrthoEqualizeLMA.buildEqualize(
clt_parameters, // CLTParameters clt_parameters,
maps_collection, // OrthoMapsCollection maps_collection
orthoMapsCollection_savepath); // String orthoMapsCollection_path
return true;
}
if (create_overlaps) { if (create_overlaps) {
boolean ok =maps_collection.getIntersectedPairs( boolean ok =maps_collection.getIntersectedPairs(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
orthoMapsCollection_path); // String orthoMapsCollection_path); orthoMapsCollection_savepath); // String orthoMapsCollection_path);
return ok; // Just exit, do not try other commands. if (!ok) return false; return ok; // Just exit, do not try other commands. if (!ok) return false;
} }
if (equalize_overlaps) { if (equalize_overlaps) {
boolean ok =maps_collection.equalizeIntersectedPairs( boolean ok =maps_collection.equalizeIntersectedPairs(
clt_parameters, // CLTParameters clt_parameters, clt_parameters, // CLTParameters clt_parameters,
orthoMapsCollection_path); // String orthoMapsCollection_path); orthoMapsCollection_savepath); // String orthoMapsCollection_path);
return ok; // Just exit, do not try other commands. if (!ok) return false; return ok; // Just exit, do not try other commands. if (!ok) return false;
} }
......
...@@ -117,6 +117,9 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -117,6 +117,9 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
public transient double sfm_gain = Double.NaN; // maximal SfM gain of this map public transient double sfm_gain = Double.NaN; // maximal SfM gain of this map
public transient double [] equalize = {1,0}; // rectified value = equalize[0]*source_value+equalize[1] public transient double [] equalize = {1,0}; // rectified value = equalize[0]*source_value+equalize[1]
private void writeObject(ObjectOutputStream oos) throws IOException { private void writeObject(ObjectOutputStream oos) throws IOException {
// temporary fix:
// double [][] affine_clone = {affine[0].clone(), affine[1].clone()};
// affine = affine_clone;
oos.defaultWriteObject(); oos.defaultWriteObject();
oos.writeObject(path); oos.writeObject(path);
// oos.writeObject(scenes_path); // oos.writeObject(scenes_path);
...@@ -511,7 +514,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -511,7 +514,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
} }
public void setAffine(double [][] affine) { public void setAffine(double [][] affine) {
this.affine = affine; this.affine = new double[][] {affine[0].clone(),affine[1].clone()};
} }
public double [][] getAffine(){ public double [][] getAffine(){
return affine; return affine;
......
...@@ -4893,7 +4893,7 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -4893,7 +4893,7 @@ public class OrthoMapsCollection implements Serializable{
int debugLevel) { int debugLevel) {
int [] indices = getScenesSelection( int [] indices = getScenesSelection(
null, // boolean select_all, null, // boolean select_all,
" to process"); // String purpose) " to process/display"); // String purpose)
if (indices == null) { if (indices == null) {
return false; return false;
} }
...@@ -4907,7 +4907,7 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -4907,7 +4907,7 @@ public class OrthoMapsCollection implements Serializable{
int [] indices, int [] indices,
int debugLevel) { int debugLevel) {
boolean show_map_stats = false; boolean show_map_stats = false;
boolean show_combo_map = false; // true; boolean show_combo_map = true; // false; // true;
boolean show_alt_map = false; boolean show_alt_map = false;
boolean show_combo_mask = false; // generate image mas (where it is defined) boolean show_combo_mask = false; // generate image mas (where it is defined)
boolean show_frames = false; boolean show_frames = false;
...@@ -4920,6 +4920,8 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -4920,6 +4920,8 @@ public class OrthoMapsCollection implements Serializable{
boolean show_centers = true; boolean show_centers = true;
boolean bounds_to_indices = true; boolean bounds_to_indices = true;
boolean merge_layers = false; // instead of individuals boolean merge_layers = false; // instead of individuals
boolean ignore_affines = false;
boolean ignore_equalize = false;
String save_top_dir = "/media/elphel/NVME/lwir16-proc/ortho_videos/debug/sept12-13/pattern_match/"; String save_top_dir = "/media/elphel/NVME/lwir16-proc/ortho_videos/debug/sept12-13/pattern_match/";
String sub_dir = "combo_maps"; String sub_dir = "combo_maps";
...@@ -4942,10 +4944,15 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -4942,10 +4944,15 @@ public class OrthoMapsCollection implements Serializable{
gd.addNumericField("Margins", margins, 0,4,"", gd.addNumericField("Margins", margins, 0,4,"",
"Add margins around images"); "Add margins around images");
gd.addCheckbox ("Show transformation centers", show_centers, "Mark verticals from the UAS on the ground."); gd.addCheckbox ("Show transformation centers",show_centers, "Mark verticals from the UAS on the ground.");
gd.addCheckbox ("Bounds to selected images", bounds_to_indices, "Set combo image bounds to selected images only. False - all images."); gd.addCheckbox ("Bounds to selected images", bounds_to_indices, "Set combo image bounds to selected images only. False - all images.");
gd.addCheckbox ("Merge layers", merge_layers, "Generate composite binary image."); gd.addCheckbox ("Merge layers", merge_layers, "Generate composite binary image.");
gd.addCheckbox ("Ignore affines", ignore_affines, "Ignore available affines, use unity.");
gd.addCheckbox ("Ignore equalization", ignore_equalize, "Ignore available intensity equalization, use unity.");
gd.addStringField ("Pattern match save directory", save_top_dir, 120, "Top directory to save combo maps"); gd.addStringField ("Pattern match save directory", save_top_dir, 120, "Top directory to save combo maps");
gd.addStringField ("Save subdirectory", sub_dir, 80, "Subdirectory for versions of the same scene/pair of scenes"); gd.addStringField ("Save subdirectory", sub_dir, 80, "Subdirectory for versions of the same scene/pair of scenes");
gd.addCheckbox ("Show generated images", show_images, "Display generated images."); gd.addCheckbox ("Show generated images", show_images, "Display generated images.");
...@@ -4968,7 +4975,8 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -4968,7 +4975,8 @@ public class OrthoMapsCollection implements Serializable{
show_centers = gd.getNextBoolean(); show_centers = gd.getNextBoolean();
bounds_to_indices = gd.getNextBoolean(); bounds_to_indices = gd.getNextBoolean();
merge_layers = gd.getNextBoolean(); merge_layers = gd.getNextBoolean();
ignore_affines = gd.getNextBoolean();
ignore_equalize = gd.getNextBoolean();
save_top_dir= gd.getNextString(); save_top_dir= gd.getNextString();
sub_dir= gd.getNextString(); sub_dir= gd.getNextString();
show_images= gd.getNextBoolean(); show_images= gd.getNextBoolean();
...@@ -5015,13 +5023,22 @@ public class OrthoMapsCollection implements Serializable{ ...@@ -5015,13 +5023,22 @@ public class OrthoMapsCollection implements Serializable{
int [] wh = new int[2]; int [] wh = new int[2];
int [] origin = new int[2]; int [] origin = new int[2];
double [][] centers = show_centers? (new double [indices.length][]): null; double [][] centers = show_centers? (new double [indices.length][]): null;
double [][][] affines = null;
if (ignore_affines) {
affines = new double [indices.length][2][3];
for (int i = 0; i < indices.length; i++) {
affines[i][0][0] = 1;
affines[i][1][1] = 1;
}
}
double [][] dmulti = renderMultiDouble ( double [][] dmulti = renderMultiDouble (
null, // double [][] ground_planes, // null - images, non-null altitudes. use new double[2][3] for old way alt null, // double [][] ground_planes, // null - images, non-null altitudes. use new double[2][3] for old way alt
indices, // int [] indices, // null or which indices to use (normally just 2 for pairwise comparison) indices, // int [] indices, // null or which indices to use (normally just 2 for pairwise comparison)
bounds_to_indices, // boolean bounds_to_indices, bounds_to_indices, // boolean bounds_to_indices,
null, // affines, // double [][][] affines, // null or [indices.length][2][3] affines, // null, // affines, // double [][][] affines, // null or [indices.length][2][3]
null, // double [][] equalize, null, // double [][] equalize,
true, // boolean ignore_equalize, ignore_equalize, // true, // boolean ignore_equalize,
null, // warp, // FineXYCorr warp,, null, // warp, // FineXYCorr warp,,
zoom_lev, // int zoom_level, zoom_lev, // int zoom_level,
wh, // int [] wh, wh, // int [] wh,
......
...@@ -19,6 +19,9 @@ public class PairwiseOrthoMatch implements Serializable { ...@@ -19,6 +19,9 @@ public class PairwiseOrthoMatch implements Serializable {
public PairwiseOrthoMatch() { public PairwiseOrthoMatch() {
}
public double getOverlap() {
return overlap;
} }
public PairwiseOrthoMatch( public PairwiseOrthoMatch(
double [][] affine, double [][] affine,
......
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