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
c8d3d7d9
Commit
c8d3d7d9
authored
Jun 19, 2024
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up with eigen, adding debug image generation for LMA
parent
477343de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
333 additions
and
58 deletions
+333
-58
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+2
-2
Interscene.java
...main/java/com/elphel/imagej/tileprocessor/Interscene.java
+172
-33
IntersceneLma.java
...n/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
+143
-19
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+16
-4
No files found.
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
c8d3d7d9
...
...
@@ -2351,6 +2351,7 @@ public class ImageDtt extends ImageDttCPU {
final
boolean
td_nopd_only
,
// only use TD accumulated data if no safe PD is available for the tile.
final
boolean
eig_use_neibs
,
// use correlation from 9 tiles with neibs, if single-tile fails
final
boolean
eig_remove_neibs
,
//remove weak (by-neibs) tiles if they have strong (by-single) neighbor
final
boolean
eig_filt_other
,
// apply other before-eigen filters
// final double min_str_nofpn, // = 0.25;
final
double
eig_str_sum_nofpn
,
// = 0.8; // 5;
final
double
eig_str_neib_nofpn
,
// = 0.8; // 5;
...
...
@@ -2720,10 +2721,9 @@ public class ImageDtt extends ImageDttCPU {
}
startAndJoin
(
threads
);
}
boolean
old_filter
=
false
;
// true;
// Reduce weight if differs much from average of 8 neighbors, large disparity, remove too few neibs
final
double
scale_num_neib
=
((
weight_zero_neibs
>=
0
)
&&
(
weight_zero_neibs
<
1.0
))
?
(
weight_zero_neibs
*
8
/(
1.0
-
weight_zero_neibs
)):
0.0
;
if
(
old_filt
er
)
{
if
(
eig_filt_oth
er
)
{
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/Interscene.java
View file @
c8d3d7d9
...
...
@@ -495,6 +495,7 @@ public class Interscene {
false
);
// boolean use_ERS_roll);
RMSEStats
rmse_stats
=
new
RMSEStats
();
RMSEStats
rmse_stats_metric
=
clt_parameters
.
imp
.
eig_use
?
(
new
RMSEStats
()):
null
;
double
[][][]
scenes_xyzatr
=
new
double
[
last_index
+
1
][][];
double
[][][]
dxyzatr_dt
=
new
double
[
last_index
+
1
][][];
for
(
int
nscene
=
earliest_index
;
nscene
<=
ref_index
;
nscene
++)
{
...
...
@@ -533,7 +534,7 @@ public class Interscene {
boolean
use_lma_dsi
=
clt_parameters
.
imp
.
use_lma_dsi
;
double
[]
reduced_strength
=
new
double
[
1
];
double
avg_z
=
quadCLTs
[
ref_index
].
getAverageZ
(
true
);
// use lma
double
[]
lma_rms
=
new
double
[
2
];
double
[]
lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
// use combo if second pass?
if
(
min_ref_str
>
0.0
)
{
reliable_ref
=
quadCLTs
[
ref_index
].
getReliableTiles
(
// will be null if does not exist.
...
...
@@ -618,6 +619,7 @@ public class Interscene {
fail_reason
[
0
]=
FAIL_REASON_MIN
;
}
else
{
// Trying new version with motion blur and single-setting of the reference frame
final
double
max_rms
=
clt_parameters
.
imp
.
eig_use
?
clt_parameters
.
imp
.
eig_max_rms
:
clt_parameters
.
imp
.
max_rms
;
scenes_xyzatr
[
scene_index
]
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
clt_parameters
,
// CLTParameters clt_parameters,
use_lma_dsi
,
// clt_parameters.imp.use_lma_dsi,
...
...
@@ -641,7 +643,7 @@ public class Interscene {
param_select
,
// clt_parameters.ilp.ilma_lma_select, // boolean[] param_select,
reg_weights
,
// double [] param_regweights,
lma_rms
,
// double [] rms_out, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
max_rms
,
// double max_rms,
mb_en
,
// boolean mb_en,
mb_tau
,
// double mb_tau, // 0.008; // time constant, sec
mb_max_gain
,
// double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
...
...
@@ -680,11 +682,21 @@ public class Interscene {
adjusted_xyzatr_dt
[
1
]
// ZERO3 // ers_scene.getErsATR_dt()
);
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"invertInitialOrientation(): scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"invertInitialOrientation(): scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
ref_index
].
getImageName
()
+
"/"
+
quadCLTs
[
scene_index
].
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
// for (int scene_index = ref_index; scene_index <= last_index; scene_index++) {
...
...
@@ -720,6 +732,7 @@ public class Interscene {
", using scene "
+
fpn_pairs
[
ipair
][
1
]+
" as a reference"
);
}
TpTask
[][]
tp_tasks_rel_ref
=
new
TpTask
[
2
][];
final
double
max_rms
=
clt_parameters
.
imp
.
eig_use
?
clt_parameters
.
imp
.
eig_max_rms
:
clt_parameters
.
imp
.
max_rms
;
double
[][]
rel_xyzatr
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
clt_parameters
,
// CLTParameters clt_parameters,
use_lma_dsi
,
// clt_parameters.imp.use_lma_dsi,
...
...
@@ -743,7 +756,7 @@ public class Interscene {
param_select
,
// clt_parameters.ilp.ilma_lma_select, // boolean[] param_select,
reg_weights
,
// double [] param_regweights,
lma_rms
,
// double [] rms_out, // null or double [2]
2
*
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
2
*
max_rms
,
// double max_rms,
mb_en
,
// boolean mb_en,
mb_tau
,
// double mb_tau, // 0.008; // time constant, sec
mb_max_gain
,
// double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
...
...
@@ -769,11 +782,20 @@ public class Interscene {
adjusted_xyzatr_dt
[
0
],
// ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt
[
1
]);
// ZERO3 // ers_scene.getErsATR_dt()
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"Pass multi scene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"Pass multi scene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
fpn_pairs
[
ipair
][
1
]].
getImageName
()
+
"/"
+
quadCLTs
[
fpn_pairs
[
ipair
][
0
]].
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
}
...
...
@@ -790,6 +812,10 @@ public class Interscene {
sb
.
append
(
"old_ref_index= "
+
ref_old
+
"\n"
);
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats
.
getMax
()+
"\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats
.
getAverage
()+
"\n"
);
if
(
rmse_stats_metric
!=
null
)
{
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats_metric
.
getMax
()+
"pix\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats_metric
.
getAverage
()+
"pix\n"
);
}
sb
.
append
(
"------------------------\n\n"
);
quadCLTs
[
ref_index
].
saveStringInModelDirectory
(
sb
.
toString
(),
QuadCLT
.
ORIENTATION_LOGS_SUFFIX
);
// String suffix)
}
...
...
@@ -812,6 +838,7 @@ public class Interscene {
final
boolean
updateStatus
,
final
int
debugLevel
)
{
RMSEStats
rmse_stats
=
new
RMSEStats
();
RMSEStats
rmse_stats_metric
=
clt_parameters
.
imp
.
eig_use
?
(
new
RMSEStats
()):
null
;
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
boolean
ref_need_lma
=
clt_parameters
.
imp
.
ref_need_lma
;
double
min_ref_frac
=
clt_parameters
.
imp
.
min_ref_frac
;
...
...
@@ -839,7 +866,7 @@ public class Interscene {
System
.
out
.
println
(
"*** setInitialOrientationsIms(): clt_parameters.ilp.ilma_3d is TRUE. You may want to disable it when using IMS"
);
}
double
[]
lma_rms
=
new
double
[
2
];
double
[]
lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
int
tilesX
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesX
();
int
tilesY
=
quadCLTs
[
ref_index
].
getTileProcessor
().
getTilesY
();
...
...
@@ -989,6 +1016,7 @@ public class Interscene {
ArrayList
<
Integer
>
fpn_list
=
new
ArrayList
<
Integer
>();
double
[]
reg_weights
=
clt_parameters
.
ilp
.
ilma_regularization_weights
;
// min_max[1] = max_offset;
final
double
max_rms
=
clt_parameters
.
imp
.
eig_use
?
clt_parameters
.
imp
.
eig_max_rms
:
clt_parameters
.
imp
.
max_rms
;
for
(
int
scene_index
=
ref_index
-
1
;
scene_index
>=
earliest_scene
;
scene_index
--)
{
if
((
ref_index
-
scene_index
)
>=
max_num_scenes
){
earliest_scene
=
scene_index
+
1
;
...
...
@@ -1067,7 +1095,7 @@ public class Interscene {
boolean
adjust_OK
=
false
;
if
(
est_shift
<
min_max
[
0
])
{
fail_reason
[
0
]=
FAIL_REASON_MIN
;
}
else
{
}
else
{
scenes_xyzatr
[
scene_index
]
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
clt_parameters
,
// CLTParameters clt_parameters,
use_lma_dsi
,
// clt_parameters.imp.use_lma_dsi,
...
...
@@ -1088,10 +1116,10 @@ public class Interscene {
initial_pose
,
// double [][] scene1_xyzatr,
Double
.
NaN
,
// double average_z,
initial_pose
,
// double [] scene1_xyzatr_pull, // if both are not null, specify target values to pull to
param_select
,
// clt_parameters.ilp.ilma_lma_select, // boolean[] param_select,
param_select
,
// clt_parameters.ilp.ilma_lma_select, // boolean[] param_select,
reg_weights
,
// double [] param_regweights,
lma_rms
,
// double [] rms_out, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
max_rms
,
// double max_rms,
mb_en
,
// boolean mb_en,
mb_tau
,
// double mb_tau, // 0.008; // time constant, sec
mb_max_gain
,
// double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
...
...
@@ -1173,14 +1201,21 @@ public class Interscene {
adjusted_xyzatr_dt
[
1
]
// ZERO3 // ers_scene.getErsATR_dt()
);
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
ref_index
].
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
// for (int scene_index = ref_index - 1; scene_index >= 0 ; scene_index--)
if
((
ref_index
-
earliest_scene
+
1
)
<
min_num_scenes
)
{
System
.
out
.
println
(
"Total number of useful scenes = "
+(
ref_index
-
earliest_scene
+
1
)+
...
...
@@ -1248,7 +1283,7 @@ public class Interscene {
param_select
,
// clt_parameters.ilp.ilma_lma_select, // boolean[] param_select,
reg_weights
,
// double [] param_regweights,
lma_rms
,
// double [] rms_out, // null or double [2]
clt_parameters
.
imp
.
max_rms
,
// double max_rms,
max_rms
,
// double max_rms,
mb_en
,
// boolean mb_en,
mb_tau
,
// double mb_tau, // 0.008; // time constant, sec
mb_max_gain
,
// double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
...
...
@@ -1274,22 +1309,44 @@ public class Interscene {
adjusted_xyzatr_dt
[
0
],
// ZERO3, // ers_scene.getErsXYZ_dt(),
adjusted_xyzatr_dt
[
1
]);
// ZERO3 // ers_scene.getErsATR_dt()
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"Pass multi scene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"Pass multi scene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
fpn_pairs
[
ipair
][
1
]].
getImageName
()
+
"/"
+
quadCLTs
[
fpn_pairs
[
ipair
][
0
]].
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
}
}
if
(
earliest_scene
>
0
)
{
System
.
out
.
print
ln
(
"setInitialOrientationsIms(): Not all scenes matched, earliest useful scene = "
+
earliest_scene
+
System
.
out
.
print
(
"setInitialOrientationsIms(): Not all scenes matched, earliest useful scene = "
+
earliest_scene
+
" (total number of scenes = "
+(
ref_index
-
earliest_scene
+
1
)+
"). Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". Maximal metric so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
else
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
System
.
out
.
print
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". Maximal metric so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
quadCLTs
[
ref_index
].
set_orient
(
1
);
// first orientation
quadCLTs
[
ref_index
].
set_accum
(
0
);
// reset accumulations ("build_interscene") number
...
...
@@ -1306,6 +1363,10 @@ public class Interscene {
sb
.
append
(
"ref_index= "
+
ref_index
+
"\n"
);
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats
.
getMax
()+
"\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats
.
getAverage
()+
"\n"
);
if
(
rmse_stats_metric
!=
null
)
{
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats_metric
.
getMax
()+
"pix\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats_metric
.
getAverage
()+
"pix\n"
);
}
sb
.
append
(
"------------------------\n\n"
);
quadCLTs
[
ref_index
].
saveStringInModelDirectory
(
sb
.
toString
(),
QuadCLT
.
ORIENTATION_LOGS_SUFFIX
);
// String suffix)
return
earliest_scene
;
...
...
@@ -1446,6 +1507,7 @@ public class Interscene {
double
scale_extrap_xyz
=
clt_parameters
.
imp
.
scale_extrap_xyz
;
int
avg_len
=
clt_parameters
.
imp
.
avg_len
;
RMSEStats
rmse_stats
=
new
RMSEStats
();
RMSEStats
rmse_stats_metric
=
clt_parameters
.
imp
.
eig_use
?
(
new
RMSEStats
()):
null
;
double
min_ref_str
=
clt_parameters
.
imp
.
min_ref_str
;
boolean
ref_need_lma
=
clt_parameters
.
imp
.
ref_need_lma
;
double
min_ref_frac
=
clt_parameters
.
imp
.
min_ref_frac
;
...
...
@@ -1764,11 +1826,20 @@ public class Interscene {
ZERO3
// ers_scene.getErsATR_dt()
);
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"Pass multi scene "
+
scene_index
+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
ref_index
].
getImageName
()
+
"/"
+
scene_QuadClt
.
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
// for (int scene_index = ref_index - 1; scene_index >= 0 ; scene_index--)
if
((
ref_index
-
earliest_scene
+
1
)
<
min_num_scenes
)
{
...
...
@@ -1780,11 +1851,22 @@ public class Interscene {
return
-
1
;
}
if
(
earliest_scene
>
0
)
{
System
.
out
.
print
ln
(
"setInitialOrientations(): Not all scenes matched, earliest useful scene = "
+
earliest_scene
+
System
.
out
.
print
(
"setInitialOrientations(): Not all scenes matched, earliest useful scene = "
+
earliest_scene
+
" (total number of scenes = "
+(
ref_index
-
earliest_scene
+
1
)+
").Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". Maximal metric so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
else
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
System
.
out
.
print
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". Maximal metric so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
quadCLTs
[
ref_index
].
set_orient
(
1
);
// first orientation
quadCLTs
[
ref_index
].
set_accum
(
0
);
// reset accumulations ("build_interscene") number
...
...
@@ -2083,6 +2165,7 @@ public class Interscene {
// should have at least next or previous non-null
int
debug_scene
=
69
;
// -68; // -8;
RMSEStats
rmse_stats
=
new
RMSEStats
();
RMSEStats
rmse_stats_metric
=
clt_parameters
.
imp
.
eig_use
?
(
new
RMSEStats
()):
null
;
if
(
debug_ers
)
{
System
.
out
.
println
(
"ERS velocities scale mode = '"
+
dbg_ers_string
+
"'"
);
}
...
...
@@ -2273,13 +2356,13 @@ public class Interscene {
double
[][]
pXpYD_ref
=
new
double
[
tilesX
*
tilesY
][];
ArrayList
<
Integer
>
fpn_list
=
new
ArrayList
<
Integer
>();
boolean
fpn_disable
=
false
;
// estimate they are too close
final
double
max_rms
=
clt_parameters
.
imp
.
max_rms
;
final
double
max_rms
=
clt_parameters
.
imp
.
eig_use
?
clt_parameters
.
imp
.
eig_max_rms
:
clt_parameters
.
imp
.
max_rms
;
//add test
boolean
test_adjust
=
debugLevel
>
1000
;
while
(
test_adjust
)
{
int
[]
test_pair
=
{
ref_index
,
0
};
double
[]
test_lma_rms
=
new
double
[
2
];
double
[]
test_lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
TpTask
[][]
tp_tasks_test_rel_ref
=
new
TpTask
[
2
][];
double
[][]
test_xyzatr
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
clt_parameters
,
//CLTParameters clt_parameters,
...
...
@@ -2385,7 +2468,7 @@ public class Interscene {
dxyzatr_dt
[
nscene
]
);
}
else
{
// if (nscene == ref_index)
double
[]
lma_rms
=
new
double
[
2
];
double
[]
lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
double
[][]
initial_pose
=
scenes_xyzatr
[
nscene
].
clone
();
boolean
adjust_OK
=
false
;
if
(
est_shift
<
min_max
[
0
])
{
...
...
@@ -2521,11 +2604,20 @@ public class Interscene {
);
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"reAdjustPairsLMAInterscene "
+
nscene
+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"reAdjustPairsLMAInterscene "
+
nscene
+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
ref_index
].
getImageName
()
+
"/"
+
ts
+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
// if (nscene == ref_index) else
}
// for (int nscene = ref_index; nscene > earliest_scene; nscene--) {
...
...
@@ -2582,7 +2674,7 @@ public class Interscene {
" being too close to reference "
+
ref_index
+
", using scene "
+
fpn_pairs
[
ipair
][
1
]+
" as a reference"
);
}
double
[]
lma_rms
=
new
double
[
2
];
double
[]
lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
TpTask
[][]
tp_tasks_rel_ref
=
new
TpTask
[
2
][];
double
[][]
rel_xyzatr
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
clt_parameters
,
//CLTParameters clt_parameters,
...
...
@@ -2633,11 +2725,20 @@ public class Interscene {
adjusted_xyzatr_dt
[
0
],
adjusted_xyzatr_dt
[
1
]);
rmse_stats
.
add
(
lma_rms
[
0
]);
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
rmse_stats_metric
.
add
(
lma_rms
[
2
]);
}
if
(
debugLevel
>
-
3
)
{
System
.
out
.
print
ln
(
"reAdjustPairsLMAInterscene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
System
.
out
.
print
(
"reAdjustPairsLMAInterscene "
+
fpn_pairs
[
ipair
][
0
]+
" (of "
+
quadCLTs
.
length
+
") "
+
quadCLTs
[
fpn_pairs
[
ipair
][
1
]].
getImageName
()
+
"/"
+
quadCLTs
[
fpn_pairs
[
ipair
][
0
]].
getImageName
()+
" Done. RMS="
+
lma_rms
[
0
]+
", maximal so far was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
((
rmse_stats_metric
!=
null
)
&&
(
lma_rms
.
length
>=
4
))
{
System
.
out
.
print
(
". RMS="
+
lma_rms
[
2
]+
"pix, maximal so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
}
}
...
...
@@ -2647,7 +2748,7 @@ public class Interscene {
if
(
test_adjust1
)
{
int
[]
test_pair
=
{
0
,
ref_index
};
while
(
test_adjust1
)
{
double
[]
test_lma_rms
=
new
double
[
2
];
double
[]
test_lma_rms
=
new
double
[
clt_parameters
.
imp
.
eig_use
?
4
:
2
];
// [
2];
TpTask
[][]
tp_tasks_test_rel_ref
=
new
TpTask
[
2
][];
System
.
out
.
println
(
"test_adjust scene = "
+
test_pair
[
0
]+
", reference="
+
test_pair
[
1
]);
double
[][]
test_xyzatr
=
adjustDiffPairsLMAInterscene
(
// compare two scenes, first may be reference, use motion blur
...
...
@@ -2681,9 +2782,10 @@ public class Interscene {
clt_parameters
.
imp
.
debug_level
);
// int debugLevel)
boolean
adjust_OK_test
=
test_xyzatr
!=
null
;
System
.
out
.
println
(
"adjust_OK_test = "
+
adjust_OK_test
);
System
.
out
.
print
ln
(
"reAdjustPairsLMAInterscene "
+
test_pair
[
0
]+
System
.
out
.
print
(
"reAdjustPairsLMAInterscene "
+
test_pair
[
0
]+
quadCLTs
[
test_pair
[
1
]].
getImageName
()
+
"/"
+
quadCLTs
[
test_pair
[
0
]].
getImageName
()+
" Done. RMS="
+
test_lma_rms
[
0
]);
// if
System
.
out
.
println
(
"test_adjust = "
+
test_adjust1
);
}
}
...
...
@@ -2703,7 +2805,13 @@ public class Interscene {
}
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
System
.
out
.
print
(
"All multi scene passes are Done. Maximal RMSE was "
+
rmse_stats
.
getMax
()+
", average was "
+
rmse_stats
.
getAverage
());
if
(
rmse_stats_metric
!=
null
)
{
System
.
out
.
print
(
". Maximal metric so far was "
+
rmse_stats_metric
.
getMax
()+
"pix, average was "
+
rmse_stats_metric
.
getAverage
()+
"pix."
);
}
System
.
out
.
println
();
}
quadCLTs
[
ref_index
].
saveInterProperties
(
// save properties for interscene processing (extrinsics, ers, ...)
...
...
@@ -2721,6 +2829,10 @@ public class Interscene {
sb
.
append
(
"last_index= "
+
range
[
1
]+
"\n"
);
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats
.
getMax
()+
"\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats
.
getAverage
()+
"\n"
);
if
(
rmse_stats_metric
!=
null
)
{
sb
.
append
(
"Maximal RMSE= "
+
rmse_stats_metric
.
getMax
()+
"pix\n"
);
sb
.
append
(
"Average RMSE= "
+
rmse_stats_metric
.
getAverage
()+
"pix\n"
);
}
sb
.
append
(
"lpf_xy= "
+
lpf_xy
+
"\n"
);
sb
.
append
(
"readjust_xy_ims="
+
readjust_xy_ims
+
"\n"
);
sb
.
append
(
"lma_xyzatr= "
+
lma_xyzatr
+
"\n"
);
...
...
@@ -3120,7 +3232,7 @@ public class Interscene {
double
[][]
ref_xyzatr
,
//
boolean
[]
param_select
,
double
[]
param_regweights
,
double
[]
rms_out
,
// null or double [2]
double
[]
rms_out
,
// null or double [2]
or double[4]
double
max_rms
,
// motion blur compensation
double
mb_tau
,
// 0.008; // time constant, sec
...
...
@@ -3128,6 +3240,7 @@ public class Interscene {
double
[][]
mb_vectors
,
// now [2][ntiles];
int
debug_level
)
{
boolean
dbg_images
=
false
;
// show images at each LMA step
boolean
show_initial
=
true
;
// debug feature
// boolean debug_corr_fpn = false;
boolean
use3D
=
clt_parameters
.
ilp
.
ilma_3d
;
...
...
@@ -3235,6 +3348,8 @@ public class Interscene {
double
[][]
eigen
=
(
coord_motion
.
length
<
3
)?
null
:
coord_motion
[
2
];
double
eig_max_sqrt
=
clt_parameters
.
imp
.
eig_max_sqrt
;
double
eig_min_sqrt
=
clt_parameters
.
imp
.
eig_min_sqrt
;
// boolean dbg_images = false;
String
dbg_prefix
=
dbg_images
?
(
first_QuadClt
.
getImageName
()+
"-"
+
scene_QuadClt
.
getImageName
()+
"-NLMA_"
+
nlma
)
:
null
;
intersceneLma
.
prepareLMA
(
scene_xyzatr0
,
// final double [] scene_xyzatr0, // camera center in world coordinates (or null to use instance)
scene_xyzatr_pull
,
// final double [] scene_xyz_pull, // if both are not null, specify target values to pull to
...
...
@@ -3250,6 +3365,7 @@ public class Interscene {
coord_motion
[
1
],
// final double [][] vector_XYS, // optical flow X,Y, confidence obtained from the correlate2DIterate()
coord_motion
[
0
],
// final double [][] centers, // macrotile centers (in pixels and average disparities
(
nlma
==
0
),
// boolean first_run,
dbg_prefix
,
// String dbg_prefix, // null or image name prefix
clt_parameters
.
imp
.
debug_level
);
// final int debug_level)
lmaResult
=
intersceneLma
.
runLma
(
clt_parameters
.
ilp
.
ilma_lambda
,
// double lambda, // 0.1
...
...
@@ -3272,8 +3388,13 @@ public class Interscene {
return
null
;
}
if
(
debug_level
>
-
3
){
System
.
out
.
print
ln
(
"iter="
+
lmaResult
+
", RMS="
+
intersceneLma
.
getLastRms
()[
0
]+
System
.
out
.
print
(
"iter="
+
lmaResult
+
", RMS="
+
intersceneLma
.
getLastRms
()[
0
]+
" (Pure RMS="
+
intersceneLma
.
getLastRms
()[
1
]+
")"
);
if
(
intersceneLma
.
isEigenNormalized
())
{
double
[]
rms_metric
=
intersceneLma
.
calcRMS
(
true
);
System
.
out
.
print
(
", RMS="
+
rms_metric
[
0
]+
"pix (Pure RMS="
+
rms_metric
[
0
]+
"pix )"
);
}
System
.
out
.
println
();
}
scene_xyzatr0
=
intersceneLma
.
getSceneXYZATR
(
false
);
// true for initial values
double
[]
diffs_atr
=
intersceneLma
.
getV3Diff
(
ErsCorrection
.
DP_DSAZ
);
...
...
@@ -3397,10 +3518,15 @@ public class Interscene {
}
if
(
clt_parameters
.
imp
.
debug_level
>
-
2
)
{
String
[]
lines1
=
intersceneLma
.
printOldNew
((
clt_parameters
.
imp
.
debug_level
>
-
1
));
// false); // boolean allvectors)
System
.
out
.
print
ln
(
"Adjusted interscene, iteration="
+
nlma
+
System
.
out
.
print
(
"Adjusted interscene, iteration="
+
nlma
+
", last RMS = "
+
intersceneLma
.
getLastRms
()[
0
]+
" (pure RMS = "
+
intersceneLma
.
getLastRms
()[
1
]+
")"
+
", results:"
);
" (pure RMS = "
+
intersceneLma
.
getLastRms
()[
1
]+
")"
);
if
(
intersceneLma
.
isEigenNormalized
())
{
double
[]
rms_metric
=
intersceneLma
.
calcRMS
(
true
);
System
.
out
.
print
(
" RMS="
+
rms_metric
[
0
]+
"pix (Pure RMS="
+
rms_metric
[
0
]+
"pix )"
);
}
System
.
out
.
println
(
", results:"
);
for
(
String
line
:
lines1
)
{
System
.
out
.
println
(
line
);
}
...
...
@@ -3414,6 +3540,18 @@ public class Interscene {
if
((
rms_out
!=
null
)
&&
(
intersceneLma
.
getLastRms
()
!=
null
))
{
rms_out
[
0
]
=
intersceneLma
.
getLastRms
()[
0
];
rms_out
[
1
]
=
intersceneLma
.
getLastRms
()[
1
];
if
(
rms_out
.
length
>=
4
)
{
if
(
intersceneLma
.
isEigenNormalized
())
{
double
[]
rms_metric
=
intersceneLma
.
calcRMS
(
true
);
rms_out
[
2
]
=
rms_metric
[
0
];
rms_out
[
3
]
=
rms_metric
[
1
];
}
else
{
rms_out
[
2
]
=
Double
.
NaN
;
rms_out
[
3
]
=
Double
.
NaN
;
}
}
//if (lmaResult < 0) { last_rms[0]
}
if
(
max_rms
>
0.0
)
{
...
...
@@ -4181,6 +4319,7 @@ public class Interscene {
clt_parameters
.
imp
.
td_nopd_only
,
// final boolean td_nopd_only , // only use TD accumulated data if no safe PD is available for the tile.
clt_parameters
.
imp
.
eig_use_neibs
,
// final boolean eig_use_neibs, // use correlation from 9 tiles with neibs, if single-tile fails
clt_parameters
.
imp
.
eig_remove_neibs
,
//final boolean eig_remove_neibs, //remove weak (by-neibs) tiles if they have strong (by-single) neighbor
clt_parameters
.
imp
.
eig_filt_other
,
// final boolean eig_filt_other, // apply other before-eigen filters
// min_str, // final double min_str_nofpn, // = 0.25;
eig_str_sum
,
// final double eig_str_sum_nofpn, // = 0.8; // 5;
eig_str_neib
,
// final double eig_str_neib_nofpn,
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneLma.java
View file @
c8d3d7d9
...
...
@@ -31,11 +31,14 @@ import java.io.Serializable;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.DoubleAdder
;
import
javax.xml.bind.DatatypeConverter
;
import
com.elphel.imagej.common.ShowDoubleFloatArrays
;
import
Jama.Matrix
;
public
class
IntersceneLma
{
...
...
@@ -44,6 +47,7 @@ public class IntersceneLma {
private
double
[]
good_or_bad_rms
=
null
;
// just for diagnostics, to read last (failed) rms
private
double
[]
initial_rms
=
null
;
// {rms, rms_pure}, first-calcualted rms
private
double
[]
y_vector
=
null
;
// sum of fx(initial parameters) and correlation offsets
private
double
[]
s_vector
=
null
;
// strength component - just for debug images
private
double
[]
last_ymfx
=
null
;
private
double
[][]
last_jt
=
null
;
private
double
[]
weights
;
// normalized so sum is 1.0 for all - samples and extra regularization
...
...
@@ -69,7 +73,9 @@ public class IntersceneLma {
private
double
disparity_weight
=
1.0
;
// relative weight of disparity errors
private
double
[][][]
eig_trans
=
null
;
private
int
tilesX
=
-
1
;
private
String
dbg_prefix
=
null
;
public
IntersceneLma
(
boolean
thread_invariant
,
double
disparity_weight
...
...
@@ -259,20 +265,21 @@ public class IntersceneLma {
// 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
[][]
centers
,
// macrotile centers (in pixels and average disparities
boolean
first_run
,
String
dbg_prefix
,
// null or image name prefix
final
int
debug_level
)
{
// befo
l
re getFxDerivs
// before getFxDerivs
eig_trans
=
setEigenTransform
(
eig_max_sqrt
,
// final double eig_max_sqrt,
eig_min_sqrt
,
// final double eig_min_sqrt,
eigen
);
// final double [][] eigen); // [tilesX*tilesY]{lamb0_x,lamb0_y, lamb0, lamb1} eigenvector0[x,y],lam0,lam1
tilesX
=
reference_QuadClt
.
getTileProcessor
().
getTilesX
();
// just for debug images
scenesCLT
=
new
QuadCLT
[]
{
reference_QuadClt
,
scene_QuadClt
};
par_mask
=
param_select
;
macrotile_centers
=
centers
;
num_samples
=
num_components
*
centers
.
length
;
this
.
dbg_prefix
=
dbg_prefix
;
s_vector
=
(
this
.
dbg_prefix
!=
null
)
?
(
new
double
[
centers
.
length
]):
null
;
// original strength
ErsCorrection
ers_ref
=
reference_QuadClt
.
getErsCorrection
();
ErsCorrection
ers_scene
=
scene_QuadClt
.
getErsCorrection
();
final
double
[]
scene_xyz
=
(
scene_xyzatr0
!=
null
)
?
scene_xyzatr0
[
0
]
:
ers_scene
.
camera_xyz
;
...
...
@@ -366,8 +373,11 @@ public class IntersceneLma {
if
(
vector_XYSDS
[
i
]
!=
null
){
y_vector
[
num_components
*
i
+
0
]
+=
vector_XYSDS
[
i
][
0
];
y_vector
[
num_components
*
i
+
1
]
+=
vector_XYSDS
[
i
][
1
];
if
(
num_components
>
2
)
{
y_vector
[
num_components
*
i
+
2
]
+=
vector_XYSDS
[
i
][
2
];
if
(
num_components
>
2
)
{
// ****************************** [3] - disparity? Was BUG: [2] !
y_vector
[
num_components
*
i
+
2
]
+=
vector_XYSDS
[
i
][
3
];
// vector_XYSDS[i][2];
}
if
(
s_vector
!=
null
)
{
s_vector
[
i
]
=
vector_XYSDS
[
i
][
2
];
}
}
}
...
...
@@ -562,6 +572,10 @@ public class IntersceneLma {
break
;
// not used in lwir
}
}
if
(
dbg_prefix
!=
null
)
{
showDebugImage
(
dbg_prefix
+
"-"
+
iter
+(
rslt
[
0
]?
"-GOOD"
:
"-BAD"
));
}
}
if
(
rslt
[
0
])
{
// better
if
(
iter
>=
num_iter
)
{
// better, but num tries exceeded
...
...
@@ -578,6 +592,9 @@ public class IntersceneLma {
if
(
debug_level
>
1
)
System
.
out
.
println
(
"Step "
+
iter
+
": Failed to converge"
);
}
}
if
(
dbg_prefix
!=
null
)
{
showDebugImage
(
dbg_prefix
+
"-FINAL"
);
}
boolean
show_intermediate
=
true
;
if
(
show_intermediate
&&
(
debug_level
>
0
))
{
System
.
out
.
println
(
"LMA: full RMS="
+
last_rms
[
0
]+
" ("
+
initial_rms
[
0
]+
"), pure RMS="
+
last_rms
[
1
]+
" ("
+
initial_rms
[
1
]+
") + lambda="
+
lambda
);
...
...
@@ -657,6 +674,9 @@ public class IntersceneLma {
true); //boolean graphic)
*/
}
if
(
dbg_prefix
!=
null
)
{
showDebugImage
(
dbg_prefix
+
"-INIT"
);
}
}
Matrix
y_minus_fx_weighted
=
new
Matrix
(
this
.
last_ymfx
,
this
.
last_ymfx
.
length
);
...
...
@@ -829,7 +849,7 @@ public class IntersceneLma {
w
=
vector_XYSDS
[
iMTile
][
4
]
*
disparity_weight
;
if
(
Double
.
isNaN
(
w
)
||
Double
.
isNaN
(
vector_XYSDS
[
iMTile
][
3
]))
{
w
=
0
;
vector_XYSDS
[
iMTile
][
3
]
=
0.0
;
vector_XYSDS
[
iMTile
][
3
]
=
0.0
;
// disparity
}
weights
[
num_components
*
iMTile
+
2
]
=
w
;
sw_arr
[
thread_num
]
+=
w
;
...
...
@@ -1036,9 +1056,11 @@ public class IntersceneLma {
}
}
}
else
if
(
mb_mode
)
{
for
(
int
i
=
0
;
i
<
par_indices
.
length
;
i
++)
{
jt
[
i
][
2
*
iMTile
+
0
]
=
Double
.
NaN
;
// pX
jt
[
i
][
2
*
iMTile
+
1
]
=
Double
.
NaN
;
// ; // pY (disparity is not used)
if
(
jt
!=
null
)
{
for
(
int
i
=
0
;
i
<
par_indices
.
length
;
i
++)
{
jt
[
i
][
2
*
iMTile
+
0
]
=
Double
.
NaN
;
// pX
jt
[
i
][
2
*
iMTile
+
1
]
=
Double
.
NaN
;
// ; // pY (disparity is not used)
}
}
}
}
...
...
@@ -1053,7 +1075,9 @@ public class IntersceneLma {
// pull to the initial parameter values
for
(
int
i
=
0
;
i
<
par_indices
.
length
;
i
++)
{
fx
[
i
+
num_samples
]
=
vector
[
i
];
// - parameters_initial[i]; // scale will be combined with weights
jt
[
i
][
i
+
num_samples
]
=
1.0
;
// scale will be combined with weights
if
(
jt
!=
null
)
{
jt
[
i
][
i
+
num_samples
]
=
1.0
;
// scale will be combined with weights
}
}
/// if (parameters_pull != null){
/// for (int i = 0; i < par_indices.length; i++) {
...
...
@@ -1101,16 +1125,114 @@ public class IntersceneLma {
ImageDtt
.
startAndJoin
(
threads
);
return
wjtjl
;
}
public
void
showDebugImage
(
String
dbg_title
)
{
// includes "_iteration_number" or "_final"
if
(
s_vector
==
null
)
{
return
;
}
int
tilesY
=
s_vector
.
length
/
tilesX
;
String
[]
titles
=
{
"dx"
,
"dy"
,
"dr"
,
"str"
,
"e0"
,
"e1"
,
"e"
};
double
[][]
dbg_img
=
new
double
[
titles
.
length
][
tilesX
*
tilesY
];
for
(
int
l
=
0
;
l
<
dbg_img
.
length
;
l
++)
{
Arrays
.
fill
(
dbg_img
[
l
],
Double
.
NaN
);
}
double
[]
fx
=
getFxDerivs
(
parameters_vector
,
// double [] vector,
null
,
// final double [][] jt, // should be null or initialized with [vector.length][]
scenesCLT
[
1
],
// final QuadCLT scene_QuadClt,
scenesCLT
[
0
],
// final QuadCLT reference_QuadClt,
-
1
);
// debug_level); // final int debug_level)
double
[]
ymfxw_m
=
getYminusFxWeighted
(
fx
,
// final double [] fx,
null
,
// final double [] rms_fp // null or [2]
true
);
//final boolean force_metric // when true, ignore transform with eig_trans and use linear dx, dy in pixels
double
[]
ymfxw_e
=
null
;
if
(
eig_trans
!=
null
)
{
ymfxw_e
=
getYminusFxWeighted
(
fx
,
// final double [] fx,
null
,
// final double [] rms_fp // null or [2]
false
);
//final boolean force_metric // when true, ignore transform with eig_trans and use linear dx, dy in pixels
}
for
(
int
nTile
=
0
;
nTile
<
s_vector
.
length
;
nTile
++)
{
int
indx
=
num_components
*
nTile
;
double
w
=
weights
[
num_components
*
nTile
];
if
((
weights
[
indx
]
>
0
)
&&
(
weights
[
indx
+
1
]
>
0
))
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
ymfxw_m
[
indx
+
i
]
/=
weights
[
indx
+
i
];
if
(
ymfxw_e
!=
null
)
{
ymfxw_e
[
indx
+
i
]
/=
weights
[
indx
+
i
];
}
}
double
dx
=
ymfxw_m
[
indx
+
0
];
double
dy
=
ymfxw_m
[
indx
+
1
];
dbg_img
[
0
][
nTile
]
=
dx
;
dbg_img
[
1
][
nTile
]
=
dy
;
dbg_img
[
2
][
nTile
]
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
dbg_img
[
3
][
nTile
]
=
s_vector
[
nTile
];
if
(
ymfxw_e
!=
null
)
{
double
d0
=
ymfxw_e
[
indx
+
0
];
double
d1
=
ymfxw_e
[
indx
+
1
];
dbg_img
[
4
][
nTile
]
=
d0
;
dbg_img
[
5
][
nTile
]
=
d1
;
dbg_img
[
6
][
nTile
]
=
Math
.
sqrt
(
d0
*
d0
+
d1
*
d1
);
}
}
}
if
(
ymfxw_e
==
null
)
{
dbg_img
[
4
]=
null
;
dbg_img
[
5
]=
null
;
dbg_img
[
6
]=
null
;
}
ShowDoubleFloatArrays
.
showArrays
(
// out of boundary 15
dbg_img
,
tilesX
,
tilesY
,
true
,
dbg_title
,
titles
);
}
public
boolean
isEigenNormalized
()
{
return
(
eig_trans
!=
null
);
}
public
double
[]
calcRMS
(
boolean
metric
)
{
double
[]
rms_fp
=
new
double
[
2
];
double
[]
fx
=
getFxDerivs
(
parameters_vector
,
// double [] vector,
null
,
// final double [][] jt, // should be null or initialized with [vector.length][]
scenesCLT
[
1
],
// final QuadCLT scene_QuadClt,
scenesCLT
[
0
],
// final QuadCLT reference_QuadClt,
-
1
);
// debug_level); // final int debug_level)
last_ymfx
=
getYminusFxWeighted
(
fx
,
// final double [] fx,
rms_fp
,
// final double [] rms_fp // null or [2]
metric
);
//final boolean force_metric // when true, ignore transform with eig_trans and use linear dx, dy in pixels
return
rms_fp
;
}
private
double
[]
getYminusFxWeighted
(
final
double
[]
fx
,
final
double
[]
rms_fp
)
{
// null or [2]
return
getYminusFxWeighted
(
fx
,
// final double [] fx,
rms_fp
,
// final double [] rms_fp, // null or [2]
false
);
// final boolean force_metric)
}
private
double
[]
getYminusFxWeighted
(
final
double
[]
fx
,
final
double
[]
rms_fp
// null or [2]
final
double
[]
rms_fp
,
// null or [2]
final
boolean
force_metric
// when true, ignore transform with eig_trans and use linear dx, dy in pixels
)
{
double
[]
ymfxw
;
if
(
thread_invariant
)
{
ymfxw
=
getYminusFxWeightedInvariant
(
fx
,
rms_fp
);
// null or [2]
ymfxw
=
getYminusFxWeightedInvariant
(
fx
,
rms_fp
,
force_metric
);
// null or [2]
}
else
{
ymfxw
=
getYminusFxWeightedFast
(
fx
,
rms_fp
);
// null or [2]
ymfxw
=
getYminusFxWeightedFast
(
fx
,
rms_fp
,
force_metric
);
// null or [2]
}
return
ymfxw
;
}
...
...
@@ -1120,14 +1242,15 @@ public class IntersceneLma {
private
double
[]
getYminusFxWeightedInvariant
(
final
double
[]
fx
,
final
double
[]
rms_fp
// null or [2]
final
double
[]
rms_fp
,
// null or [2]
final
boolean
force_metric
// when true, ignore transform with eig_trans and use linear dx, dy in pixels
)
{
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
QuadCLT
.
THREADS_MAX
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
double
[]
wymfw
=
new
double
[
fx
.
length
];
double
s_rms
;
final
double
[]
l2_arr
=
new
double
[
num_samples
];
if
(
eig_trans
!=
null
)
{
if
(
!
force_metric
&&
(
eig_trans
!=
null
)
)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
...
...
@@ -1213,14 +1336,15 @@ public class IntersceneLma {
private
double
[]
getYminusFxWeightedFast
(
// problems. at least with eigen?
final
double
[]
fx
,
final
double
[]
rms_fp
// null or [2]
final
double
[]
rms_fp
,
// null or [2]
final
boolean
force_metric
// when true, ignore transform with eig_trans and use linear dx, dy in pixels
)
{
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
QuadCLT
.
THREADS_MAX
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
double
[]
wymfw
=
new
double
[
fx
.
length
];
final
AtomicInteger
ati
=
new
AtomicInteger
(
0
);
final
double
[]
l2_arr
=
new
double
[
threads
.
length
];
if
(
eig_trans
!=
null
)
{
if
(
!
force_metric
&&
(
eig_trans
!=
null
)
)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
c8d3d7d9
...
...
@@ -451,6 +451,9 @@ public class IntersceneMatchParameters {
public
double
eig_min_sqrt
=
1.0
;
// for sqrt(lambda) - limit minimal sqrt(lambda) - can be sharp for very small max
public
boolean
eig_use_neibs
=
true
;
// use correlation from 9 tiles with neibs, if single-tile fails
public
boolean
eig_remove_neibs
=
true
;
// remove weak (by-neibs) tiles if they have strong (by-single) neighbor
public
boolean
eig_filt_other
=
false
;
// apply other before-eigen filters
public
double
eig_max_rms
=
2.0
;
// eigen-normalized maximal RMS to consider adjustment to be a failure
/*
min_str_sum_nofpn 0.22
...
...
@@ -1358,8 +1361,10 @@ min_str_neib_fpn 0.35
"Use correlation from 9 tiles with neibs, if single-tile fails"
);
gd
.
addCheckbox
(
"Remove weak by strong neighbors"
,
this
.
eig_remove_neibs
,
"Remove weak (by-neibs) tiles if they have strong (by-single) neighbor"
);
gd
.
addCheckbox
(
"Apply other filters"
,
this
.
eig_filt_other
,
"Apply other (before-eigen) filters"
);
gd
.
addNumericField
(
"Maximal eigen-normalized RMS"
,
this
.
eig_max_rms
,
5
,
7
,
""
,
"Maximal eigen-normalized RMSE for LMA adjustment. Replaces \"Maximal RMS to fail\" setting below."
);
gd
.
addMessage
(
"Filtering tiles for interscene matching"
);
...
...
@@ -2048,7 +2053,8 @@ min_str_neib_fpn 0.35
this
.
eig_min_sqrt
=
gd
.
getNextNumber
();
this
.
eig_use_neibs
=
gd
.
getNextBoolean
();
this
.
eig_remove_neibs
=
gd
.
getNextBoolean
();
this
.
eig_filt_other
=
gd
.
getNextBoolean
();
this
.
eig_max_rms
=
gd
.
getNextNumber
();
this
.
use_combo_reliable
=
gd
.
getNextBoolean
();
this
.
ref_need_lma
=
gd
.
getNextBoolean
();
this
.
ref_need_lma_combo
=
gd
.
getNextBoolean
();
...
...
@@ -2603,6 +2609,8 @@ min_str_neib_fpn 0.35
properties
.
setProperty
(
prefix
+
"eig_min_sqrt"
,
this
.
eig_min_sqrt
+
""
);
// double
properties
.
setProperty
(
prefix
+
"eig_use_neibs"
,
this
.
eig_use_neibs
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"eig_remove_neibs"
,
this
.
eig_remove_neibs
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"eig_filt_other"
,
this
.
eig_filt_other
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"eig_max_rms"
,
this
.
eig_max_rms
+
""
);
// double
properties
.
setProperty
(
prefix
+
"use_combo_reliable"
,
this
.
use_combo_reliable
+
""
);
// boolean
properties
.
setProperty
(
prefix
+
"ref_need_lma"
,
this
.
ref_need_lma
+
""
);
// boolean
...
...
@@ -3120,7 +3128,9 @@ min_str_neib_fpn 0.35
if
(
properties
.
getProperty
(
prefix
+
"eig_min_sqrt"
)!=
null
)
this
.
eig_min_sqrt
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"eig_min_sqrt"
));
if
(
properties
.
getProperty
(
prefix
+
"eig_use_neibs"
)!=
null
)
this
.
eig_use_neibs
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"eig_use_neibs"
));
if
(
properties
.
getProperty
(
prefix
+
"eig_remove_neibs"
)!=
null
)
this
.
eig_remove_neibs
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"eig_remove_neibs"
));
if
(
properties
.
getProperty
(
prefix
+
"eig_filt_other"
)!=
null
)
this
.
eig_filt_other
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"eig_filt_other"
));
if
(
properties
.
getProperty
(
prefix
+
"eig_max_rms"
)!=
null
)
this
.
eig_max_rms
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"eig_max_rms"
));
if
(
properties
.
getProperty
(
prefix
+
"use_combo_reliable"
)!=
null
)
this
.
use_combo_reliable
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"use_combo_reliable"
));
else
if
(
properties
.
getProperty
(
prefix
+
"use_combo_relaible"
)!=
null
)
this
.
use_combo_reliable
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"use_combo_relaible"
));
if
(
properties
.
getProperty
(
prefix
+
"ref_need_lma"
)!=
null
)
this
.
ref_need_lma
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"ref_need_lma"
));
...
...
@@ -3645,6 +3655,8 @@ min_str_neib_fpn 0.35
imp
.
eig_min_sqrt
=
this
.
eig_min_sqrt
;
imp
.
eig_use_neibs
=
this
.
eig_use_neibs
;
imp
.
eig_remove_neibs
=
this
.
eig_remove_neibs
;
imp
.
eig_filt_other
=
this
.
eig_filt_other
;
imp
.
eig_max_rms
=
this
.
eig_max_rms
;
imp
.
use_combo_reliable
=
this
.
use_combo_reliable
;
imp
.
ref_need_lma
=
this
.
ref_need_lma
;
...
...
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