Commit 12d3c947 authored by Andrey Filippov's avatar Andrey Filippov

Cleaned up/implemented generation of the scene stats and combo images

parent 640b8df3
...@@ -148,11 +148,12 @@ public class ComboMatch { ...@@ -148,11 +148,12 @@ public class ComboMatch {
int gpu_width= clt_parameters.imp.rln_gpu_width; // 3008; int gpu_width= clt_parameters.imp.rln_gpu_width; // 3008;
int gpu_height= clt_parameters.imp.rln_gpu_height; // 3008; int gpu_height= clt_parameters.imp.rln_gpu_height; // 3008;
int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice int zoom_lev = -3; // 0; // +1 - zoom in twice, -1 - zoom out twice
boolean show_map_stats = false; // boolean show_map_stats = false;
boolean show_combo_map = false; // true; boolean show_combo = false; // true;
boolean show_combo_mask = false; // generate image mas (where it is defined)_
boolean use_alt = false; // boolean show_combo_mask = false; // generate image mas (where it is defined)_
boolean show_centers = true; // boolean use_alt = false;
// boolean show_centers = true;
boolean use_saved_collection = true; // false; boolean use_saved_collection = true; // false;
boolean save_collection = true; boolean save_collection = true;
boolean process_correlation = true; // use false to save new version of data boolean process_correlation = true; // use false to save new version of data
...@@ -212,11 +213,11 @@ public class ComboMatch { ...@@ -212,11 +213,11 @@ public class ComboMatch {
"GPU image width"); "GPU image width");
gd.addNumericField("GPU image height", gpu_height, 0,4,"", gd.addNumericField("GPU image height", gpu_height, 0,4,"",
"GPU image height"); "GPU image height");
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 ("Show statistics for ortho images", show_map_stats, "Generate and show statistics for ortho maps."); // gd.addCheckbox ("Show statistics for ortho images", show_map_stats, "Generate and show statistics for ortho maps.");
gd.addCheckbox ("Show combo image map", show_combo_map, "Load and process altitude maps."); gd.addCheckbox ("Show combo maps/stats", show_combo, "Generate/save combo maps and stats.");
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.");
gd.addNumericField("Maximal metric error", metric_error, 3,7,"m", "Maximal tolerable fitting error caused by elevation variations."); gd.addNumericField("Maximal metric error", metric_error, 3,7,"m", "Maximal tolerable fitting error caused by elevation variations.");
if (use_marked_image ) { if (use_marked_image ) {
...@@ -257,11 +258,11 @@ public class ComboMatch { ...@@ -257,11 +258,11 @@ public class ComboMatch {
OrthoMap.setGPUWidthHeight(gpu_width,gpu_height); OrthoMap.setGPUWidthHeight(gpu_width,gpu_height);
show_centers = gd.getNextBoolean(); // show_centers = gd.getNextBoolean();
show_map_stats = gd.getNextBoolean(); // show_map_stats = gd.getNextBoolean();
show_combo_map = gd.getNextBoolean(); show_combo = gd.getNextBoolean();
show_combo_mask = gd.getNextBoolean(); // show_combo_mask = gd.getNextBoolean();
use_alt = gd.getNextBoolean(); // use_alt = gd.getNextBoolean();
// gpu_spair[0] = gd.getNextString(); // gpu_spair[0] = gd.getNextString();
// gpu_spair[1] = gd.getNextString(); // gpu_spair[1] = gd.getNextString();
...@@ -741,48 +742,9 @@ public class ComboMatch { ...@@ -741,48 +742,9 @@ public class ComboMatch {
// which pair to compare // which pair to compare
// String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]}; // String [] gpu_spair = {names[gpu_ipair[0]],names[gpu_ipair[1]]};
int [] origin = new int[2]; int [] origin = new int[2];
ImagePlus imp_img = null; if (show_combo) { // now all modes, and stats?
if (show_map_stats) { maps_collection.processComboMap(debugLevel);
boolean ok = maps_collection.showScenesStats(false); // boolean select_all) return true;
if (!ok) {
return false;
}
// System.out.println("Exiting after generating stats");
// return true; // do not process anything else
}
if (show_combo_map) {
imp_img = maps_collection.renderMulti (
"multi_zoom"+zoom_lev, // String title,
OrthoMapsCollection.MODE_IMAGE, // int mode, // 0 - regular image, 1 - altitudes, 2 - black/white mask // boolean use_alt,
show_centers, // boolean show_centers,
zoom_lev, // int zoom_level,
temp_mode, // int temp_mode, // 0 - do nothing, 1 - equalize average,2 - try to correct
origin); // int [] origin){
imp_img.show();
}
ImagePlus imp_alt = null;
if (use_alt) {
imp_alt =maps_collection.renderMulti (
"multi_alt_zoom"+zoom_lev, // String title,
// true, // boolean use_alt,
OrthoMapsCollection.MODE_ALT, // int mode, // 0 - regular image, 1 - altitudes, 2 - black/white mask // boolean use_alt,
show_centers, // boolean show_centers,
zoom_lev, // int zoom_level,
0, // int temp_mode, // 0 - do nothing, 1 - equalize average,2 - try to correct
origin); // int [] origin){
imp_alt.show();
}
if (show_combo_mask) {
imp_alt =maps_collection.renderMulti (
"multi_alt_zoom"+zoom_lev, // String title,
// true, // boolean use_alt,
OrthoMapsCollection.MODE_MASK, // int mode, // 0 - regular image, 1 - altitudes, 2 - black/white mask // boolean use_alt,
show_centers, // boolean show_centers,
zoom_lev, // int zoom_level,
0, // int temp_mode, // 0 - do nothing, 1 - equalize average,2 - try to correct
origin); // int [] origin){
imp_alt.show();
} }
if (process_correlation || render_match || pattern_match) { if (process_correlation || render_match || pattern_match) {
// int [] gpu_pair; // int [] gpu_pair;
...@@ -953,8 +915,6 @@ public class ComboMatch { ...@@ -953,8 +915,6 @@ public class ComboMatch {
} }
} }
if (pattern_match) { if (pattern_match) {
ImagePlus imp_pat_match = maps_collection.patternMatchDualWrap ( ImagePlus imp_pat_match = maps_collection.patternMatchDualWrap (
gpu_pair, // int [] indices, // null or which indices to use (normally just 2 for pairwise comparison) gpu_pair, // int [] indices, // null or which indices to use (normally just 2 for pairwise comparison)
...@@ -974,7 +934,7 @@ public class ComboMatch { ...@@ -974,7 +934,7 @@ public class ComboMatch {
temp_mode, // int temp_mode, // 0 - do nothing, 1 - equalize average,2 - try to correct temp_mode, // int temp_mode, // 0 - do nothing, 1 - equalize average,2 - try to correct
affines, // double [][][] affines, // null or [indices.length][2][3] affines, // double [][][] affines, // null or [indices.length][2][3]
warp, // FineXYCorr warp, warp, // FineXYCorr warp,
show_centers, // boolean show_centers, true, // show_centers, // boolean show_centers,
min_zoom_lev, // int zoom_level, min_zoom_lev, // int zoom_level,
origin); // int [] origin){ origin); // int [] origin){
imp_img_pair.show(); imp_img_pair.show();
......
...@@ -200,6 +200,16 @@ public class ItemMatch { ...@@ -200,6 +200,16 @@ public class ItemMatch {
return match.getMatch(indx); return match.getMatch(indx);
} }
public double getMatchBestValue(String pattern_path) {
ItemPatternMatch match = pattern_matches.get(pattern_path);
if (match == null) {
System.out.println("No matches found for pattern "+pattern_path);
return Double.NaN;
}
return match.getBestMatchValue();
}
/** /**
...@@ -212,6 +222,17 @@ public class ItemMatch { ...@@ -212,6 +222,17 @@ public class ItemMatch {
return getMatchValue(groundObjectPattern.getPatternPath()); return getMatchValue(groundObjectPattern.getPatternPath());
} }
/**
* Return actual best correlation value regardless of where best subpattern index
* points to - it may be forced to point to the full pattern by absolute contrast
* @param groundObjectPattern
* @return maximal correlation value amoong the full pattern and all half-patterns.
*/
public double getMatchBestValue(GroundObjectPattern groundObjectPattern) {
return getMatchBestValue(groundObjectPattern.getPatternPath());
}
public double getMatchValue(String pattern_path) { public double getMatchValue(String pattern_path) {
int indx = getPatternMatch(pattern_path).getBestSub(); // -1; int indx = getPatternMatch(pattern_path).getBestSub(); // -1;
...@@ -231,6 +252,7 @@ public class ItemMatch { ...@@ -231,6 +252,7 @@ public class ItemMatch {
int indx){ int indx){
String pattern_path = groundObjectPattern.getPatternPath(); String pattern_path = groundObjectPattern.getPatternPath();
return sortByMatch(match_list, pattern_path, keep_removed, indx); return sortByMatch(match_list, pattern_path, keep_removed, indx);
} }
public static ArrayList<Integer> sortByMatch( public static ArrayList<Integer> sortByMatch(
...@@ -238,6 +260,9 @@ public class ItemMatch { ...@@ -238,6 +260,9 @@ public class ItemMatch {
String pattern_path, String pattern_path,
boolean keep_removed, boolean keep_removed,
int indx){ int indx){
if (indx < 0) {
return sortByBestMatch (match_list, pattern_path, keep_removed);
}
double large_enough = 1.0; double large_enough = 1.0;
ArrayList<Integer> result_list= new ArrayList<Integer>(match_list.size()); ArrayList<Integer> result_list= new ArrayList<Integer>(match_list.size());
for (int i = 0; i < match_list.size(); i++) { for (int i = 0; i < match_list.size(); i++) {
...@@ -258,6 +283,32 @@ public class ItemMatch { ...@@ -258,6 +283,32 @@ public class ItemMatch {
return result_list; return result_list;
} }
public static ArrayList<Integer> sortByBestMatch(
ArrayList<ItemMatch> match_list,
String pattern_path,
boolean keep_removed){
double large_enough = 1.0;
ArrayList<Integer> result_list= new ArrayList<Integer>(match_list.size());
for (int i = 0; i < match_list.size(); i++) {
if (keep_removed || !match_list.get(i).isRemoved()) {
result_list.add(i);
}
}
Collections.sort(result_list, new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
ItemMatch rhsm = match_list.get(rhs);
ItemMatch lhsm = match_list.get(lhs);
double rhsd = rhsm.getMatchBestValue(pattern_path) - (rhsm.isRemoved() ? large_enough:0 );
double lhsd = lhsm.getMatchBestValue(pattern_path) - (lhsm.isRemoved() ? large_enough:0 );
return (rhsd > lhsd) ? 1 : (rhsd < lhsd) ? -1 : 0; // decreasing
}
});
return result_list;
}
public static void setExtractedObjects( public static void setExtractedObjects(
int scene_num, int scene_num,
int extr_size, int extr_size,
......
...@@ -41,6 +41,25 @@ public class ItemPatternMatch { ...@@ -41,6 +41,25 @@ public class ItemPatternMatch {
} }
return sub_matches[indx]; return sub_matches[indx];
} }
/**
* Return actual largest value of full and all half patterns, regardless of best_sub which can point
* to full pattern even if the correlation value is larger for partial
* @return
*/
public double getBestMatchValue() { //
if (sub_matches == null) {
return Double.NaN;
}
double best = 0;
for (int i = 1; i < sub_matches.length; i++) {
if (sub_matches[i] > best) {
best = sub_matches[i];
}
}
return best;
}
public double [] getMatches() { public double [] getMatches() {
return sub_matches; return sub_matches;
......
...@@ -2165,7 +2165,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{ ...@@ -2165,7 +2165,7 @@ public class OrthoMap implements Comparable <OrthoMap>, Serializable{
} }
} }
double threshold = obscure_frac * avg[0] + (1.0 - obscure_frac) * avg[1]; double threshold = (1.0 - obscure_frac) * avg[0] + obscure_frac * avg[1];
double over_thresh = (avg[0] < avg[1]) ? (zone3_min_max[0] - threshold) : (threshold - zone3_min_max[1]); double over_thresh = (avg[0] < avg[1]) ? (zone3_min_max[0] - threshold) : (threshold - zone3_min_max[1]);
......
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