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
3711a65e
Commit
3711a65e
authored
Aug 12, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging
parent
b56ba447
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
7 deletions
+42
-7
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+41
-7
CuasMotionLMA.java
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
+1
-0
No files found.
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
3711a65e
...
@@ -936,6 +936,7 @@ public class CuasMotion {
...
@@ -936,6 +936,7 @@ public class CuasMotion {
double
lma_mink
,
// = 0.0; // Minimal K (overshoot) = 0.0
double
lma_mink
,
// = 0.0; // Minimal K (overshoot) = 0.0
double
lma_maxk
,
// = 5.0; // Minimal K (overshoot) = 5.0
double
lma_maxk
,
// = 5.0; // Minimal K (overshoot) = 5.0
double
lma_a2a
,
double
lma_a2a
,
double
lma_horizon
,
// horizon as maximal pixel Y
String
[]
slice_titles
,
//
String
[]
slice_titles
,
//
String
title_targets_filt
,
String
title_targets_filt
,
double
[][][]
failures_debug
,
double
[][][]
failures_debug
,
...
@@ -959,6 +960,7 @@ public class CuasMotion {
...
@@ -959,6 +960,7 @@ public class CuasMotion {
lma_mink
,
// final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_mink
,
// final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_maxk
,
// final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0// final double lma_a2a,
lma_maxk
,
// final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0// final double lma_a2a,
lma_a2a
,
// final double lma_a2a,
lma_a2a
,
// final double lma_a2a,
lma_horizon
,
// final double lma_horizon, // horizon as maximal pixel Y
lma_minxy
,
// final double lma_minxy, // 0.8
lma_minxy
,
// final double lma_minxy, // 0.8
tilesX
,
// final int tilesX,
tilesX
,
// final int tilesX,
failures_debug
,
// final double failures_debug,
failures_debug
,
// final double failures_debug,
...
@@ -1633,6 +1635,7 @@ public class CuasMotion {
...
@@ -1633,6 +1635,7 @@ public class CuasMotion {
final
double
lma_mink
,
// = 0.0; // Minimal K (overshoot) = 1.0
final
double
lma_mink
,
// = 0.0; // Minimal K (overshoot) = 1.0
final
double
lma_maxk
,
// = 5.0; // Minimal K (overshoot) = 3.0
final
double
lma_maxk
,
// = 5.0; // Minimal K (overshoot) = 3.0
final
double
lma_a2a
,
final
double
lma_a2a
,
final
double
lma_horizon
,
// horizon as maximal pixel Y
final
double
lma_minxy
,
// 0.8
final
double
lma_minxy
,
// 0.8
final
int
tilesX
,
final
int
tilesX
,
final
double
[][][]
failures_debug
,
// if not null, should be [num_scenes][][], fill contain a copy of original target_coords with failure reason
final
double
[][][]
failures_debug
,
// if not null, should be [num_scenes][][], fill contain a copy of original target_coords with failure reason
...
@@ -1672,6 +1675,7 @@ public class CuasMotion {
...
@@ -1672,6 +1675,7 @@ public class CuasMotion {
double
RMSE_A
=
lma_rslts
[
CuasMotionLMA
.
RSLT_RMS_A
];
double
RMSE_A
=
lma_rslts
[
CuasMotionLMA
.
RSLT_RMS_A
];
double
R1
=
lma_rslts
[
CuasMotionLMA
.
RSLT_R1
];
double
R1
=
lma_rslts
[
CuasMotionLMA
.
RSLT_R1
];
double
MAX2A
=
lma_rslts
[
CuasMotionLMA
.
RSLT_MAX2A
];
double
MAX2A
=
lma_rslts
[
CuasMotionLMA
.
RSLT_MAX2A
];
double
Y
=
(
ntile
/
tilesX
+
0.5
)
*
GPUTileProcessor
.
DTT_SIZE
+
lma_rslts
[
CuasMotionLMA
.
RSLT_Y
];
if
(
A
<
lma_mina
)
{
if
(
A
<
lma_mina
)
{
if
(
failures_debug
!=
null
)
failures_debug
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_A_LOW
;
if
(
failures_debug
!=
null
)
failures_debug
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_A_LOW
;
continue
;
// too weak
continue
;
// too weak
...
@@ -1716,6 +1720,11 @@ public class CuasMotion {
...
@@ -1716,6 +1720,11 @@ public class CuasMotion {
if
(
failures_debug
!=
null
)
failures_debug
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_FAR
;
if
(
failures_debug
!=
null
)
failures_debug
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_FAR
;
continue
;
// center outside of allowed range (on the very edges)
continue
;
// center outside of allowed range (on the very edges)
}
}
if
((
lma_horizon
>
0
)
&&
(
Y
>
lma_horizon
))
{
if
(
failures_debug
!=
null
)
failures_debug
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_HORIZON
;
continue
;
// below horizon line
}
// filter_target[nSeq][ntile] = true;
// filter_target[nSeq][ntile] = true;
// Now calculate overall quality
// Now calculate overall quality
double
[]
quality_factors
=
new
double
[
IMPORTANCE_LENGTH
];
double
[]
quality_factors
=
new
double
[
IMPORTANCE_LENGTH
];
...
@@ -1797,6 +1806,7 @@ public class CuasMotion {
...
@@ -1797,6 +1806,7 @@ public class CuasMotion {
public
static
boolean
[][]
filterMotionScanTarget
(
// should work for motion vectors and target coordinates
public
static
boolean
[][]
filterMotionScanTarget
(
// should work for motion vectors and target coordinates
double
[][]
confidence
,
double
[][]
confidence
,
double
min_confidence
,
double
min_confidence
,
final
double
lma_horizon
,
// target below horizon
final
int
tilesX
,
final
int
tilesX
,
final
int
range
,
// 1 or 2
final
int
range
,
// 1 or 2
final
int
[]
remain
,
final
int
[]
remain
,
...
@@ -1808,6 +1818,7 @@ public class CuasMotion {
...
@@ -1808,6 +1818,7 @@ public class CuasMotion {
final
boolean
[][]
filter5
=
new
boolean
[
num_seq
][
num_tiles
];
final
boolean
[][]
filter5
=
new
boolean
[
num_seq
][
num_tiles
];
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
();
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
();
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
int
ihorizon
=
(
lma_horizon
>
0
)
?(
(
int
)
Math
.
ceil
(
lma_horizon
/
GPUTileProcessor
.
DTT_SIZE
))
:
-
1
;
// tiles with tileY >= ihorizon are removed
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
public
void
run
()
{
...
@@ -1816,6 +1827,9 @@ public class CuasMotion {
...
@@ -1816,6 +1827,9 @@ public class CuasMotion {
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
int
num_total
=
0
;
int
num_total
=
0
;
Arrays
.
fill
(
prohibit
,
false
);
Arrays
.
fill
(
prohibit
,
false
);
if
((
ihorizon
>
0
)
&&
(
ihorizon
<
tilesY
))
{
Arrays
.
fill
(
prohibit
,
ihorizon
*
tilesX
,
num_tiles
,
true
);
}
double
[]
conf
=
confidence
[
nSeq
];
double
[]
conf
=
confidence
[
nSeq
];
int
num_this_pass
=
0
;
int
num_this_pass
=
0
;
int
npass
=
0
;
int
npass
=
0
;
...
@@ -3738,7 +3752,7 @@ public class CuasMotion {
...
@@ -3738,7 +3752,7 @@ public class CuasMotion {
double
lma_mink
=
clt_parameters
.
imp
.
cuas_lma_mink
;
// = 0.0; // Minimal K (overshoot) <0.007
double
lma_mink
=
clt_parameters
.
imp
.
cuas_lma_mink
;
// = 0.0; // Minimal K (overshoot) <0.007
double
lma_maxk
=
clt_parameters
.
imp
.
cuas_lma_maxk
;
// = 5.0; // Minimal K (overshoot) > 3.8
double
lma_maxk
=
clt_parameters
.
imp
.
cuas_lma_maxk
;
// = 5.0; // Minimal K (overshoot) > 3.8
double
lma_a2a
=
clt_parameters
.
imp
.
cuas_lma_a2a
;
// = 0.7; // Minimal ratio of the maximal pixel to the amplitude
double
lma_a2a
=
clt_parameters
.
imp
.
cuas_lma_a2a
;
// = 0.7; // Minimal ratio of the maximal pixel to the amplitude
double
target_horizon
=
clt_parameters
.
imp
.
cuas_horizon
;
// Handling overall target scores
// Handling overall target scores
double
min_score_mv
=
clt_parameters
.
imp
.
cuas_score_mv
;
double
min_score_mv
=
clt_parameters
.
imp
.
cuas_score_mv
;
...
@@ -3986,6 +4000,16 @@ public class CuasMotion {
...
@@ -3986,6 +4000,16 @@ public class CuasMotion {
motion_scan
,
// double [][][] scan0, // all tried for targets
motion_scan
,
// double [][][] scan0, // all tried for targets
targets_bad
,
// double [][][] scan1) // good targets
targets_bad
,
// double [][][] scan1) // good targets
remain
);
remain
);
// remove known good (already processed)
motion_scan
=
subtractMotionScans
(
// motion vectors
motion_scan
,
// double [][][] scan0, // all tried for targets
targets_good
,
// double [][][] scan1) // good targets (lma-vect)
remain
);
if
(
debugLevel
>
-
4
)
printRemain
(
remain
,
"filtered wo good"
,
true
);
if
(
save_filtered_low
)
{
if
(
save_filtered_low
)
{
//title_vf_all
//title_vf_all
ImagePlus
imp_ms1
=
showVectorFieldsSequence
(
ImagePlus
imp_ms1
=
showVectorFieldsSequence
(
...
@@ -3994,7 +4018,8 @@ public class CuasMotion {
...
@@ -3994,7 +4018,8 @@ public class CuasMotion {
speed_pref
,
// double speed_pref,
speed_pref
,
// double speed_pref,
speed_boost
,
// double speed_boost,
speed_boost
,
// double speed_boost,
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
model_prefix
+
"MS1-NOBAD-n"
+
niter
,
// String title,
// model_prefix+"MS1-NOBAD-n"+niter,// String title,
model_prefix
+
"MS1-NOBAD-NOGOOD-n"
+
niter
,
// String title,
false
,
// boolean nan_effective_strength,
false
,
// boolean nan_effective_strength,
!
batch_mode
,
// boolean show,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
cuasMotion
.
tilesX
);
// int tilesX) {
...
@@ -4030,6 +4055,7 @@ public class CuasMotion {
...
@@ -4030,6 +4055,7 @@ public class CuasMotion {
boolean
[][]
filter5
=
filterMotionScanTarget
(
boolean
[][]
filter5
=
filterMotionScanTarget
(
effective_strength
,
// double [][] confidence,
effective_strength
,
// double [][] confidence,
min_score_mv
,
// double min_confidence,
min_score_mv
,
// double min_confidence,
target_horizon
,
// final double lma_horizon, // target below horizon
cuasMotion
.
tilesX
,
// final int tilesX,
cuasMotion
.
tilesX
,
// final int tilesX,
max_range
,
// final int range, // 1 or 2
max_range
,
// final int range, // 1 or 2
remain
,
// final int [] remain){
remain
,
// final int [] remain){
...
@@ -4065,12 +4091,14 @@ public class CuasMotion {
...
@@ -4065,12 +4091,14 @@ public class CuasMotion {
double
[][][]
motion_scan_filtered
=
applyFilter
(
// motion vectors
double
[][][]
motion_scan_filtered
=
applyFilter
(
// motion vectors
motion_scan
,
// double [][][] motion_scan,
motion_scan
,
// double [][][] motion_scan,
filter5
);
// boolean [][] filter5)
filter5
);
// boolean [][] filter5)
/*
// remove known good (already processed)
// remove known good (already processed)
motion_scan_filtered = subtractMotionScans( // motion vectors
motion_scan_filtered = subtractMotionScans( // motion vectors
motion_scan_filtered, // double [][][] scan0, // all tried for targets
motion_scan_filtered, // double [][][] scan0, // all tried for targets
targets_good, // double [][][] scan1) // good targets (lma-vect)
targets_good, // double [][][] scan1) // good targets (lma-vect)
remain);
remain);
if (debugLevel > -4) printRemain(remain, "filtered wo good", true);
if (debugLevel > -4) printRemain(remain, "filtered wo good", true);
*/
// Anything remains? we'll see after extension
// Anything remains? we'll see after extension
double
[][][]
extended_scan
=
extendMotionScan
(
double
[][][]
extended_scan
=
extendMotionScan
(
motion_scan_filtered
,
// final double [][][] motion_scan,
motion_scan_filtered
,
// final double [][][] motion_scan,
...
@@ -4293,6 +4321,7 @@ public class CuasMotion {
...
@@ -4293,6 +4321,7 @@ public class CuasMotion {
lma_mink
,
// double lma_mink, // = 1.0; // Minimal K (overshoot) = 1.0
lma_mink
,
// double lma_mink, // = 1.0; // Minimal K (overshoot) = 1.0
lma_maxk
,
// double lma_maxk, // = 1.0; // Minimal K (overshoot) = 3.0
lma_maxk
,
// double lma_maxk, // = 1.0; // Minimal K (overshoot) = 3.0
lma_a2a
,
// double lma_a2a,
lma_a2a
,
// double lma_a2a,
target_horizon
,
// double lma_horizon, // horizon as maximal pixel Y
slice_titles
,
// String [] slice_titles, //
slice_titles
,
// String [] slice_titles, //
model_prefix
+
"-TARGETS-FILTERED-LMA-n"
+
niter
,
// String title_targets_filt, // empty
model_prefix
+
"-TARGETS-FILTERED-LMA-n"
+
niter
,
// String title_targets_filt, // empty
failures_debug
,
// double [][][] failures_debug,
failures_debug
,
// double [][][] failures_debug,
...
@@ -4368,6 +4397,7 @@ public class CuasMotion {
...
@@ -4368,6 +4397,7 @@ public class CuasMotion {
double
lma_minxy
=
0.8
;
double
lma_minxy
=
0.8
;
double
[][][]
failures_debug
=
(
intermed_low
)
?
(
new
double
[
targets_good
.
length
][][])
:
null
;
double
[][][]
failures_debug
=
(
intermed_low
)
?
(
new
double
[
targets_good
.
length
][][])
:
null
;
System
.
out
.
println
(
"\nUsing horizon cutoff at "
+
target_horizon
);
double
[][]
target_scores
=
getEffectiveStrengthLMA
(
double
[][]
target_scores
=
getEffectiveStrengthLMA
(
targets_good
,
// final double [][][] target_coords, // LMA
targets_good
,
// final double [][][] target_coords, // LMA
factor_lim
,
// final double importance_limit,
factor_lim
,
// final double importance_limit,
...
@@ -4382,6 +4412,8 @@ public class CuasMotion {
...
@@ -4382,6 +4412,8 @@ public class CuasMotion {
lma_mink
,
// final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_mink
,
// final double lma_mink, // = 0.0; // Minimal K (overshoot) = 1.0
lma_maxk
,
// final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0
lma_maxk
,
// final double lma_maxk, // = 5.0; // Minimal K (overshoot) = 3.0
lma_a2a
,
// final double lma_a2a,
lma_a2a
,
// final double lma_a2a,
target_horizon
,
// final double lma_horizon, // target below horizon
lma_minxy
,
// final double lma_minxy, // 0.8
lma_minxy
,
// final double lma_minxy, // 0.8
cuasMotion
.
tilesX
,
// final int tilesX,
cuasMotion
.
tilesX
,
// final int tilesX,
failures_debug
,
// final double [][][] failures_debug,
failures_debug
,
// final double [][][] failures_debug,
...
@@ -4414,6 +4446,7 @@ public class CuasMotion {
...
@@ -4414,6 +4446,7 @@ public class CuasMotion {
boolean
[][]
filter5
=
filterMotionScanTarget
(
boolean
[][]
filter5
=
filterMotionScanTarget
(
target_scores
,
// double [][] confidence,
target_scores
,
// double [][] confidence,
min_score_lma
,
// min_mv_strength, // double min_confidence,
min_score_lma
,
// min_mv_strength, // double min_confidence,
target_horizon
,
// final double lma_horizon, // target below horizon
cuasMotion
.
tilesX
,
// final int tilesX,
cuasMotion
.
tilesX
,
// final int tilesX,
max_range
,
// final int range, // 1 or 2
max_range
,
// final int range, // 1 or 2
remain
,
// final int [] remain){
remain
,
// final int [] remain){
...
@@ -4708,6 +4741,7 @@ public class CuasMotion {
...
@@ -4708,6 +4741,7 @@ public class CuasMotion {
lma_mink
,
// double lma_mink, // = 1.0; // Minimal K (overshoot) = 1.0
lma_mink
,
// double lma_mink, // = 1.0; // Minimal K (overshoot) = 1.0
lma_maxk
,
// double lma_maxk, // = 1.0; // Minimal K (overshoot) = 3.0
lma_maxk
,
// double lma_maxk, // = 1.0; // Minimal K (overshoot) = 3.0
lma_a2a
,
// double lma_a2a,
lma_a2a
,
// double lma_a2a,
target_horizon
,
// double lma_horizon, // horizon as maximal pixel Y
slice_titles
,
// String [] slice_titles, //
slice_titles
,
// String [] slice_titles, //
model_prefix
+
"-LMA-FILTERED"
,
// String title_targets_filt,
model_prefix
+
"-LMA-FILTERED"
,
// String title_targets_filt,
null
,
// double [][][] failures_debug,
null
,
// double [][][] failures_debug,
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
View file @
3711a65e
...
@@ -60,6 +60,7 @@ public class CuasMotionLMA {
...
@@ -60,6 +60,7 @@ public class CuasMotionLMA {
public
static
final
int
FAIL_K_LOW
=
7
;
// Overshoot is too low (not used, it can be down to 0)
public
static
final
int
FAIL_K_LOW
=
7
;
// Overshoot is too low (not used, it can be down to 0)
public
static
final
int
FAIL_K_HIGH
=
8
;
// Overshoot is too high
public
static
final
int
FAIL_K_HIGH
=
8
;
// Overshoot is too high
public
static
final
int
FAIL_FAR
=
9
;
// Peak is too far from the center
public
static
final
int
FAIL_FAR
=
9
;
// Peak is too far from the center
public
static
final
int
FAIL_HORIZON
=
10
;
// Peak is below horizon
private
int
width
;
private
int
width
;
private
double
[][]
window
;
private
double
[][]
window
;
...
...
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