Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
7180569b
Commit
7180569b
authored
Aug 11, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Before textures artefacts correction
parent
38b6b0d7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
265 additions
and
90 deletions
+265
-90
IntersceneLma.java
...n/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
+1
-0
IntersceneLmaParameters.java
.../elphel/imagej/tileprocessor/IntersceneLmaParameters.java
+26
-2
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+10
-2
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+179
-83
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+49
-3
No files found.
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
View file @
7180569b
...
@@ -43,6 +43,7 @@ public class IntersceneLma {
...
@@ -43,6 +43,7 @@ public class IntersceneLma {
)
{
)
{
this
.
thread_invariant
=
thread_invariant
;
this
.
thread_invariant
=
thread_invariant
;
this
.
num_components
=
(
disparity_weight
>
0
)
?
3
:
2
;
this
.
num_components
=
(
disparity_weight
>
0
)
?
3
:
2
;
this
.
disparity_weight
=
disparity_weight
;
}
}
public
int
getNumComponents
()
{
public
int
getNumComponents
()
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLmaParameters.java
View file @
7180569b
...
@@ -36,6 +36,8 @@ public class IntersceneLmaParameters {
...
@@ -36,6 +36,8 @@ public class IntersceneLmaParameters {
public
boolean
ilma_thread_invariant
=
true
;
// Do not use DoubleAdder, provide results not dependent on threads
public
boolean
ilma_thread_invariant
=
true
;
// Do not use DoubleAdder, provide results not dependent on threads
public
boolean
[]
ilma_lma_select
=
new
boolean
[
ErsCorrection
.
DP_NUM_PARS
];
// first three will not be used
public
boolean
[]
ilma_lma_select
=
new
boolean
[
ErsCorrection
.
DP_NUM_PARS
];
// first three will not be used
public
double
[]
ilma_regularization_weights
=
new
double
[
ErsCorrection
.
DP_NUM_PARS
];
// first three will not be used
public
double
[]
ilma_regularization_weights
=
new
double
[
ErsCorrection
.
DP_NUM_PARS
];
// first three will not be used
public
double
[]
ilma_regularization_weights0
=
new
double
[
ErsCorrection
.
DP_NUM_PARS
];
// Use after spiral
public
boolean
ilma_translation_priority
=
false
;
// expect translation for thepre-ref scene to be probable than rotation
public
boolean
ilma_ignore_ers
=
false
;
// ignore linear and angular velocities, assume tham zeroes
public
boolean
ilma_ignore_ers
=
false
;
// ignore linear and angular velocities, assume tham zeroes
public
boolean
ilma_ers_adj_lin
=
false
;
// adjust linear ERS for scene-to-ref (LWIR does not work, check with high-speed)
public
boolean
ilma_ers_adj_lin
=
false
;
// adjust linear ERS for scene-to-ref (LWIR does not work, check with high-speed)
public
boolean
ilma_ers_adj_ang
=
false
;
// adjust angular ERS for scene-to-ref (LWIR does not work, check with high-speed)
public
boolean
ilma_ers_adj_ang
=
false
;
// adjust angular ERS for scene-to-ref (LWIR does not work, check with high-speed)
...
@@ -107,6 +109,7 @@ public class IntersceneLmaParameters {
...
@@ -107,6 +109,7 @@ public class IntersceneLmaParameters {
ilma_regularization_weights
[
ErsCorrection
.
DP_DSX
]=
0.0
;
ilma_regularization_weights
[
ErsCorrection
.
DP_DSX
]=
0.0
;
ilma_regularization_weights
[
ErsCorrection
.
DP_DSY
]=
0.0
;
ilma_regularization_weights
[
ErsCorrection
.
DP_DSY
]=
0.0
;
ilma_regularization_weights
[
ErsCorrection
.
DP_DSZ
]=
0.0
;
ilma_regularization_weights
[
ErsCorrection
.
DP_DSZ
]=
0.0
;
ilma_regularization_weights0
=
ilma_regularization_weights
.
clone
();
}
}
public
void
dialogQuestions
(
GenericJTabbedDialog
gd
)
{
public
void
dialogQuestions
(
GenericJTabbedDialog
gd
)
{
...
@@ -132,6 +135,15 @@ public class IntersceneLmaParameters {
...
@@ -132,6 +135,15 @@ public class IntersceneLmaParameters {
"Weight of "
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
" pull, 1.0 means that the paramter offset from initial corresponding to 1 image pixel\n"
+
"Weight of "
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
" pull, 1.0 means that the paramter offset from initial corresponding to 1 image pixel\n"
+
" will cause error equal to all reprojection ones"
);
" will cause error equal to all reprojection ones"
);
}
}
gd
.
addMessage
(
"Regularization parameters to be used first after spiral"
);
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
gd
.
addNumericField
(
ErsCorrection
.
DP_DERIV_NAMES
[
i
],
this
.
ilma_regularization_weights0
[
i
],
6
,
8
,
""
,
"Weight of "
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
" pull, 1.0 means that the paramter offset from initial corresponding to 1 image pixel\n"
+
" will cause error equal to all reprojection ones"
);
}
gd
.
addCheckbox
(
"Expect translation not rotation"
,
this
.
ilma_translation_priority
,
"Expect translation to be more likely than rotation for the first movement after the spiral search"
);
gd
.
addMessage
(
"LMA other parameters"
);
gd
.
addMessage
(
"LMA other parameters"
);
gd
.
addCheckbox
(
"Ignore linear and angular velocities"
,
this
.
ilma_ignore_ers
,
gd
.
addCheckbox
(
"Ignore linear and angular velocities"
,
this
.
ilma_ignore_ers
,
"Ignore calculated linear and angular velocities when correlating scenes to the reference one"
);
"Ignore calculated linear and angular velocities when correlating scenes to the reference one"
);
...
@@ -187,6 +199,10 @@ public class IntersceneLmaParameters {
...
@@ -187,6 +199,10 @@ public class IntersceneLmaParameters {
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
this
.
ilma_regularization_weights
[
i
]
=
gd
.
getNextNumber
();
this
.
ilma_regularization_weights
[
i
]
=
gd
.
getNextNumber
();
}
}
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
this
.
ilma_regularization_weights0
[
i
]
=
gd
.
getNextNumber
();
}
this
.
ilma_translation_priority
=
gd
.
getNextBoolean
();
this
.
ilma_ignore_ers
=
gd
.
getNextBoolean
();
this
.
ilma_ignore_ers
=
gd
.
getNextBoolean
();
this
.
ilma_ers_adj_lin
=
gd
.
getNextBoolean
();
this
.
ilma_ers_adj_lin
=
gd
.
getNextBoolean
();
this
.
ilma_ers_adj_ang
=
gd
.
getNextBoolean
();
this
.
ilma_ers_adj_ang
=
gd
.
getNextBoolean
();
...
@@ -216,7 +232,9 @@ public class IntersceneLmaParameters {
...
@@ -216,7 +232,9 @@ public class IntersceneLmaParameters {
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
for
(
int
i
=
ErsCorrection
.
DP_DVAZ
;
i
<
ErsCorrection
.
DP_NUM_PARS
;
i
++)
{
properties
.
setProperty
(
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_sel"
,
this
.
ilma_lma_select
[
i
]+
""
);
properties
.
setProperty
(
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_sel"
,
this
.
ilma_lma_select
[
i
]+
""
);
properties
.
setProperty
(
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight"
,
this
.
ilma_regularization_weights
[
i
]+
""
);
properties
.
setProperty
(
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight"
,
this
.
ilma_regularization_weights
[
i
]+
""
);
properties
.
setProperty
(
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight0"
,
this
.
ilma_regularization_weights0
[
i
]+
""
);
}
}
properties
.
setProperty
(
prefix
+
"ilma_translation_priority"
,
this
.
ilma_translation_priority
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ignore_ers"
,
this
.
ilma_ignore_ers
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ignore_ers"
,
this
.
ilma_ignore_ers
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ers_adj_lin"
,
this
.
ilma_ers_adj_lin
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ers_adj_lin"
,
this
.
ilma_ers_adj_lin
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ers_adj_ang"
,
this
.
ilma_ers_adj_ang
+
""
);
properties
.
setProperty
(
prefix
+
"ilma_ers_adj_ang"
,
this
.
ilma_ers_adj_ang
+
""
);
...
@@ -247,7 +265,11 @@ public class IntersceneLmaParameters {
...
@@ -247,7 +265,11 @@ public class IntersceneLmaParameters {
if
(
properties
.
getProperty
(
pn_sel
)!=
null
)
this
.
ilma_lma_select
[
i
]=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
pn_sel
));
if
(
properties
.
getProperty
(
pn_sel
)!=
null
)
this
.
ilma_lma_select
[
i
]=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
pn_sel
));
pn_sel
=
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight"
;
pn_sel
=
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight"
;
if
(
properties
.
getProperty
(
pn_sel
)!=
null
)
this
.
ilma_regularization_weights
[
i
]=
Double
.
parseDouble
(
properties
.
getProperty
(
pn_sel
));
if
(
properties
.
getProperty
(
pn_sel
)!=
null
)
this
.
ilma_regularization_weights
[
i
]=
Double
.
parseDouble
(
properties
.
getProperty
(
pn_sel
));
pn_sel
=
prefix
+
ErsCorrection
.
DP_DERIV_NAMES
[
i
]+
"_regweight0"
;
if
(
properties
.
getProperty
(
pn_sel
)!=
null
)
this
.
ilma_regularization_weights0
[
i
]=
Double
.
parseDouble
(
properties
.
getProperty
(
pn_sel
));
}
}
//
if
(
properties
.
getProperty
(
prefix
+
"ilma_translation_priority"
)!=
null
)
this
.
ilma_translation_priority
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_translation_priority"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ignore_ers"
)!=
null
)
this
.
ilma_ignore_ers
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ignore_ers"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ignore_ers"
)!=
null
)
this
.
ilma_ignore_ers
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ignore_ers"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_lin"
)!=
null
)
this
.
ilma_ers_adj_lin
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_lin"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_lin"
)!=
null
)
this
.
ilma_ers_adj_lin
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_lin"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_ang"
)!=
null
)
this
.
ilma_ers_adj_ang
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_ang"
));
if
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_ang"
)!=
null
)
this
.
ilma_ers_adj_ang
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ilma_ers_adj_ang"
));
...
@@ -287,6 +309,8 @@ public class IntersceneLmaParameters {
...
@@ -287,6 +309,8 @@ public class IntersceneLmaParameters {
ilp
.
ilma_thread_invariant
=
this
.
ilma_thread_invariant
;
ilp
.
ilma_thread_invariant
=
this
.
ilma_thread_invariant
;
System
.
arraycopy
(
this
.
ilma_lma_select
,
0
,
ilp
.
ilma_lma_select
,
0
,
ilma_lma_select
.
length
);
System
.
arraycopy
(
this
.
ilma_lma_select
,
0
,
ilp
.
ilma_lma_select
,
0
,
ilma_lma_select
.
length
);
System
.
arraycopy
(
this
.
ilma_regularization_weights
,
0
,
ilp
.
ilma_regularization_weights
,
0
,
ilma_regularization_weights
.
length
);
System
.
arraycopy
(
this
.
ilma_regularization_weights
,
0
,
ilp
.
ilma_regularization_weights
,
0
,
ilma_regularization_weights
.
length
);
System
.
arraycopy
(
this
.
ilma_regularization_weights0
,
0
,
ilp
.
ilma_regularization_weights0
,
0
,
ilma_regularization_weights0
.
length
);
ilp
.
ilma_translation_priority
=
this
.
ilma_translation_priority
;
ilp
.
ilma_ignore_ers
=
this
.
ilma_ignore_ers
;
ilp
.
ilma_ignore_ers
=
this
.
ilma_ignore_ers
;
ilp
.
ilma_ers_adj_lin
=
this
.
ilma_ers_adj_lin
;
ilp
.
ilma_ers_adj_lin
=
this
.
ilma_ers_adj_lin
;
ilp
.
ilma_ers_adj_ang
=
this
.
ilma_ers_adj_ang
;
ilp
.
ilma_ers_adj_ang
=
this
.
ilma_ers_adj_ang
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
7180569b
...
@@ -238,7 +238,8 @@ public class IntersceneMatchParameters {
...
@@ -238,7 +238,8 @@ public class IntersceneMatchParameters {
public
double
half_avg_diff
=
0.2
;
// when L2 of x,y difference from average of neibs - reduce twice
public
double
half_avg_diff
=
0.2
;
// when L2 of x,y difference from average of neibs - reduce twice
// Detect initial match
// Detect initial match
public
double
min_ref_str
=
0.15
;
// 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
public
double
min_ref_str
=
0.33
;
// 0.22; // For orientations: use only tiles of the reference scene DSI_MAIN is stronger
public
double
min_ref_frac
=
0.2
;
// 0.22; if fraction number of reliable tiles is less than this, use best possible
public
int
pix_step
=
4
;
// Azimuth/tilt search step in pixels
public
int
pix_step
=
4
;
// Azimuth/tilt search step in pixels
public
int
search_rad
=
10
;
// Search radius in steps
public
int
search_rad
=
10
;
// Search radius in steps
public
double
maybe_sum
=
1.0
;
// minimal sum of strengths (will search for the best)
public
double
maybe_sum
=
1.0
;
// minimal sum of strengths (will search for the best)
...
@@ -759,6 +760,8 @@ public class IntersceneMatchParameters {
...
@@ -759,6 +760,8 @@ public class IntersceneMatchParameters {
gd
.
addMessage
(
"Initial search for the inter-scene match"
);
gd
.
addMessage
(
"Initial search for the inter-scene match"
);
gd
.
addNumericField
(
"DSI_MAIN minimal strength"
,
this
.
min_ref_str
,
5
,
7
,
""
,
gd
.
addNumericField
(
"DSI_MAIN minimal strength"
,
this
.
min_ref_str
,
5
,
7
,
""
,
"Match only tiles where DSI_MAIN is stronger than that (and has LMA)."
);
"Match only tiles where DSI_MAIN is stronger than that (and has LMA)."
);
gd
.
addNumericField
(
"DSI_MAIN minimal fraction"
,
this
.
min_ref_frac
,
5
,
7
,
""
,
"If relative number of the reliable tiles is less than this - use this best fraction."
);
gd
.
addNumericField
(
"Azimuth/tilt step"
,
this
.
pix_step
,
0
,
3
,
"pix"
,
gd
.
addNumericField
(
"Azimuth/tilt step"
,
this
.
pix_step
,
0
,
3
,
"pix"
,
"Search in a spiral starting with no-shift with this step between probes, in approximate pixels"
);
"Search in a spiral starting with no-shift with this step between probes, in approximate pixels"
);
...
@@ -1169,6 +1172,7 @@ public class IntersceneMatchParameters {
...
@@ -1169,6 +1172,7 @@ public class IntersceneMatchParameters {
this
.
half_disparity
=
gd
.
getNextNumber
();
this
.
half_disparity
=
gd
.
getNextNumber
();
this
.
half_avg_diff
=
gd
.
getNextNumber
();
this
.
half_avg_diff
=
gd
.
getNextNumber
();
this
.
min_ref_str
=
gd
.
getNextNumber
();
this
.
min_ref_str
=
gd
.
getNextNumber
();
this
.
min_ref_frac
=
gd
.
getNextNumber
();
this
.
pix_step
=
(
int
)
gd
.
getNextNumber
();
this
.
pix_step
=
(
int
)
gd
.
getNextNumber
();
this
.
search_rad
=
(
int
)
gd
.
getNextNumber
();
this
.
search_rad
=
(
int
)
gd
.
getNextNumber
();
this
.
maybe_sum
=
gd
.
getNextNumber
();
this
.
maybe_sum
=
gd
.
getNextNumber
();
...
@@ -1492,6 +1496,7 @@ public class IntersceneMatchParameters {
...
@@ -1492,6 +1496,7 @@ public class IntersceneMatchParameters {
properties
.
setProperty
(
prefix
+
"centroid_radius"
,
this
.
centroid_radius
+
""
);
// double
properties
.
setProperty
(
prefix
+
"centroid_radius"
,
this
.
centroid_radius
+
""
);
// double
properties
.
setProperty
(
prefix
+
"n_recenter"
,
this
.
n_recenter
+
""
);
// int
properties
.
setProperty
(
prefix
+
"n_recenter"
,
this
.
n_recenter
+
""
);
// int
properties
.
setProperty
(
prefix
+
"min_ref_str"
,
this
.
min_ref_str
+
""
);
// double
properties
.
setProperty
(
prefix
+
"min_ref_str"
,
this
.
min_ref_str
+
""
);
// double
properties
.
setProperty
(
prefix
+
"min_ref_frac"
,
this
.
min_ref_frac
+
""
);
// double
properties
.
setProperty
(
prefix
+
"td_weight"
,
this
.
td_weight
+
""
);
// double
properties
.
setProperty
(
prefix
+
"td_weight"
,
this
.
td_weight
+
""
);
// double
properties
.
setProperty
(
prefix
+
"pd_weight"
,
this
.
pd_weight
+
""
);
// double
properties
.
setProperty
(
prefix
+
"pd_weight"
,
this
.
pd_weight
+
""
);
// double
properties
.
setProperty
(
prefix
+
"td_nopd_only"
,
this
.
td_nopd_only
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"td_nopd_only"
,
this
.
td_nopd_only
+
""
);
// boolean
...
@@ -1784,6 +1789,7 @@ public class IntersceneMatchParameters {
...
@@ -1784,6 +1789,7 @@ public class IntersceneMatchParameters {
if
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
)!=
null
)
this
.
centroid_radius
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
));
if
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
)!=
null
)
this
.
centroid_radius
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"centroid_radius"
));
if
(
properties
.
getProperty
(
prefix
+
"n_recenter"
)!=
null
)
this
.
n_recenter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"n_recenter"
));
if
(
properties
.
getProperty
(
prefix
+
"n_recenter"
)!=
null
)
this
.
n_recenter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"n_recenter"
));
if
(
properties
.
getProperty
(
prefix
+
"min_ref_str"
)!=
null
)
this
.
min_ref_str
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_ref_str"
));
if
(
properties
.
getProperty
(
prefix
+
"min_ref_str"
)!=
null
)
this
.
min_ref_str
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_ref_str"
));
if
(
properties
.
getProperty
(
prefix
+
"min_ref_frac"
)!=
null
)
this
.
min_ref_frac
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"min_ref_frac"
));
if
(
properties
.
getProperty
(
prefix
+
"td_weight"
)!=
null
)
this
.
td_weight
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"td_weight"
));
if
(
properties
.
getProperty
(
prefix
+
"td_weight"
)!=
null
)
this
.
td_weight
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"td_weight"
));
if
(
properties
.
getProperty
(
prefix
+
"pd_weight"
)!=
null
)
this
.
pd_weight
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"pd_weight"
));
if
(
properties
.
getProperty
(
prefix
+
"pd_weight"
)!=
null
)
this
.
pd_weight
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"pd_weight"
));
if
(
properties
.
getProperty
(
prefix
+
"td_nopd_only"
)!=
null
)
this
.
td_nopd_only
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"td_nopd_only"
));
if
(
properties
.
getProperty
(
prefix
+
"td_nopd_only"
)!=
null
)
this
.
td_nopd_only
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"td_nopd_only"
));
...
@@ -2086,6 +2092,8 @@ public class IntersceneMatchParameters {
...
@@ -2086,6 +2092,8 @@ public class IntersceneMatchParameters {
imp
.
centroid_radius
=
this
.
centroid_radius
;
imp
.
centroid_radius
=
this
.
centroid_radius
;
imp
.
n_recenter
=
this
.
n_recenter
;
imp
.
n_recenter
=
this
.
n_recenter
;
imp
.
min_ref_str
=
this
.
min_ref_str
;
imp
.
min_ref_str
=
this
.
min_ref_str
;
imp
.
min_ref_frac
=
this
.
min_ref_frac
;
imp
.
td_weight
=
this
.
td_weight
;
imp
.
td_weight
=
this
.
td_weight
;
imp
.
pd_weight
=
this
.
pd_weight
;
imp
.
pd_weight
=
this
.
pd_weight
;
imp
.
td_nopd_only
=
this
.
td_nopd_only
;
imp
.
td_nopd_only
=
this
.
td_nopd_only
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
7180569b
...
@@ -3538,6 +3538,7 @@ public class OpticalFlow {
...
@@ -3538,6 +3538,7 @@ public class OpticalFlow {
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
.
imp
.
use_lma_dsi
,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -4510,12 +4511,14 @@ public class OpticalFlow {
...
@@ -4510,12 +4511,14 @@ public class OpticalFlow {
final
int
threadsMax
,
// int threadsMax,
final
int
threadsMax
,
// int threadsMax,
final
boolean
updateStatus
,
final
boolean
updateStatus
,
final
int
debugLevel
)
{
final
int
debugLevel
)
{
int
num_scene_retries
=
10
;
int
retry_radius
=
2
;
double
scale_extrap_atr
=
clt_parameters
.
imp
.
scale_extrap_atr
;
double
scale_extrap_atr
=
clt_parameters
.
imp
.
scale_extrap_atr
;
double
scale_extrap_xyz
=
clt_parameters
.
imp
.
scale_extrap_xyz
;
double
scale_extrap_xyz
=
clt_parameters
.
imp
.
scale_extrap_xyz
;
int
avg_len
=
clt_parameters
.
imp
.
avg_len
;
int
avg_len
=
clt_parameters
.
imp
.
avg_len
;
double
maximal_series_rms
=
0.0
;
double
maximal_series_rms
=
0.0
;
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
double
min_ref_frac
=
clt_parameters
.
imp
.
min_ref_frac
;
int
min_num_scenes
=
clt_parameters
.
imp
.
min_num_scenes
;
// abandon series if there are less than this number of scenes in it
int
min_num_scenes
=
clt_parameters
.
imp
.
min_num_scenes
;
// abandon series if there are less than this number of scenes in it
int
max_num_scenes
=
clt_parameters
.
imp
.
max_num_scenes
;
// cut longer series
int
max_num_scenes
=
clt_parameters
.
imp
.
max_num_scenes
;
// cut longer series
...
@@ -4547,10 +4550,17 @@ public class OpticalFlow {
...
@@ -4547,10 +4550,17 @@ public class OpticalFlow {
int
debug_scene
=
-
15
;
int
debug_scene
=
-
15
;
boolean
debug2
=
!
batch_mode
;
// false; // true;
boolean
debug2
=
!
batch_mode
;
// false; // true;
boolean
[]
reliable_ref
=
null
;
boolean
[]
reliable_ref
=
null
;
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
double
[]
reduced_strength
=
new
double
[
1
];
if
(
min_ref_str
>
0.0
)
{
if
(
min_ref_str
>
0.0
)
{
reliable_ref
=
quadCLTs
[
ref_index
].
getReliableTiles
(
// will be null if does not exist.
reliable_ref
=
quadCLTs
[
ref_index
].
getReliableTiles
(
// will be null if does not exist.
min_ref_str
,
// double min_strength,
min_ref_str
,
// double min_strength,
true
);
// boolean needs_lma);
min_ref_frac
,
// double min_ref_frac,
true
,
// boolean needs_lma);
reduced_strength
);
// if not null will return >0 if had to reduce strength (no change if did not reduce)
if
(
reduced_strength
[
0
]
>
0
)
{
use_lma_dsi
=
false
;
// too few points
}
if
(
debug2
)
{
if
(
debug2
)
{
double
[]
dbg_img
=
new
double
[
reliable_ref
.
length
];
double
[]
dbg_img
=
new
double
[
reliable_ref
.
length
];
for
(
int
i
=
0
;
i
<
dbg_img
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
dbg_img
.
length
;
i
++)
{
...
@@ -4565,7 +4575,9 @@ public class OpticalFlow {
...
@@ -4565,7 +4575,9 @@ public class OpticalFlow {
}
}
double
[][][]
scenes_xyzatr
=
new
double
[
quadCLTs
.
length
][][];
// previous scene relative to the next one
double
[][][]
scenes_xyzatr
=
new
double
[
quadCLTs
.
length
][][];
// previous scene relative to the next one
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
boolean
after_spiral
=
false
;
boolean
got_spiral
=
false
;
int
search_rad
=
clt_parameters
.
imp
.
search_rad
;
// 10;
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
earliest_scene
;
scene_index
--)
{
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
earliest_scene
;
scene_index
--)
{
if
((
ref_index
-
scene_index
)
>=
max_num_scenes
){
if
((
ref_index
-
scene_index
)
>=
max_num_scenes
){
earliest_scene
=
scene_index
+
1
;
earliest_scene
=
scene_index
+
1
;
...
@@ -4585,15 +4597,21 @@ public class OpticalFlow {
...
@@ -4585,15 +4597,21 @@ public class OpticalFlow {
QuadCLT
scene_QuadClt
=
quadCLTs
[
scene_index
];
QuadCLT
scene_QuadClt
=
quadCLTs
[
scene_index
];
// get initial xyzatr:
// get initial xyzatr:
// TODO:repeat spiralSearchATR if found scene was too close
// TODO:repeat spiralSearchATR if found scene was too close
// if (scene_index == ref_index - 1) { // search around for the best fit
if
(
scene_index
==
ref_index
-
1
)
{
// search around for the best fit
if
(
!
got_spiral
)
{
// search around for the best fit
use_atr
=
spiralSearchATR
(
use_atr
=
spiralSearchATR
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
use_lma_dsi
,
// may be turned off by the caller if there are too few points
search_rad
,
// int search_rad
quadCLTs
[
ref_index
],
// QuadCLT reference_QuadClt,
quadCLTs
[
ref_index
],
// QuadCLT reference_QuadClt,
scene_QuadClt
,
// QuadCLT scene_QuadClt,
scene_QuadClt
,
// QuadCLT scene_QuadClt,
reliable_ref
,
// ********* boolean [] reliable_ref,
reliable_ref
,
// ********* boolean [] reliable_ref,
debugLevel
);
debugLevel
);
if
(
use_atr
==
null
)
{
if
(
use_atr
==
null
)
{
if
(
num_scene_retries
--
>
0
)
{
search_rad
=
retry_radius
;
// faster, no need/sense to look far
continue
;
}
earliest_scene
=
scene_index
+
1
;
earliest_scene
=
scene_index
+
1
;
if
(
debugLevel
>
-
3
)
{
if
(
debugLevel
>
-
3
)
{
System
.
out
.
println
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
println
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
...
@@ -4602,18 +4620,23 @@ public class OpticalFlow {
...
@@ -4602,18 +4620,23 @@ public class OpticalFlow {
}
}
// set this and all previous to null
// set this and all previous to null
for
(;
scene_index
>=
0
;
scene_index
--)
{
for
(;
scene_index
>=
0
;
scene_index
--)
{
ers_reference
.
addScene
(
quadCLTs
[
scene_index
].
getImageName
(),
null
);
if
(
quadCLTs
[
scene_index
]
==
null
)
{
System
.
out
.
println
(
"setInitialOrientations(): quadCLTs["
+
scene_index
+
"] is alreadu null!"
);
}
else
{
ers_reference
.
addScene
(
quadCLTs
[
scene_index
].
getImageName
(),
null
);
// null pointer
}
}
}
break
;
// failed with even first before reference
break
;
// failed with even first before reference
}
}
after_spiral
=
true
;
got_spiral
=
true
;
scenes_xyzatr
[
scene_index
]
=
new
double
[][]
{
new
double
[
3
],
use_atr
};
scenes_xyzatr
[
scene_index
]
=
new
double
[][]
{
new
double
[
3
],
use_atr
};
}
else
{
// assume linear motion
}
else
{
// assume linear motion
after_spiral
=
false
;
if
(
scene_index
==
debug_scene
)
{
if
(
scene_index
==
debug_scene
)
{
System
.
out
.
println
(
"adjusting orientation, scene_index="
+
scene_index
);
System
.
out
.
println
(
"adjusting orientation, scene_index="
+
scene_index
);
System
.
out
.
println
(
"adjusting orientation, scene_index="
+
scene_index
);
System
.
out
.
println
(
"adjusting orientation, scene_index="
+
scene_index
);
}
}
// int avg_len = 1; // 3;
// double scale_xyz = 0.0; // 0.5;
int
na
=
avg_len
;
int
na
=
avg_len
;
if
((
scene_index
+
1
+
na
)
>
ref_index
)
{
if
((
scene_index
+
1
+
na
)
>
ref_index
)
{
na
=
ref_index
-
(
scene_index
+
1
);
na
=
ref_index
-
(
scene_index
+
1
);
...
@@ -4635,8 +4658,14 @@ public class OpticalFlow {
...
@@ -4635,8 +4658,14 @@ public class OpticalFlow {
last_diff
);
last_diff
);
}
}
// Refine with LMA
// Refine with LMA
double
[][]
initial_pose
=
new
double
[][]{
scenes_xyzatr
[
scene_index
][
0
].
clone
(),
scenes_xyzatr
[
scene_index
][
1
].
clone
()};
boolean
rot_to_transl
=
after_spiral
&&
clt_parameters
.
ilp
.
ilma_translation_priority
;
double
[]
reg_weights
=
rot_to_transl
?
clt_parameters
.
ilp
.
ilma_regularization_weights0
:
clt_parameters
.
ilp
.
ilma_regularization_weights
;
scenes_xyzatr
[
scene_index
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
scene_index
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
use_lma_dsi
,
// clt_parameters.imp.use_lma_dsi,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
min_max
,
// double [] min_max, // null or pair of minimal and maximal offsets
min_max
,
// double [] min_max, // null or pair of minimal and maximal offsets
fail_reason
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
fail_reason
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -4644,12 +4673,12 @@ public class OpticalFlow {
...
@@ -4644,12 +4673,12 @@ public class OpticalFlow {
null
,
// double [] ref_disparity, // null or alternative reference disparity
null
,
// double [] ref_disparity, // null or alternative reference disparity
reliable_ref
,
// boolean [] reliable_ref, // null or bitmask of reliable reference tiles
reliable_ref
,
// boolean [] reliable_ref, // null or bitmask of reliable reference tiles
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
scene_QuadClt
,
// QuadCLT scene_QuadCLT,
scenes_xyzatr
[
scene_index
]
[
0
],
// xyz
initial_pose
[
0
],
// xyz
scenes_xyzatr
[
scene_index
]
[
1
],
// atr
initial_pose
[
1
],
// atr
scenes_xyzatr
[
scene_index
]
[
0
],
// double [] scene_xyz_pull, // if both are not null, specify target values to pull to
initial_pose
[
0
],
// double [] scene_xyz_pull, // if both are not null, specify target values to pull to
scenes_xyzatr
[
scene_index
]
[
1
],
// double [] scene_atr_pull, //
rot_to_transl
?
(
new
double
[
3
]):
initial_pose
[
1
],
// double [] scene_atr_pull, //
clt_parameters
.
ilp
.
ilma_lma_select
,
// final boolean[] param_select,
clt_parameters
.
ilp
.
ilma_lma_select
,
// final boolean[] param_select,
clt_parameters
.
ilp
.
ilma_regularization_weights
,
// final double [] param_regweights,
reg_weights
,
//
clt_parameters.ilp.ilma_regularization_weights, // final double [] param_regweights,
lma_rms
,
// double [] rms, // null or double [2]
lma_rms
,
// double [] rms, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
clt_parameters
.
imp
.
debug_level
);
// 1); // -1); // int debug_level);
...
@@ -4660,13 +4689,15 @@ public class OpticalFlow {
...
@@ -4660,13 +4689,15 @@ public class OpticalFlow {
adjust_OK
=
false
;
adjust_OK
=
false
;
}
}
// FAIL_REASON_ROLL
// FAIL_REASON_ROLL
handle_failure:
{
if
(!
adjust_OK
)
{
if
(!
adjust_OK
)
{
boolean
OK
=
false
;
//
boolean OK = false;
System
.
out
.
println
(
"LMA failed at nscene = "
+
scene_index
+
". Reason = "
+
fail_reason
[
0
]);
System
.
out
.
println
(
"LMA failed at nscene = "
+
scene_index
+
". Reason = "
+
fail_reason
[
0
]);
if
(
fail_reason
[
0
]==
FAIL_REASON_MIN
)
{
if
((
fail_reason
[
0
]==
FAIL_REASON_MIN
)
||
((
fail_reason
[
0
]==
FAIL_REASON_LMA
)
&&
!
got_spiral
)
)
{
if
(
fpn_skip
)
{
if
(
fpn_skip
)
{
System
.
out
.
println
(
"fpn_skip is set, just skipping this scene"
);
System
.
out
.
println
(
"fpn_skip is set, just using initial pose"
);
continue
;
// to next scene
scenes_xyzatr
[
scene_index
]
=
initial_pose
;
break
handle_failure
;
// to next scene
}
else
{
}
else
{
System
.
out
.
println
(
"fpn_skip is not set, aborting series and adjusting earliest_scene"
);
System
.
out
.
println
(
"fpn_skip is not set, aborting series and adjusting earliest_scene"
);
// set this and all previous to null
// set this and all previous to null
...
@@ -4682,10 +4713,30 @@ public class OpticalFlow {
...
@@ -4682,10 +4713,30 @@ public class OpticalFlow {
// set this and all previous to null
// set this and all previous to null
for
(;
scene_index
>=
0
;
scene_index
--)
{
for
(;
scene_index
>=
0
;
scene_index
--)
{
ers_reference
.
addScene
(
quadCLTs
[
scene_index
].
getImageName
(),
null
);
ers_reference
.
addScene
(
quadCLTs
[
scene_index
].
getImageName
(),
null
);
// quadCLTs[scene_index] = null; // completely remove early scenes?
// quadCLTs[scene_index] = null; // completely remove early scenes?
}
}
break
;
break
;
}
}
}
if
(
after_spiral
&&
(
scene_index
<
(
ref_index
-
1
)))
{
// need to interpolate skipped scenes
// here we expect very small translations/angles, so linear scaling is OK
double
s
=
1.0
/
(
ref_index
-
scene_index
);
for
(
int
interp_index
=
ref_index
-
1
;
interp_index
>
scene_index
;
interp_index
--)
{
scenes_xyzatr
[
interp_index
]
=
new
double
[
2
][
3
];
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
scenes_xyzatr
[
interp_index
][
i
][
j
]
=
scenes_xyzatr
[
scene_index
][
i
][
j
]
*
s
*(
interp_index
-
scene_index
);
}
}
ers_reference
.
addScene
(
scene_QuadClt
.
getImageName
(),
scenes_xyzatr
[
interp_index
][
0
],
scenes_xyzatr
[
interp_index
][
1
],
ZERO3
,
// ers_scene.getErsXYZ_dt(),
ZERO3
// ers_scene.getErsATR_dt()
);
}
}
/* old version
/* old version
if (scenes_xyzatr[scene_index] == null) {
if (scenes_xyzatr[scene_index] == null) {
...
@@ -4875,6 +4926,7 @@ public class OpticalFlow {
...
@@ -4875,6 +4926,7 @@ public class OpticalFlow {
int
test_ers1
=
clt_parameters
.
imp
.
test_ers1
;
// try adjusting a pair of scenes with ERS. Other scene index
int
test_ers1
=
clt_parameters
.
imp
.
test_ers1
;
// try adjusting a pair of scenes with ERS. Other scene index
test_ers
&=
(
test_ers0
>=
0
)
&&
(
test_ers1
>=
0
);
test_ers
&=
(
test_ers0
>=
0
)
&&
(
test_ers1
>=
0
);
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
double
min_ref_frac
=
clt_parameters
.
imp
.
min_ref_frac
;
double
[]
ref_blue_sky
=
null
;
// turn off "lma" in the ML output
double
[]
ref_blue_sky
=
null
;
// turn off "lma" in the ML output
if
(
reuse_video
)
{
// disable all other options
if
(
reuse_video
)
{
// disable all other options
generate_mapped
=
false
;
generate_mapped
=
false
;
...
@@ -5106,14 +5158,20 @@ public class OpticalFlow {
...
@@ -5106,14 +5158,20 @@ public class OpticalFlow {
null
,
// String path, // full name with extension or w/o path to use x3d directory
null
,
// String path, // full name with extension or w/o path to use x3d directory
debugLevel
+
1
);
debugLevel
+
1
);
}
}
double
[]
reduced_strength
=
new
double
[
1
];
// boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
if
(
quadCLTs
[
ref_index
].
getNumOrient
()
<
min_num_orient
)
{
if
(
quadCLTs
[
ref_index
].
getNumOrient
()
<
min_num_orient
)
{
boolean
[]
reliable_ref
=
null
;
boolean
[]
reliable_ref
=
null
;
if
(
min_ref_str
>
0.0
)
{
if
(
min_ref_str
>
0.0
)
{
reliable_ref
=
quadCLTs
[
ref_index
].
getReliableTiles
(
// will be null if does not exist.
reliable_ref
=
quadCLTs
[
ref_index
].
getReliableTiles
(
// will be null if does not exist.
min_ref_str
,
// double min_strength,
min_ref_str
,
// double min_strength,
true
);
// boolean needs_lma);
min_ref_frac
,
// double min_ref_frac,
true
,
// boolean needs_lma);
reduced_strength
);
// if not null will return >0 if had to reduce strength (no change if did not reduce)
}
}
// if (reduced_strength[0] > 0) {
// use_lma_dsi = false; // too few points
// }
// on last pass use final max MB correction same as for render (mb_max_gain - typical =5.0),
// on last pass use final max MB correction same as for render (mb_max_gain - typical =5.0),
// for earlier - mb_max_gain_inter (which may be smaller - typical = 2.0)
// for earlier - mb_max_gain_inter (which may be smaller - typical = 2.0)
double
mb_max_gain
=
clt_parameters
.
imp
.
mb_max_gain
;
double
mb_max_gain
=
clt_parameters
.
imp
.
mb_max_gain
;
...
@@ -6624,6 +6682,7 @@ public class OpticalFlow {
...
@@ -6624,6 +6682,7 @@ public class OpticalFlow {
double
[][]
adjusted_xyzatr
=
adjustPairsLMAInterscene
(
double
[][]
adjusted_xyzatr
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
.
imp
.
use_lma_dsi
,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -6784,7 +6843,7 @@ public class OpticalFlow {
...
@@ -6784,7 +6843,7 @@ public class OpticalFlow {
public
static
ImagePlus
renderSceneSequence
(
public
static
ImagePlus
renderSceneSequence
(
CLTParameters
clt_parameters
,
CLTParameters
clt_parameters
,
Rectangle
fov_tiles
,
Rectangle
fov_tiles
,
int
mode3d
,
int
mode3d
,
// for older compatibility mode3d = -1 for RAW, 0 - INF, 1 - FG, 2 BG
boolean
toRGB
,
boolean
toRGB
,
double
[]
stereo_xyz
,
// offset reference camera {x,y,z}
double
[]
stereo_xyz
,
// offset reference camera {x,y,z}
int
sensor_mask
,
int
sensor_mask
,
...
@@ -7014,6 +7073,8 @@ public class OpticalFlow {
...
@@ -7014,6 +7073,8 @@ public class OpticalFlow {
public
static
double
[]
spiralSearchATR
(
public
static
double
[]
spiralSearchATR
(
CLTParameters
clt_parameters
,
CLTParameters
clt_parameters
,
boolean
use_lma_dsi
,
// may be turned off by the caller if there are too few points
int
search_rad
,
// to reduce for the next scenes on failure (FPN filter)
QuadCLT
reference_QuadClt
,
QuadCLT
reference_QuadClt
,
QuadCLT
scene_QuadClt
,
QuadCLT
scene_QuadClt
,
boolean
[]
reliable_ref
,
boolean
[]
reliable_ref
,
...
@@ -7027,7 +7088,7 @@ public class OpticalFlow {
...
@@ -7027,7 +7088,7 @@ public class OpticalFlow {
int
sensor_mask_inter
=
clt_parameters
.
imp
.
sensor_mask_inter
;
//-1;
int
sensor_mask_inter
=
clt_parameters
.
imp
.
sensor_mask_inter
;
//-1;
float
[][][]
facc_2d_img
=
new
float
[
1
][][];
float
[][][]
facc_2d_img
=
new
float
[
1
][][];
int
pix_step
=
clt_parameters
.
imp
.
pix_step
;
// 4;
int
pix_step
=
clt_parameters
.
imp
.
pix_step
;
// 4;
int
search_rad
=
clt_parameters
.
imp
.
search_rad
;
// 10;
//
int search_rad = clt_parameters.imp.search_rad; // 10;
double
maybe_sum
=
clt_parameters
.
imp
.
maybe_sum
;
// 8.0;
double
maybe_sum
=
clt_parameters
.
imp
.
maybe_sum
;
// 8.0;
double
sure_sum
=
clt_parameters
.
imp
.
sure_sum
;
// 30.0;
double
sure_sum
=
clt_parameters
.
imp
.
sure_sum
;
// 30.0;
double
maybe_avg
=
clt_parameters
.
imp
.
maybe_avg
;
// 0.005;
double
maybe_avg
=
clt_parameters
.
imp
.
maybe_avg
;
// 0.005;
...
@@ -7038,7 +7099,7 @@ public class OpticalFlow {
...
@@ -7038,7 +7099,7 @@ public class OpticalFlow {
double
sure_fom
=
clt_parameters
.
imp
.
sure_fom
;
// 10.0; // good - 30, second good - 10
double
sure_fom
=
clt_parameters
.
imp
.
sure_fom
;
// 10.0; // good - 30, second good - 10
boolean
treat_serch_fpn
=
clt_parameters
.
imp
.
treat_serch_fpn
;
// use FPN (higher) thresholds during search (even if offset is not small)
boolean
treat_serch_fpn
=
clt_parameters
.
imp
.
treat_serch_fpn
;
// use FPN (higher) thresholds during search (even if offset is not small)
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
//
boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
double
[][]
pose
=
new
double
[
2
][
3
];
double
[][]
pose
=
new
double
[
2
][
3
];
double
angle_per_step
=
reference_QuadClt
.
getGeometryCorrection
().
getCorrVector
().
getTiltAzPerPixel
()
*
pix_step
;
double
angle_per_step
=
reference_QuadClt
.
getGeometryCorrection
().
getCorrVector
().
getTiltAzPerPixel
()
*
pix_step
;
...
@@ -7374,6 +7435,7 @@ public class OpticalFlow {
...
@@ -7374,6 +7435,7 @@ public class OpticalFlow {
if
(
high_res_motion_vectors
)
{
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
.
imp
.
use_lma_dsi
,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -7487,6 +7549,7 @@ public class OpticalFlow {
...
@@ -7487,6 +7549,7 @@ public class OpticalFlow {
if
(
high_res_motion_vectors
)
{
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
.
imp
.
use_lma_dsi
,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -7632,6 +7695,7 @@ public class OpticalFlow {
...
@@ -7632,6 +7695,7 @@ public class OpticalFlow {
if
(
high_res_motion_vectors
)
{
if
(
high_res_motion_vectors
)
{
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
scenes_xyzatr
[
i
]
=
adjustPairsLMAInterscene
(
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
,
// CLTParameters clt_parameters,
clt_parameters
.
imp
.
use_lma_dsi
,
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
false
,
// boolean fpn_disable, // disable fpn filter if images are known to be too close
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// double [] min_max, // null or pair of minimal and maximal offsets
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
null
,
// int [] fail_reason, // null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -12750,8 +12814,20 @@ public class OpticalFlow {
...
@@ -12750,8 +12814,20 @@ public class OpticalFlow {
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
+
1
]};
disparity_map
[
ImageDtt
.
DISPARITY_INDEX_CM
+
1
]};
}
}
// remove disparity average, only detect tilts
// remove disparity average, only detect tilts
if
(
use3D_lma_tilt_only
)
{
double
average_disparity
=
0
;
double
average_absolute_disparity
=
0
;
{
double
sw
=
0
,
swd
=
0
;
double
sw
=
0
,
swd
=
0
;
for
(
int
i
=
0
;
i
<
scene_pXpYD
.
length
;
i
++)
{
if
((
scene_pXpYD
[
i
]!=
null
)
&&
!
Double
.
isNaN
(
scene_pXpYD
[
i
][
2
]))
{
sw
+=
1.0
;
swd
+=
scene_pXpYD
[
i
][
2
];
}
}
average_absolute_disparity
=
swd
/
sw
;
// remove average disparity and multiply by average disparity to have the same influence ratio to tild
sw
=
0
;
swd
=
0
;
for
(
int
i
=
0
;
i
<
scene_disparity_strength
[
0
].
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
scene_disparity_strength
[
0
].
length
;
i
++)
{
if
(
Double
.
isNaN
(
scene_disparity_strength
[
0
][
i
])
||
Double
.
isNaN
(
scene_disparity_strength
[
1
][
i
]))
{
if
(
Double
.
isNaN
(
scene_disparity_strength
[
0
][
i
])
||
Double
.
isNaN
(
scene_disparity_strength
[
1
][
i
]))
{
scene_disparity_strength
[
0
][
i
]=
0
;
scene_disparity_strength
[
0
][
i
]=
0
;
...
@@ -12760,9 +12836,12 @@ public class OpticalFlow {
...
@@ -12760,9 +12836,12 @@ public class OpticalFlow {
sw
+=
scene_disparity_strength
[
1
][
i
];
sw
+=
scene_disparity_strength
[
1
][
i
];
swd
+=
scene_disparity_strength
[
0
][
i
]
*
scene_disparity_strength
[
1
][
i
];
swd
+=
scene_disparity_strength
[
0
][
i
]
*
scene_disparity_strength
[
1
][
i
];
}
}
double
avg
=
swd
/
sw
;
average_disparity
=
swd
/
sw
;
double
magic_scale
=
use3D_lma
?
1.0
:
ref_scene
.
getTileProcessor
().
getMagicScale
();
for
(
int
i
=
0
;
i
<
scene_disparity_strength
[
0
].
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
scene_disparity_strength
[
0
].
length
;
i
++)
{
scene_disparity_strength
[
0
][
i
]
-=
avg
;
// scene_disparity_strength[0][i] = (scene_disparity_strength[0][i] - average_disparity) / average_absolute_disparity;
scene_disparity_strength
[
0
][
i
]
=
(
scene_disparity_strength
[
0
][
i
]
-
average_disparity
)
/
magic_scale
;
scene_disparity_strength
[
0
][
i
]
=
1.0
/
average_absolute_disparity
;
}
}
}
}
}
}
...
@@ -14094,7 +14173,7 @@ public class OpticalFlow {
...
@@ -14094,7 +14173,7 @@ public class OpticalFlow {
double
mb_tau
=
clt_parameters
.
imp
.
mb_tau
;
// 0.008; // time constant, sec
double
mb_tau
=
clt_parameters
.
imp
.
mb_tau
;
// 0.008; // time constant, sec
// double mb_max_gain = clt_parameters.imp.mb_max_gain_inter; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
// double mb_max_gain = clt_parameters.imp.mb_max_gain_inter; // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
int
margin
=
clt_parameters
.
imp
.
margin
;
int
margin
=
clt_parameters
.
imp
.
margin
;
double
second_margin
=
1.1
;
// allow slightly larger offset for readjsutments (to be limited by the first pass)
int
earliest_scene
=
0
;
int
earliest_scene
=
0
;
boolean
use_combo_dsi
=
clt_parameters
.
imp
.
use_combo_dsi
;
boolean
use_combo_dsi
=
clt_parameters
.
imp
.
use_combo_dsi
;
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
...
@@ -14103,7 +14182,7 @@ public class OpticalFlow {
...
@@ -14103,7 +14182,7 @@ public class OpticalFlow {
int
tilesY
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesY
();
int
tilesY
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesY
();
int
tile_size
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTileSize
();
int
tile_size
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTileSize
();
double
min_offset
=
clt_parameters
.
imp
.
min_offset
;
double
min_offset
=
clt_parameters
.
imp
.
min_offset
;
double
max_offset
=
clt_parameters
.
imp
.
max_rel_offset
*
tilesX
*
tile_size
;
double
max_offset
=
second_margin
*
clt_parameters
.
imp
.
max_rel_offset
*
tilesX
*
tile_size
;
double
max_roll
=
clt_parameters
.
imp
.
max_roll_deg
*
Math
.
PI
/
180.0
;
double
max_roll
=
clt_parameters
.
imp
.
max_roll_deg
*
Math
.
PI
/
180.0
;
boolean
fpn_skip
=
clt_parameters
.
imp
.
fpn_skip
;
// if false - fail as before
boolean
fpn_skip
=
clt_parameters
.
imp
.
fpn_skip
;
// if false - fail as before
boolean
fpn_rematch
=
clt_parameters
.
imp
.
fpn_rematch
;
// if false - keep previous
boolean
fpn_rematch
=
clt_parameters
.
imp
.
fpn_rematch
;
// if false - keep previous
...
@@ -14168,7 +14247,7 @@ public class OpticalFlow {
...
@@ -14168,7 +14247,7 @@ public class OpticalFlow {
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
scenes_xyzatr
[
ref_index
]
=
new
double
[
2
][
3
];
// all zeros
// should have at least next or previous non-null
// should have at least next or previous non-null
int
debug_scene
=
-
15
;
int
debug_scene
=
-
8
;
double
maximal_series_rms
=
0.0
;
double
maximal_series_rms
=
0.0
;
double
[][]
mb_vectors_ref
=
null
;
double
[][]
mb_vectors_ref
=
null
;
TpTask
[][]
tp_tasks_ref
=
null
;
TpTask
[][]
tp_tasks_ref
=
null
;
...
@@ -14218,7 +14297,8 @@ public class OpticalFlow {
...
@@ -14218,7 +14297,8 @@ public class OpticalFlow {
}
}
System
.
out
.
println
();
System
.
out
.
println
();
}
}
boolean
[]
failed_scenes
=
new
boolean
[
quadCLTs
.
length
];
int
num_failed
=
0
;
for
(
int
nscene
=
ref_index
;
nscene
>=
earliest_scene
;
nscene
--)
{
for
(
int
nscene
=
ref_index
;
nscene
>=
earliest_scene
;
nscene
--)
{
if
(
nscene
==
debug_scene
)
{
if
(
nscene
==
debug_scene
)
{
System
.
out
.
println
(
"nscene = "
+
nscene
);
System
.
out
.
println
(
"nscene = "
+
nscene
);
...
@@ -14251,8 +14331,8 @@ public class OpticalFlow {
...
@@ -14251,8 +14331,8 @@ public class OpticalFlow {
if
(
dbg_mb_img
!=
null
)
{
if
(
dbg_mb_img
!=
null
)
{
boolean
show_corrected
=
false
;
boolean
show_corrected
=
false
;
if
(
nscene
==
debug_scene
)
{
if
(
nscene
==
debug_scene
)
{
System
.
out
.
println
(
"nscene = "
+
nscene
);
System
.
out
.
println
(
"
2.
nscene = "
+
nscene
);
System
.
out
.
println
(
"nscene = "
+
nscene
);
System
.
out
.
println
(
"
3.
nscene = "
+
nscene
);
}
}
dbg_mb_img
[
nscene
]
=
new
double
[
tilesX
*
tilesY
*
2
];
dbg_mb_img
[
nscene
]
=
new
double
[
tilesX
*
tilesY
*
2
];
Arrays
.
fill
(
dbg_mb_img
[
nscene
],
Double
.
NaN
);
Arrays
.
fill
(
dbg_mb_img
[
nscene
],
Double
.
NaN
);
...
@@ -14442,13 +14522,21 @@ public class OpticalFlow {
...
@@ -14442,13 +14522,21 @@ public class OpticalFlow {
adjust_OK
=
false
;
adjust_OK
=
false
;
}
}
// FAIL_REASON_ROLL
// FAIL_REASON_ROLL
handle_failure:
{
if
(!
adjust_OK
)
{
if
(!
adjust_OK
)
{
boolean
OK
=
false
;
boolean
OK
=
false
;
System
.
out
.
println
(
"LMA failed at nscene = "
+
nscene
+
". Reason = "
+
fail_reason
[
0
]);
System
.
out
.
println
(
"LMA failed at nscene = "
+
nscene
+
". Reason = "
+
fail_reason
[
0
]);
if
(
fail_reason
[
0
]==
FAIL_REASON_MIN
)
{
if
((
fail_reason
[
0
]==
FAIL_REASON_MIN
)
||
((
fail_reason
[
0
]==
FAIL_REASON_LMA
))
)
{
if
(
fpn_skip
)
{
if
(
fpn_skip
)
{
System
.
out
.
println
(
"fpn_skip is set, just skipping this scene"
);
System
.
out
.
println
(
"fpn_skip is set, just skipping this scene"
);
continue
;
// to next scene
failed_scenes
[
nscene
]
=
true
;
num_failed
++;
scenes_xyzatr
[
nscene
]
=
new
double
[][]
{
scene_xyz_pre
,
// for now restore original, pre-adjustment
scene_atr_pre
// for now restore original, pre-adjustment
};
break
handle_failure
;
// continue; // to next scene
}
else
{
}
else
{
System
.
out
.
println
(
"fpn_skip is not set, aborting series and adjusting earliest_scene"
);
System
.
out
.
println
(
"fpn_skip is not set, aborting series and adjusting earliest_scene"
);
// set this and all previous to null
// set this and all previous to null
...
@@ -14468,6 +14556,7 @@ public class OpticalFlow {
...
@@ -14468,6 +14556,7 @@ public class OpticalFlow {
}
}
break
;
break
;
}
}
}
// overwrite old data
// overwrite old data
ers_reference
.
addScene
(
ts
,
ers_reference
.
addScene
(
ts
,
scenes_xyzatr
[
nscene
][
0
],
scenes_xyzatr
[
nscene
][
0
],
...
@@ -14741,6 +14830,7 @@ public class OpticalFlow {
...
@@ -14741,6 +14830,7 @@ public class OpticalFlow {
public
static
double
[][]
adjustPairsLMAInterscene
(
public
static
double
[][]
adjustPairsLMAInterscene
(
CLTParameters
clt_parameters
,
CLTParameters
clt_parameters
,
boolean
use_lma_dsi
,
boolean
fpn_disable
,
// disable fpn filter if images are known to be too close
boolean
fpn_disable
,
// disable fpn filter if images are known to be too close
double
[]
min_max
,
// null or pair of minimal and maximal offsets
double
[]
min_max
,
// null or pair of minimal and maximal offsets
int
[]
fail_reason
,
// null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
int
[]
fail_reason
,
// null or int[1]: 0 - OK, 1 - LMA, 2 - min, 3 - max
...
@@ -14758,7 +14848,7 @@ public class OpticalFlow {
...
@@ -14758,7 +14848,7 @@ public class OpticalFlow {
double
max_rms
,
double
max_rms
,
int
debug_level
)
int
debug_level
)
{
{
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
//
boolean use_lma_dsi = clt_parameters.imp.use_lma_dsi;
if
(
ref_disparity
==
null
)
{
if
(
ref_disparity
==
null
)
{
ref_disparity
=
reference_QuadClt
.
getDLS
()[
use_lma_dsi
?
1
:
0
];
ref_disparity
=
reference_QuadClt
.
getDLS
()[
use_lma_dsi
?
1
:
0
];
}
}
...
@@ -14925,10 +15015,11 @@ public class OpticalFlow {
...
@@ -14925,10 +15015,11 @@ public class OpticalFlow {
}
}
}
}
if
(
show_corr_fpn
&&
(
debug_level
>
-
1
))
{
// now not needed, restore if needed
if
(
show_corr_fpn
&&
(
debug_level
>
-
1
))
{
// now not needed, restore if needed
int
num_components
=
intersceneLma
.
getNumComponents
();
// int num_components = intersceneLma.getNumComponents();
int
num_components
=
2
;
String
[]
fpn_dbg_titles
=
new
String
[
num_components
+
scene_QuadClt
.
getNumSensors
()
*
2
];
String
[]
fpn_dbg_titles
=
new
String
[
num_components
+
scene_QuadClt
.
getNumSensors
()
*
2
];
fpn_dbg_titles
[
0
]
=
"X_avg"
;
fpn_dbg_titles
[
0
]
=
"X_avg"
;
fpn_dbg_titles
[
1
]
=
"
X
_avg"
;
fpn_dbg_titles
[
1
]
=
"
Y
_avg"
;
if
(
num_components
>
2
)
{
if
(
num_components
>
2
)
{
fpn_dbg_titles
[
2
]
=
"Disp"
;
fpn_dbg_titles
[
2
]
=
"Disp"
;
}
}
...
@@ -14974,12 +15065,17 @@ public class OpticalFlow {
...
@@ -14974,12 +15065,17 @@ public class OpticalFlow {
fpn_dbg_titles
);
fpn_dbg_titles
);
}
}
if
(
show_corr_fpn
)
{
// repeat after last adjustment to get images
if
(
show_corr_fpn
)
{
// repeat after last adjustment to get images
String
[]
fpn_dbg_titles
=
new
String
[
2
+
scene_QuadClt
.
getNumSensors
()
*
2
];
// int num_components = intersceneLma.getNumComponents();
fpn_dbg_titles
[
00
]
=
"X_avg"
;
int
num_components
=
2
;
// herte - no disparity
fpn_dbg_titles
[
1
]
=
"X_avg"
;
String
[]
fpn_dbg_titles
=
new
String
[
num_components
+
scene_QuadClt
.
getNumSensors
()
*
2
];
fpn_dbg_titles
[
0
]
=
"X_avg"
;
fpn_dbg_titles
[
1
]
=
"Y_avg"
;
if
(
num_components
>
2
)
{
fpn_dbg_titles
[
2
]
=
"Disp"
;
}
for
(
int
i
=
0
;
i
<
scene_QuadClt
.
getNumSensors
();
i
++)
{
for
(
int
i
=
0
;
i
<
scene_QuadClt
.
getNumSensors
();
i
++)
{
fpn_dbg_titles
[
2
+
2
*
i
]
=
"X-"
+
i
;
fpn_dbg_titles
[
num_components
+
0
+
2
*
i
]
=
"X-"
+
i
;
fpn_dbg_titles
[
3
+
2
*
i
]
=
"Y-"
+
i
;
fpn_dbg_titles
[
num_components
+
1
+
2
*
i
]
=
"Y-"
+
i
;
}
}
float
[][]
dbg_corr_fpn
=
new
float
[
fpn_dbg_titles
.
length
][];
float
[][]
dbg_corr_fpn
=
new
float
[
fpn_dbg_titles
.
length
][];
coord_motion
=
interCorrPair
(
// new double [tilesY][tilesX][][];
coord_motion
=
interCorrPair
(
// new double [tilesY][tilesX][][];
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
7180569b
...
@@ -1363,10 +1363,14 @@ public class QuadCLTCPU {
...
@@ -1363,10 +1363,14 @@ public class QuadCLTCPU {
dsi
,
dsi
,
silent
);
silent
);
}
}
//min_ref_frac
public
boolean
[]
getReliableTiles
(
public
boolean
[]
getReliableTiles
(
double
min_strength
,
double
min_strength
,
boolean
needs_lma
)
{
double
min_ref_frac
,
boolean
needs_lma
,
double
[]
reduced_strength
// if not null will return >0 if had to reduce strength (no change if did not reduce)
)
{
int
NUM_BINS
=
1024
;
double
[][]
main_dsi
=
readDsiMain
();
double
[][]
main_dsi
=
readDsiMain
();
if
(
main_dsi
==
null
)
{
if
(
main_dsi
==
null
)
{
return
null
;
return
null
;
...
@@ -1376,6 +1380,9 @@ public class QuadCLTCPU {
...
@@ -1376,6 +1380,9 @@ public class QuadCLTCPU {
if
((
strength
==
null
)
||
(
needs_lma
&&
(
disparity_lma
==
null
)
))
{
if
((
strength
==
null
)
||
(
needs_lma
&&
(
disparity_lma
==
null
)
))
{
return
null
;
return
null
;
}
}
int
min_reliable
=
(
int
)
Math
.
round
(
strength
.
length
*
min_ref_frac
);
strength
=
strength
.
clone
();
boolean
[]
reliable
=
new
boolean
[
strength
.
length
];
boolean
[]
reliable
=
new
boolean
[
strength
.
length
];
for
(
int
i
=
0
;
i
<
reliable
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
reliable
.
length
;
i
++)
{
reliable
[
i
]
=
(
strength
[
i
]
>=
min_strength
)
&&
reliable
[
i
]
=
(
strength
[
i
]
>=
min_strength
)
&&
...
@@ -1384,11 +1391,50 @@ public class QuadCLTCPU {
...
@@ -1384,11 +1391,50 @@ public class QuadCLTCPU {
boolean
[]
blue_sky
=
getBooleanBlueSky
();
boolean
[]
blue_sky
=
getBooleanBlueSky
();
if
(
blue_sky
!=
null
)
{
if
(
blue_sky
!=
null
)
{
for
(
int
i
=
0
;
i
<
reliable
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
reliable
.
length
;
i
++)
{
reliable
[
i
]
&=
!
blue_sky
[
i
];
if
(
blue_sky
[
i
]){
reliable
[
i
]
=
false
;
strength
[
i
]
=
0.0
;
}
}
}
int
num_reliable
=
0
;
for
(
boolean
b:
reliable
)
if
(
b
)
num_reliable
++;
if
(
num_reliable
<
min_reliable
)
{
// not enough, select best tiles, ignoring LMA
double
max_str
=
0
;
for
(
double
s:
strength
)
if
((
s
>
max_str
)
)
max_str
=
s
;
// NaN OK
if
(
max_str
==
0
)
return
null
;
int
[]
hist
=
new
int
[
NUM_BINS
];
int
num_gt0
=
0
;
for
(
double
s:
strength
)
if
(
s
>
0
)
{
// verify enough > 0
int
bin
=
(
int
)
Math
.
floor
(
NUM_BINS
*
s
/
max_str
);
if
(
bin
>=
NUM_BINS
)
bin
=
NUM_BINS
-
1
;
hist
[
bin
]++;
num_gt0
++;
}
if
(
num_gt0
<
min_reliable
)
{
return
null
;
// not enough non-zero values
}
num_reliable
=
0
;
int
num_prev
=
0
;
int
bin
=
NUM_BINS
-
1
;
for
(;
num_reliable
<
min_reliable
;
bin
--)
{
num_prev
=
num_reliable
;
num_reliable
+=
hist
[
bin
];
}
double
threshold
=
(
bin
+
1.0
*
(
num_reliable
-
min_reliable
)
/
(
num_reliable
-
num_prev
))
*
max_str
/
NUM_BINS
;
num_reliable
=
0
;
for
(
int
i
=
0
;
i
<
reliable
.
length
;
i
++)
{
reliable
[
i
]
=
(
strength
[
i
]
>
threshold
);
if
(
reliable
[
i
])
num_reliable
++;
}
if
(
reduced_strength
!=
null
)
{
reduced_strength
[
0
]
=
threshold
;
}
}
}
}
return
reliable
;
return
reliable
;
}
}
public
double
[][]
readDsiMain
(){
public
double
[][]
readDsiMain
(){
double
[][]
main_dsi
=
new
double
[
TwoQuadCLT
.
DSI_SLICES
.
length
][];
double
[][]
main_dsi
=
new
double
[
TwoQuadCLT
.
DSI_SLICES
.
length
][];
int
slices
=
restoreDSI
(
int
slices
=
restoreDSI
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment