Commit 6cbc4b32 authored by Andrey Filippov's avatar Andrey Filippov

tuning

parent c1e50a2a
......@@ -146,7 +146,7 @@ public class ObjectLocation {
if (rslt != null) {
return rslt;
} else {
return new double[] {Double.NaN,Double.NaN,Double.NaN,Double.NaN,Double.NaN,Double.NaN};
return new double[] {Double.NaN,Double.NaN,Double.NaN,Double.NaN,Double.NaN,Double.NaN,Double.NaN};
}
}
......
......@@ -1787,11 +1787,11 @@ public class OrthoMapsCollection implements Serializable{
// make conditional distance - decrease if small offset (increase for large to accommodate +30/-10cm
double [] filt_dist = {10.0,5.0}; // full offset and perpendicular to images offsets
double filt_height = 0.2; // allow extra negative offset parallel to image offset, corresponding to object above ground
// double [] filt_full_half_frac = {0.7, 0.5}; // second probably not needed, it is for main
double [] filt_full_half_frac = {0.675, 0.5}; // second probably not needed, it is for main
int debugLevel = 1;
GenericJTabbedDialog gd = new GenericJTabbedDialog("Correlate two images with patterns",1200,900);
GenericJTabbedDialog gd = new GenericJTabbedDialog("Correlate two images with patterns",1200,1100);
gd.addNumericField("Minimal correlation, first", min_corrs[0], 5,7,"","Minimal correlation value to keep, first scene.");
gd.addNumericField("Minimal correlation, second", min_corrs[1], 5,7,"","Minimal correlation value to keep, second scene.");
// gd.addNumericField("Maximal peak area, first", max_area[0], 5,7,"","Maximal cross-section area of the peak at certain height.");
......@@ -1830,51 +1830,55 @@ public class OrthoMapsCollection implements Serializable{
gd.addNumericField("Maximal offset", filt_dist[0], 5,7,"pix","Maximal other scene offset from the main.");
gd.addNumericField("Maximal offset perpendicular", filt_dist[1], 5,7,"pix","Maximal other scene offset perpendicular to offset between scenes.");
gd.addNumericField("Maximal object height", filt_height, 5,7,"m", "Maximal object height to allow extra offset.");
gd.addNumericField("Full/half corr minimal ratio, main",filt_full_half_frac[0], 5,7,"","Minimal correlation with full pattern strength ratio to correlation with a half-pattern.");
gd.addNumericField("Full/half corr minimal ratio, other",filt_full_half_frac[1], 5,7,"","Minimal correlation with full pattern strength ratio to correlation with a half-pattern.");
//
gd.addNumericField("Debug level", debugLevel, 0,4,"", "Debug level.");
gd.showDialog();
if (gd.wasCanceled()) return null;
min_corrs[0]= gd.getNextNumber();
min_corrs[1]= gd.getNextNumber();
min_corrs[0]= gd.getNextNumber();
min_corrs[1]= gd.getNextNumber();
// max_area[0]= gd.getNextNumber();
// max_area[1]= gd.getNextNumber();
phaseCoeff[0]= gd.getNextNumber();
phaseCoeff[1]= gd.getNextNumber();
min_corr_full_rel= gd.getNextNumber();
full_preference= gd.getNextNumber();
max_min_ratio= gd.getNextNumber();
combine_full[0] = gd.getNextBoolean();
combine_full[1] = gd.getNextBoolean();
corr_size= (int) gd.getNextNumber();
adv_radius= gd.getNextNumber();
search_radius= gd.getNextNumber();
object_type= gd.getNextString();
scale_warp = gd.getNextNumber();
extr_size= (int) gd.getNextNumber();
remove_dc= gd.getNextBoolean();
phaseCoeff[0]= gd.getNextNumber();
phaseCoeff[1]= gd.getNextNumber();
min_corr_full_rel= gd.getNextNumber();
full_preference= gd.getNextNumber();
max_min_ratio= gd.getNextNumber();
combine_full[0] = gd.getNextBoolean();
combine_full[1] = gd.getNextBoolean();
corr_size= (int) gd.getNextNumber();
adv_radius= gd.getNextNumber();
search_radius= gd.getNextNumber();
object_type= gd.getNextString();
scale_warp = gd.getNextNumber();
extr_size= (int) gd.getNextNumber();
remove_dc= gd.getNextBoolean();
filt_keep= gd.getNextBoolean();
filt_atonce= gd.getNextBoolean();
filt_frac_max= gd.getNextNumber();
filt_max_radius[0][0]= gd.getNextNumber();
filt_max_radius[0][1]= gd.getNextNumber();
filt_max_radius[1][0]= gd.getNextNumber();
filt_max_radius[1][1]= gd.getNextNumber();
filt_elongation[0][0]= gd.getNextNumber();
filt_elongation[0][1]= gd.getNextNumber();
filt_elongation[1][0]= gd.getNextNumber();
filt_elongation[1][1]= gd.getNextNumber();
filt_keep= gd.getNextBoolean();
filt_atonce= gd.getNextBoolean();
filt_frac_max= gd.getNextNumber();
filt_max_radius[0][0]=gd.getNextNumber();
filt_max_radius[0][1]=gd.getNextNumber();
filt_max_radius[1][0]=gd.getNextNumber();
filt_max_radius[1][1]=gd.getNextNumber();
filt_elongation[0][0]=gd.getNextNumber();
filt_elongation[0][1]=gd.getNextNumber();
filt_elongation[1][0]=gd.getNextNumber();
filt_elongation[1][1]=gd.getNextNumber();
filt_other_rad= gd.getNextNumber();
filt_other_frac[0]= gd.getNextNumber();
filt_other_frac[1]= gd.getNextNumber();
filt_other_rad= gd.getNextNumber();
filt_other_frac[0]= gd.getNextNumber();
filt_other_frac[1]= gd.getNextNumber();
filt_dist[0] = gd.getNextNumber();
filt_dist[1] = gd.getNextNumber();
filt_height = gd.getNextNumber();
filt_full_half_frac[0]=gd.getNextNumber();
filt_full_half_frac[1]=gd.getNextNumber();
filt_dist[0] = gd.getNextNumber();
filt_dist[1] = gd.getNextNumber();
filt_height = gd.getNextNumber();
debugLevel= (int) gd.getNextNumber();
return patternMatchDual (
......@@ -1903,6 +1907,7 @@ public class OrthoMapsCollection implements Serializable{
filt_other_frac, // double [] filt_other_frac, // no pixels around max at filt_other_rad should be higher than this fraction of max
filt_dist, // double [] filt_dist,
filt_height, // double filt_height,
filt_full_half_frac, // double [] filt_full_half_frac,
debugLevel); // int debugLevel)
}
......@@ -1932,7 +1937,7 @@ public class OrthoMapsCollection implements Serializable{
double [] filt_other_frac, // no pixels around max at filt_other_rad should be higher than this fraction of max
double [] filt_dist,
double filt_height,
double [] filt_full_half_frac,
int debugLevel) {
warp.scale_warp = scale_warp;
int corr_radius = (int) (Math.sqrt(0.5)* adv_radius) -1 ;
......@@ -2234,10 +2239,8 @@ public class OrthoMapsCollection implements Serializable{
filter_data[scene_num] = new double[match_sort.size()][2][]; // [scene][max][0-full, 1 - half][0- max, 1 - area, 2 - distance]
extr_corr[scene_num] = new double [match_sort.size()][]; // extracted_objects[scene_num].length][];
extr_corr_half[scene_num] = new double [match_sort.size()][]; // extracted_objects[scene_num].length][];
// extr_corr_best[scene_num] = new double [match_sort.size()][]; // combined full with halves
best_patt_indx = new int [match_sort.size()];
for (int mn=0; mn < match_sort.size(); mn++) {
// best_patt_indx[mn] =
int indx =match_sort.get(mn);
ItemMatch match = matches_list.get(indx);
int best_patt = match.getPatternMatch(gops[scene_num]).getBestSub() - 1;
......@@ -2286,23 +2289,24 @@ public class OrthoMapsCollection implements Serializable{
boolean[] filt_main_other = {true,false};
//int num_removed =
removed = filterCandidates(
filt_keep, // boolean filt_keep,
filt_main_other, // new boolean [] filt_main_other,
min_corrs, //double [] min_corrs, // one per
min_corr_full_rel, // double min_corr_full_rel,
filt_max_radius, // double [][] filt_max_radius,
filt_elongation, // double [][] filt_elongation,
filt_dist, // double [] filt_dist,
filt_height, // double filt_height,
best_patt_indx, // int [] best_patt_indx,
filt_other_frac, //double [] filt_other_frac, // null - disable, for all full (round) patterns.
filter_data, // double [][][][] filter_data,
zoom_level, // int zoom_level,
scene_agl, // double scene_agl,
scene_xy_offset, // double [] scene_xy_offset, //second scene vertical projection offset from the first scene
matches_list, // ArrayList <ItemMatch> matches_list,
match_sort, // ArrayList<Integer> match_sort,
debugLevel); // int debugLevel )
filt_keep, // boolean filt_keep,
filt_main_other, // new boolean [] filt_main_other,
min_corrs, // double [] min_corrs, // one per
min_corr_full_rel, // double min_corr_full_rel,
filt_max_radius, // double [][] filt_max_radius,
filt_elongation, // double [][] filt_elongation,
filt_dist, // double [] filt_dist,
filt_height, // double filt_height,
filt_full_half_frac,// double [] filt_full_half_frac,
best_patt_indx, // int [] best_patt_indx,
filt_other_frac, // double [] filt_other_frac, // null - disable, for all full (round) patterns.
filter_data, // double [][][][] filter_data,
zoom_level, // int zoom_level,
scene_agl, // double scene_agl,
scene_xy_offset, // double [] scene_xy_offset, //second scene vertical projection offset from the first scene
matches_list, // ArrayList <ItemMatch> matches_list,
match_sort, // ArrayList<Integer> match_sort,
debugLevel); // int debugLevel )
if (!filt_keep && (removed.length > match_sort.size())) { // decimate data arrays
for (int sn = 0; sn < filter_data.length; sn++) {
filter_data[sn] = removeFilteredOut (filter_data[sn], removed);
......@@ -2429,21 +2433,22 @@ public class OrthoMapsCollection implements Serializable{
removed = filterCandidates( // will filter again if already
filt_keep, // boolean filt_keep,
new boolean[] {true,true}, // new boolean [] filt_main_other,
min_corrs, //double [] min_corrs, // one per
min_corr_full_rel, // double min_corr_full_rel,
filt_max_radius, // double [][] filt_max_radius,
filt_elongation, // double [][] filt_elongation,
filt_dist, // double [] filt_dist,
filt_height, // double filt_height,
best_patt_indx, // int [] best_patt_indx,
filt_other_frac, //double [] filt_other_frac, // null - disable, for all full (round) patterns.
filter_data, // double [][][][] filter_data,
zoom_level, // int zoom_level,
scene_agl, // double scene_agl,
scene_xy_offset, // double [] scene_xy_offset, //second scene vertical projection offset from the first scene
matches_list, // ArrayList <ItemMatch> matches_list,
match_sort, // ArrayList<Integer> match_sort,
debugLevel); // int debugLevel )
min_corrs, //double [] min_corrs, // one per
min_corr_full_rel, // double min_corr_full_rel,
filt_max_radius, // double [][] filt_max_radius,
filt_elongation, // double [][] filt_elongation,
filt_dist, // double [] filt_dist,
filt_height, // double filt_height,
filt_full_half_frac,// double [] filt_other_frac, // null - disable, for all full (round) patterns.
best_patt_indx, // int [] best_patt_indx,
filt_other_frac, // double [] filt_other_frac, // null - disable, for all full (round) patterns.
filter_data, // double [][][][] filter_data,
zoom_level, // int zoom_level,
scene_agl, // double scene_agl,
scene_xy_offset, // double [] scene_xy_offset, //second scene vertical projection offset from the first scene
matches_list, // ArrayList <ItemMatch> matches_list,
match_sort, // ArrayList<Integer> match_sort,
debugLevel); // int debugLevel )
if (!filt_keep && (removed.length > match_sort.size())) { // decimate data arrays
for (int sn = 0; sn < filter_data.length; sn++) {
......@@ -2505,7 +2510,9 @@ public class OrthoMapsCollection implements Serializable{
System.out.println("filt_dist=["+filt_dist[0]+", "+filt_dist[1]+"] "+
"(First value is the total offset in pixels, second accounts for parallax.) "+
" filt_height="+filt_height+ " meters.");
System.out.println("filt_other_rad="+filt_other_rad+"pix, filt_other_frac=["+filt_other_frac[0]+", "+filt_other_frac[1]+"].");
System.out.println("filt_other_rad="+filt_other_rad+"pix, filt_other_frac=["+filt_other_frac[0]+", "+filt_other_frac[1]+"],"+
" filt_full_half_frac=["+filt_full_half_frac[0]+", "+filt_full_half_frac[1]+"].");
System.out.println("Second image is offset by dx="+scene_xy_offset[0]+", dy="+scene_xy_offset[1]+", dist="+
Math.sqrt(scene_xy_offset[0]*scene_xy_offset[0]+scene_xy_offset[1]*scene_xy_offset[1])+" pix");
System.out.println("Updated object list with main scene peak areas and secondary scene maximums, areas and maximum distances from the main");
......@@ -2513,10 +2520,10 @@ public class OrthoMapsCollection implements Serializable{
for (int j = 0; j < (corrs_out[scene_num].length + 1); j++) if (j != sort_pattern_index) {
System.out.print(String.format(" %8s ","match_"+j));
}
System.out.print(String.format("%6s %6s %6s %6s %6s | %8s %6s %6s %6s %7s %7s %7s %7s %7s | %8s %6s %6s %6s %6s %7s %7s %7s",
"mf-rad","mf-eln","mh-rad","mh-eln", "mh-ofr", // main: full radius, full elongation, half radius, half elongation
"of-corr","of-rad","of-eln","of-dst","of-dx","of-dy","of-par","of-prp","elevat",
"oh-corr","oh-rad","oh-eln", "oh-ofr", "oh-dst","oh-dx","oh-dy","removed"));
System.out.print(String.format("%6s %6s %6s %6s %6s %6s | %8s %6s %6s %6s %7s %7s %7s %7s %7s | %8s %6s %6s %6s %6s %6s %7s %7s %7s",
"mf-rad", "mf-eln","mh-rad", "mh-eln", "mh-ofr", "m_fhr", // main: full radius, full elongation, half radius, half elongation
"of-corr","of-rad","of-eln", "of-dst", "of-dx", "of-dy","of-par","of-prp","elevat",
"oh-corr","oh-rad","oh-eln", "oh-ofr", "o_fhr", "oh-dst", "oh-dx","oh-dy","removed"));
System.out.println();
for (int i = 0; i < match_sort.size(); i++) {
......@@ -2551,37 +2558,29 @@ public class OrthoMapsCollection implements Serializable{
scene_agl); // double agl)
// System.out.println(String.format("best_d=%7.5f, rad=%6.3f, elong=%6.3f, dist=%6.3f, dx=%6.3f, dy=%6.3f",
String sremoved = removed[i]?" removed":"";
double m_fhr = filter_data[0][i][0][0]/filter_data[0][i][1][0];
double o_fhr = filter_data[1][i][0][0]/filter_data[1][i][1][0];
System.out.print(String.format(
"%6.3f %6.3f %6.3f %6.3f %6.3f | %8.5f %6.3f %6.3f %6.3f %7.3f %7.3f %7.3f %7.3f %7.3f | %8.5f %6.3f %6.3f %6.3f %6.3f %7.3f %7.3f %7s",
"%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f | %8.5f %6.3f %6.3f %6.3f %7.3f %7.3f %7.3f %7.3f %7.3f | %8.5f %6.3f %6.3f %6.3f %6.3f %6.3f %7.3f %7.3f %7s",
// main full and best half areas only, radius and elongation
filter_data[0][i][0][1], filter_data[0][i][0][2], // main full: radius and elongation
filter_data[0][i][1][1], filter_data[0][i][1][2], // main best half: radius and elongation
filter_data[0][i][1][6], // other max fraction of the main one
m_fhr,
// for second full - everything and parallel/perpendicular+elevation
filter_data[1][i][0][0], filter_data[1][i][0][1], filter_data[1][i][0][2], // full: corr, radius, elongation
filter_data[1][i][0][3], filter_data[1][i][0][4], filter_data[1][i][0][5], // full: dist, dx, dy
scnd_xy_proj[0], scnd_xy_proj[1],obj_elev, // full: parallel, perpnd, elevation(m)
filter_data[1][i][1][0], filter_data[1][i][1][1], filter_data[1][i][1][2], // half: corr, radius, elongation
filter_data[1][i][1][6],
filter_data[1][i][1][6], ///
o_fhr,
filter_data[1][i][1][3], filter_data[1][i][1][4], filter_data[1][i][1][5], // half: dist, dx, dy
sremoved));
System.out.println();
}
System.out.println();
//ortho_maps[indices[0]]
//double [][] dmulti
//ortho_maps[indices[scene_num]].getName()
/*
PointRoi roi = new PointRoi();
roi.setOptions("label");
for (int i = 0; i < src_marks.length; i++) {
roi.addPoint(src_marks[i][0],src_marks[i][1]); // ,1);
}
imp_corrs[scene_num].setRoi(roi);
*/
{ // Create image with marked mines
PointRoi final_roi = new PointRoi();
final_roi.setOptions("label");
......@@ -2710,7 +2709,7 @@ public class OrthoMapsCollection implements Serializable{
}
System.out.println("patternMatchDual(): all correlations DONE");
return null;
return imps_patt_conv[0];
}
public static double [][][] removeFilteredOut(
......@@ -2801,6 +2800,7 @@ public class OrthoMapsCollection implements Serializable{
double [][] filt_elongation,
double [] filt_dist,
double filt_height,
double [] filt_full_half_frac,
int [] best_patt_indx,
double [] filt_other_frac, // null - disable, for all full (round) patterns.
double [][][][] filter_data,
......@@ -2820,12 +2820,16 @@ public class OrthoMapsCollection implements Serializable{
zoom_level, // int zoom_level,
scene_agl) ;// double agl)
for (int mn=0; mn < match_sort.size(); mn++) {
int indx =match_sort.get(mn);
ItemMatch match = matches_list.get(indx);
int [] ixy = match.getIntXY();
String name = ixy[0]+"/"+ixy[1];
boolean is_partial = best_patt_indx[mn] != 0; // only apply to combined full/half correlations, just full may have nearby maximums near the same size
double [] strength_full_half_ratio = new double[2];
for (int scene_num = 0; scene_num < 2; scene_num++) if (filter_data[scene_num] != null){
strength_full_half_ratio[scene_num] = filter_data[scene_num][mn][0][0] / filter_data[scene_num][mn][1][0];
}
for (int hf = 0; hf < 2; hf++) {
int indx =match_sort.get(mn);
ItemMatch match = matches_list.get(indx);
int [] ixy = match.getIntXY();
String name = ixy[0]+"/"+ixy[1];
boolean is_partial = best_patt_indx[mn] != 0; // only apply to combined full/halv correlations, just full may have nearby maximums near the same size
for (int scene_num = 0; scene_num < 2; scene_num++) if (filt_main_other[scene_num]){
if (Double.isNaN(filter_data[scene_num][mn][hf][0])) {
System.out.println(name+": filtered out by "+NAME_MO[scene_num]+"/"+NAME_FH[hf]+
......@@ -2896,13 +2900,22 @@ public class OrthoMapsCollection implements Serializable{
if (!remove[mn]) num_removed++;
remove[mn] = true;
}
if ((filt_other_frac != null) && (hf > 0) && (near_max_frac > filt_other_frac[scene_num])) {
if (is_partial && (filt_other_frac != null) && (hf > 0) && (near_max_frac > filt_other_frac[scene_num])) {
System.out.println(name+": filtered out by "+NAME_MO[scene_num]+
" because it matches partial pattern and combined full/partial correlation has a near peak "+
near_max_frac+" > "+ filt_other_frac[scene_num]+" of the used peak.");
if (!remove[mn]) num_removed++;
remove[mn] = true;
}
if (hf==0) {
if ( strength_full_half_ratio[scene_num] < filt_full_half_frac[scene_num]) {
System.out.println(name+": filtered out by "+NAME_MO[scene_num]+
" because its correlation with the full patern strengh ratio to the partial pattern one = "+
strength_full_half_ratio[scene_num]+" < "+ filt_full_half_frac[scene_num]+" (minimum allowed).");
if (!remove[mn]) num_removed++;
remove[mn] = true;
}
}
}
}
}
......
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