Commit 0cccb665 authored by Andrey Filippov's avatar Andrey Filippov

working on sfm

parent be2cbd56
...@@ -275,6 +275,7 @@ public class IntersceneLma { ...@@ -275,6 +275,7 @@ public class IntersceneLma {
final double [][] eigen, // [tilesX*tilesY]{lamb0_x,lamb0_y, lamb0, lamb1} eigenvector0[x,y],lam0,lam1 final double [][] eigen, // [tilesX*tilesY]{lamb0_x,lamb0_y, lamb0, lamb1} eigenvector0[x,y],lam0,lam1
// now includes optional Disparity as the last element (for num_components==3) // now includes optional Disparity as the last element (for num_components==3)
final double [][] vector_XYSDS,// optical flow X,Y, confidence obtained from the correlate2DIterate() final double [][] vector_XYSDS,// optical flow X,Y, confidence obtained from the correlate2DIterate()
final boolean [] reliable_ref, // additional mask for vector_XYSDS or null
final double [][] centers, // macrotile centers (in pixels and average disparities final double [][] centers, // macrotile centers (in pixels and average disparities
final boolean same_weights, final boolean same_weights,
boolean first_run, boolean first_run,
...@@ -339,6 +340,7 @@ public class IntersceneLma { ...@@ -339,6 +340,7 @@ public class IntersceneLma {
if (vector_XYSDS != null) {// skip when used for the motion blur vectors, not LMA if (vector_XYSDS != null) {// skip when used for the motion blur vectors, not LMA
setSamplesWeights(vector_XYSDS, // not regularized yet ! // 3d updated setSamplesWeights(vector_XYSDS, // not regularized yet ! // 3d updated
reliable_ref, // final boolean [] reliable_ref, // additional mask for vector_XYSDS or null
same_weights); // final boolean same_weights) // same weight if > 0 same_weights); // final boolean same_weights) // same weight if > 0
} else { } else {
...@@ -482,6 +484,7 @@ public class IntersceneLma { ...@@ -482,6 +484,7 @@ public class IntersceneLma {
if (vector_XYSDS != null) {// skip when used for the motion blur vectors, not LMA if (vector_XYSDS != null) {// skip when used for the motion blur vectors, not LMA
setSamplesWeights(vector_XYSDS, // not regularized yet ! // 3d updated setSamplesWeights(vector_XYSDS, // not regularized yet ! // 3d updated
null, // final boolean [] reliable_ref, // additional mask for vector_XYSDS or null
same_weights); // final boolean same_weights) // same weight if > 0 same_weights); // final boolean same_weights) // same weight if > 0
} else { } else {
weights = null; // new double[2 * centers.length]; weights = null; // new double[2 * centers.length];
...@@ -867,6 +870,7 @@ public class IntersceneLma { ...@@ -867,6 +870,7 @@ public class IntersceneLma {
private void setSamplesWeights( private void setSamplesWeights(
final double [][] vector_XYSDS, // not regularized yet final double [][] vector_XYSDS, // not regularized yet
final boolean [] reliable_ref, // additional mask for vector_XYSDS or null
final boolean same_weights) // same weight if > 0 final boolean same_weights) // same weight if > 0
{ {
//num_components 2 - old, 3 - with disparity //num_components 2 - old, 3 - with disparity
...@@ -883,7 +887,8 @@ public class IntersceneLma { ...@@ -883,7 +887,8 @@ public class IntersceneLma {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
int thread_num = ati.getAndIncrement(); int thread_num = ati.getAndIncrement();
for (int iMTile = ai.getAndIncrement(); iMTile < vector_XYSDS.length; iMTile = ai.getAndIncrement()) if (vector_XYSDS[iMTile] != null){ for (int iMTile = ai.getAndIncrement(); iMTile < vector_XYSDS.length; iMTile = ai.getAndIncrement())
if ((vector_XYSDS[iMTile] != null) && ((reliable_ref == null) || reliable_ref[iMTile])){
double w = vector_XYSDS[iMTile][2]; double w = vector_XYSDS[iMTile][2];
if ((eig_trans != null) && (eig_trans[iMTile] == null)) { if ((eig_trans != null) && (eig_trans[iMTile] == null)) {
w = 0; w = 0;
...@@ -931,7 +936,8 @@ public class IntersceneLma { ...@@ -931,7 +936,8 @@ public class IntersceneLma {
for (int ithread = 0; ithread < threads.length; ithread++) { for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() { threads[ithread] = new Thread() {
public void run() { public void run() {
for (int iMTile = ai.getAndIncrement(); iMTile < vector_XYSDS.length; iMTile = ai.getAndIncrement()) if (vector_XYSDS[iMTile] != null){ for (int iMTile = ai.getAndIncrement(); iMTile < vector_XYSDS.length; iMTile = ai.getAndIncrement())
if ((vector_XYSDS[iMTile] != null) && ((reliable_ref == null) || reliable_ref[iMTile])){
weights[num_components * iMTile] *= s; weights[num_components * iMTile] *= s;
weights[num_components * iMTile + 1] = weights[num_components * iMTile]; weights[num_components * iMTile + 1] = weights[num_components * iMTile];
if (num_components > 2) { if (num_components > 2) {
......
...@@ -158,6 +158,8 @@ public class IntersceneMatchParameters { ...@@ -158,6 +158,8 @@ public class IntersceneMatchParameters {
public double sfma_filt_fgbg = 0.1; // If weak tile's neighbors max-min exceeds this, and public double sfma_filt_fgbg = 0.1; // If weak tile's neighbors max-min exceeds this, and
public double sfma_filt_str = 0.9; // it is NaN or weaker that this fraction of the local maximum, consider it a bg and average with bg tiles only public double sfma_filt_str = 0.9; // it is NaN or weaker that this fraction of the local maximum, consider it a bg and average with bg tiles only
public boolean sfma_all_en = true; // calculate SfM for all tiles, including "unreliable" (make them reliable?)
public double sfma_confidence = 0.15; // rehabilitate "unreliable" SfM tiles if confidence is above this threshold
...@@ -1572,9 +1574,14 @@ min_str_neib_fpn 0.35 ...@@ -1572,9 +1574,14 @@ min_str_neib_fpn 0.35
"Consider weak tiles to belong to bg if the next are met."); "Consider weak tiles to belong to bg if the next are met.");
gd.addNumericField("Min max/min range for BG", this.sfma_filt_fgbg, 6,7,"m", gd.addNumericField("Min max/min range for BG", this.sfma_filt_fgbg, 6,7,"m",
"If weak tile's neighbors max-min exceeds this, and"); "If weak tile's neighbors max-min exceeds this, and");
gd.addNumericField("Maximal BG relative local strength", this.sfma_filt_str, 6,7,"m", gd.addNumericField("Maximal BG relative local strength", this.sfma_filt_str, 6,7,"",
"(continue) it is NaN or weaker that this fraction of the local maximum, consider it a bg and average with bg tiles only"); "(continue) it is NaN or weaker that this fraction of the local maximum, consider it a bg and average with bg tiles only");
gd.addCheckbox ("Calculate SfM for all tiles", this.sfma_all_en,
"Calculate SfM for all tiles, including \"unreliable\", make them reliable (>certain confidence?).");
gd.addNumericField("Rehabilitation confidence", this.sfma_confidence, 6,7,"", // fraction of average "reliable"?
"Interscene correlation confidence to make it \"reliable\".");
//------------------- //-------------------
...@@ -3555,6 +3562,8 @@ min_str_neib_fpn 0.35 ...@@ -3555,6 +3562,8 @@ min_str_neib_fpn 0.35
this.sfma_filt_weakbg = gd.getNextBoolean(); this.sfma_filt_weakbg = gd.getNextBoolean();
this.sfma_filt_fgbg = gd.getNextNumber(); this.sfma_filt_fgbg = gd.getNextNumber();
this.sfma_filt_str = gd.getNextNumber(); this.sfma_filt_str = gd.getNextNumber();
this.sfma_all_en = gd.getNextBoolean();
this.sfma_confidence = gd.getNextNumber();
this.omtch_img_set = ComboMatch.FILES_LISTS_PATHS[gd.getNextChoiceIndex()]; this.omtch_img_set = ComboMatch.FILES_LISTS_PATHS[gd.getNextChoiceIndex()];
this.rln_gpu_width = (int) gd.getNextNumber(); this.rln_gpu_width = (int) gd.getNextNumber();
...@@ -4764,6 +4773,8 @@ min_str_neib_fpn 0.35 ...@@ -4764,6 +4773,8 @@ min_str_neib_fpn 0.35
properties.setProperty(prefix+"sfma_filt_weakbg", this.sfma_filt_weakbg + ""); // boolean properties.setProperty(prefix+"sfma_filt_weakbg", this.sfma_filt_weakbg + ""); // boolean
properties.setProperty(prefix+"sfma_filt_fgbg", this.sfma_filt_fgbg+""); // double properties.setProperty(prefix+"sfma_filt_fgbg", this.sfma_filt_fgbg+""); // double
properties.setProperty(prefix+"sfma_filt_str", this.sfma_filt_str+""); // double properties.setProperty(prefix+"sfma_filt_str", this.sfma_filt_str+""); // double
properties.setProperty(prefix+"sfma_all_en", this.sfma_all_en + ""); // boolean
properties.setProperty(prefix+"sfma_confidence", this.sfma_confidence+""); // double
properties.setProperty(prefix+"omtch_img_set", this.omtch_img_set + ""); // String properties.setProperty(prefix+"omtch_img_set", this.omtch_img_set + ""); // String
properties.setProperty(prefix+"rln_gpu_width", this.rln_gpu_width+""); // int properties.setProperty(prefix+"rln_gpu_width", this.rln_gpu_width+""); // int
...@@ -5916,6 +5927,8 @@ min_str_neib_fpn 0.35 ...@@ -5916,6 +5927,8 @@ min_str_neib_fpn 0.35
if (properties.getProperty(prefix+"sfma_filt_weakbg")!=null) this.sfma_filt_weakbg=Boolean.parseBoolean(properties.getProperty(prefix+"sfma_filt_weakbg")); if (properties.getProperty(prefix+"sfma_filt_weakbg")!=null) this.sfma_filt_weakbg=Boolean.parseBoolean(properties.getProperty(prefix+"sfma_filt_weakbg"));
if (properties.getProperty(prefix+"sfma_filt_fgbg")!=null) this.sfma_filt_fgbg=Double.parseDouble(properties.getProperty(prefix+"sfma_filt_fgbg")); if (properties.getProperty(prefix+"sfma_filt_fgbg")!=null) this.sfma_filt_fgbg=Double.parseDouble(properties.getProperty(prefix+"sfma_filt_fgbg"));
if (properties.getProperty(prefix+"sfma_filt_str")!=null) this.sfma_filt_str=Double.parseDouble(properties.getProperty(prefix+"sfma_filt_str")); if (properties.getProperty(prefix+"sfma_filt_str")!=null) this.sfma_filt_str=Double.parseDouble(properties.getProperty(prefix+"sfma_filt_str"));
if (properties.getProperty(prefix+"sfma_all_en")!=null) this.sfma_all_en=Boolean.parseBoolean(properties.getProperty(prefix+"sfma_all_en"));
if (properties.getProperty(prefix+"sfma_confidence")!=null) this.sfma_confidence=Double.parseDouble(properties.getProperty(prefix+"sfma_confidence"));
if (properties.getProperty(prefix+"omtch_img_set")!=null) this.omtch_img_set=(String) properties.getProperty(prefix+ "omtch_img_set"); if (properties.getProperty(prefix+"omtch_img_set")!=null) this.omtch_img_set=(String) properties.getProperty(prefix+ "omtch_img_set");
if (properties.getProperty(prefix+"rln_gpu_width")!=null) this.rln_gpu_width=Integer.parseInt(properties.getProperty(prefix+"rln_gpu_width")); if (properties.getProperty(prefix+"rln_gpu_width")!=null) this.rln_gpu_width=Integer.parseInt(properties.getProperty(prefix+"rln_gpu_width"));
...@@ -7099,7 +7112,8 @@ min_str_neib_fpn 0.35 ...@@ -7099,7 +7112,8 @@ min_str_neib_fpn 0.35
imp.sfma_filt_weakbg = this.sfma_filt_weakbg; imp.sfma_filt_weakbg = this.sfma_filt_weakbg;
imp.sfma_filt_fgbg = this.sfma_filt_fgbg; imp.sfma_filt_fgbg = this.sfma_filt_fgbg;
imp.sfma_filt_str = this.sfma_filt_str; imp.sfma_filt_str = this.sfma_filt_str;
imp.sfma_all_en = this.sfma_all_en;
imp.sfma_confidence = this.sfma_confidence;
imp.omtch_img_set = this.omtch_img_set; imp.omtch_img_set = this.omtch_img_set;
imp.rln_gpu_width = this.rln_gpu_width; imp.rln_gpu_width = this.rln_gpu_width;
......
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