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
17265194
Commit
17265194
authored
Sep 09, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging and fine tuning detection
parent
673cd8a6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
69 deletions
+100
-69
ShowDoubleFloatArrays.java
.../java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
+2
-0
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+96
-34
CuasMotionLMA.java
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
+1
-0
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+1
-35
No files found.
src/main/java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
View file @
17265194
...
@@ -1091,6 +1091,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
...
@@ -1091,6 +1091,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
int
num_slices
,
// (0 - all)
int
num_slices
,
// (0 - all)
int
[]
wh
)
{
int
[]
wh
)
{
ImagePlus
imp
=
null
;
ImagePlus
imp
=
null
;
System
.
out
.
println
(
"readFloatArray(): reading "
+
file_path
);
try
{
try
{
imp
=
new
ImagePlus
(
file_path
);
imp
=
new
ImagePlus
(
file_path
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -1111,6 +1112,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
...
@@ -1111,6 +1112,7 @@ G= Y +Pr*(- 2*Kr*(1-Kr))/Kg + Pb*(-2*Kb*(1-Kb))/Kg
int
[]
wh
,
// should be null or int[2]
int
[]
wh
,
// should be null or int[2]
String
[][]
ptop_titles
,
// should be null or String [1][]
String
[][]
ptop_titles
,
// should be null or String [1][]
String
[][]
pslice_titles
){
// should be null or String [1][]
String
[][]
pslice_titles
){
// should be null or String [1][]
System
.
out
.
println
(
"readDoubleHyperstack(): reading "
+
path
);
ImagePlus
imp
=
new
ImagePlus
(
path
);
ImagePlus
imp
=
new
ImagePlus
(
path
);
if
(
imp
.
getWidth
()
==
0
)
{
if
(
imp
.
getWidth
()
==
0
)
{
System
.
out
.
println
(
"testSynthetic(): Failed reading Vector field from: "
+
path
);
System
.
out
.
println
(
"testSynthetic(): Failed reading Vector field from: "
+
path
);
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
17265194
...
@@ -3183,7 +3183,7 @@ public class CuasMotion {
...
@@ -3183,7 +3183,7 @@ public class CuasMotion {
// duplicate first/last, interpolate middle
// duplicate first/last, interpolate middle
if
(
Double
.
isNaN
(
temp_line
[
x
]))
{
if
(
Double
.
isNaN
(
temp_line
[
x
]))
{
int
i
;
int
i
;
for
(
i
=
1
;
Double
.
isNaN
(
temp_line
[
i
*
width
+
x
])
&&
(
i
<
num_scenes
);
i
++);
for
(
i
=
1
;
(
i
<
num_scenes
)
&&
Double
.
isNaN
(
temp_line
[
i
*
width
+
x
])
;
i
++);
//Index 318080 out of bounds for length 318080
temp_line
[
x
]
=
temp_line
[
i
*
width
+
x
];
temp_line
[
x
]
=
temp_line
[
i
*
width
+
x
];
}
}
if
(
Double
.
isNaN
(
temp_line
[(
num_scenes
-
1
)*
width
+
x
]))
{
if
(
Double
.
isNaN
(
temp_line
[(
num_scenes
-
1
)*
width
+
x
]))
{
...
@@ -6989,8 +6989,12 @@ public class CuasMotion {
...
@@ -6989,8 +6989,12 @@ public class CuasMotion {
public
static
void
calcMathingTargetsLengths
(
// calculate number of consecutive keyframes connected to each target
public
static
void
calcMathingTargetsLengths
(
// calculate number of consecutive keyframes connected to each target
final
double
[][][][]
targets_multi
,
final
double
[][][][]
targets_multi
,
final
double
max_mismatch
,
// if <=0, do not calculate mismatch_ba and filter
final
double
max_mismatch
,
// if <=0, do not calculate mismatch_ba and filter
// final double good_mismatch, // 0.4; // do not add to score if worse
final
double
slow_fast_mismatch
,
final
double
slow_fast_mismatch
,
final
double
match_len_pwr
,
// 0.5; // raise matching length to this power for calculating score
final
double
seq_travel
,
final
int
tilesX
)
{
final
int
tilesX
)
{
final
double
good_mismatch
=
max_mismatch
;
final
double
max_mismatch2
=
max_mismatch
*
max_mismatch
;
final
double
max_mismatch2
=
max_mismatch
*
max_mismatch
;
final
double
slow_fast_mismatch2
=
slow_fast_mismatch
*
slow_fast_mismatch
;
final
double
slow_fast_mismatch2
=
slow_fast_mismatch
*
slow_fast_mismatch
;
// Will only consider not-failed targets
// Will only consider not-failed targets
...
@@ -7133,19 +7137,33 @@ public class CuasMotion {
...
@@ -7133,19 +7137,33 @@ public class CuasMotion {
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
{
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
{
double
[]
target
=
targets
[
ntarg
];
double
[]
target
=
targets
[
ntarg
];
if
((
target
!=
null
)
&&
(
target
[
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
))
{
if
((
target
!=
null
)
&&
(
target
[
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
))
{
target
[
CuasMotionLMA
.
RSLT_BEFORE_LENGTH
]
=
len_ba
[
0
][
nSeq
][
ntile
][
ntarg
];
target
[
CuasMotionLMA
.
RSLT_AFTER_LENGTH
]
=
len_ba
[
1
][
nSeq
][
ntile
][
ntarg
];
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]
=
0
;
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]
=
0
;
for
(
int
ba
=
0
;
ba
<
len_ba
.
length
;
ba
++)
{
for
(
int
ba
=
0
;
ba
<
len_ba
.
length
;
ba
++)
{
if
(
len_ba
[
ba
][
nSeq
][
ntile
]
!=
null
)
{
if
(
len_ba
[
ba
][
nSeq
][
ntile
]
!=
null
)
{
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]+=
len_ba
[
ba
][
nSeq
][
ntile
][
ntarg
];
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]+=
len_ba
[
ba
][
nSeq
][
ntile
][
ntarg
];
}
}
}
}
target
[
CuasMotionLMA
.
RSLT_BEFORE_LENGTH
]
=
len_ba
[
0
][
nSeq
][
ntile
][
ntarg
];
target
[
CuasMotionLMA
.
RSLT_AFTER_LENGTH
]
=
len_ba
[
1
][
nSeq
][
ntile
][
ntarg
];
double
[]
bbox
=
getBbox
(
double
[]
bbox
=
getBbox
(
bbox_ba
[
0
][
nSeq
][
ntile
][
ntarg
],
// double [] bbox1,
bbox_ba
[
0
][
nSeq
][
ntile
][
ntarg
],
// double [] bbox1,
bbox_ba
[
1
][
nSeq
][
ntile
][
ntarg
]);
//double [] bbox2);
bbox_ba
[
1
][
nSeq
][
ntile
][
ntarg
]);
//double [] bbox2);
target
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]
=
Math
.
sqrt
(
getDiagonal2
(
bbox
));
target
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]
=
Math
.
sqrt
(
getDiagonal2
(
bbox
));
// calculate related quality factors (moved from getEffective...())
target
[
CuasMotionLMA
.
RSLT_QMATCH_LEN
]
=
Math
.
pow
(
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
],
match_len_pwr
);
// 1.0 if in every scene;
target
[
CuasMotionLMA
.
RSLT_QTRAVEL
]
=
Math
.
max
((
target
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]
-
seq_travel
)/
seq_travel
,
0
);
double
MM_BEFORE
=
target
[
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
];
double
MM_AFTER
=
target
[
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
];
target
[
CuasMotionLMA
.
RSLT_QMATCH
]
=
0
;
if
(
MM_BEFORE
<=
good_mismatch
)
{
target
[
CuasMotionLMA
.
RSLT_QMATCH
]
+=
Math
.
max
(
0
,(
good_mismatch
-
MM_BEFORE
)/
good_mismatch
);
// 0 .. 1
}
if
(
MM_AFTER
<=
good_mismatch
)
{
target
[
CuasMotionLMA
.
RSLT_QMATCH
]
+=
Math
.
max
(
0
,(
good_mismatch
-
MM_AFTER
)/
good_mismatch
);
// 0 .. 1
}
if
(
ntile
==
dbg_tile
)
{
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"calcMathingTargetsLengths().4 nSeq = "
+
nSeq
+
", targets["
+
ntarg
+
"][CuasMotionLMA.RSLT_MATCH_LENGTH]="
+
System
.
out
.
println
(
"calcMathingTargetsLengths().4 nSeq = "
+
nSeq
+
", targets["
+
ntarg
+
"][CuasMotionLMA.RSLT_MATCH_LENGTH]="
+
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]+
", travel="
+
target
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]);
target
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
]+
", travel="
+
target
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]);
...
@@ -7982,10 +8000,10 @@ public class CuasMotion {
...
@@ -7982,10 +8000,10 @@ public class CuasMotion {
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,
0
,
// max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
0
,
// max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
good_mismatch
,
// final double good_mismatch, //do not add to score if worse
///
good_mismatch, // final double good_mismatch, //do not add to score if worse
slow_fast_mismatch
,
// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
slow_fast_mismatch
,
// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
match_len_pwr
,
// final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
///
match_len_pwr, // final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
seq_travel
,
// final double seq_travel,
///
seq_travel, // final double seq_travel,
fail_mismatch
,
// final boolean fail_mismatch,
fail_mismatch
,
// final boolean fail_mismatch,
target_horizon
,
// final double lma_horizon, // horizon as maximal pixel Y
target_horizon
,
// final double lma_horizon, // horizon as maximal pixel Y
cuasMotion
.
tilesX
);
// final int tilesX,
cuasMotion
.
tilesX
);
// final int tilesX,
...
@@ -8060,7 +8078,6 @@ public class CuasMotion {
...
@@ -8060,7 +8078,6 @@ public class CuasMotion {
if
(
debugLevel
>
-
4
)
{
if
(
debugLevel
>
-
4
)
{
System
.
out
.
println
(
"\n========================== Starting centered iterations =============================.\n"
);
System
.
out
.
println
(
"\n========================== Starting centered iterations =============================.\n"
);
}
}
// second pass, using non-centered targets
// second pass, using non-centered targets
int
niter_lim
=
niter
+
num_cycles
;
int
niter_lim
=
niter
+
num_cycles
;
int
iter_show1
=
iter_show
+
niter
;
int
iter_show1
=
iter_show
+
niter
;
...
@@ -8291,10 +8308,10 @@ public class CuasMotion {
...
@@ -8291,10 +8308,10 @@ public class CuasMotion {
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,
0
,
// max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
0
,
// max_mismatch, // final double max_mismatch, apply only during final, when mismatch scores are calculated
good_mismatch
,
// final double good_mismatch, //do not add to score if worse
///
good_mismatch, // final double good_mismatch, //do not add to score if worse
slow_fast_mismatch
,
// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
slow_fast_mismatch
,
// final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
match_len_pwr
,
// final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
///
match_len_pwr, // final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
seq_travel
,
// final double seq_travel,
///
seq_travel, // final double seq_travel,
fail_mismatch
,
// final boolean fail_mismatch,
fail_mismatch
,
// final boolean fail_mismatch,
target_horizon
,
// final double lma_horizon, // horizon as maximal pixel Y
target_horizon
,
// final double lma_horizon, // horizon as maximal pixel Y
cuasMotion
.
tilesX
);
// final int tilesX,
cuasMotion
.
tilesX
);
// final int tilesX,
...
@@ -8353,6 +8370,7 @@ public class CuasMotion {
...
@@ -8353,6 +8370,7 @@ public class CuasMotion {
boolean
good_only
=
false
;
boolean
good_only
=
false
;
boolean
show_empty
=
true
;
// false; // show scenes with no (valid) targets
boolean
show_empty
=
true
;
// false; // show scenes with no (valid) targets
if
(
intermed_low
)
{
// targets_good now has
if
(
intermed_low
)
{
// targets_good now has
ImagePlus
imp_good
=
showTargetSequence
(
ImagePlus
imp_good
=
showTargetSequence
(
target_sequence_multi
,
// double [][][] vector_fields_sequence,
target_sequence_multi
,
// double [][][] vector_fields_sequence,
...
@@ -8636,6 +8654,35 @@ public class CuasMotion {
...
@@ -8636,6 +8654,35 @@ public class CuasMotion {
return
filter5
;
return
filter5
;
}
}
// mark all "used" targets (non-centered, after all centered are added) as failed
public
static
void
failUsed
(
final
double
[][][][]
target_sequence
)
{
final
int
num_seq
=
target_sequence
.
length
;
final
int
num_tiles
=
target_sequence
[
0
].
length
;
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
();
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
ai
.
set
(
0
);
// mark selected (non-centered) targets as "used"
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
for
(
int
ntile
=
0
;
ntile
<
num_tiles
;
ntile
++)
if
(
target_sequence
[
nSeq
][
ntile
]
!=
null
)
{
for
(
int
ntarg
=
0
;
ntarg
<
target_sequence
[
nSeq
][
ntile
].
length
;
ntarg
++)
{
double
[]
target
=
target_sequence
[
nSeq
][
ntile
][
ntarg
];
if
((
target
!=
null
)
&&
(
target
[
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
)
&&
(
target
[
CuasMotionLMA
.
RSLT_CENTERED
]
==
CuasMotionLMA
.
CENTERED_USED
))
{
target
[
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_USED
;
}
}
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
}
public
static
void
getEffectiveStrengthLMA
(
public
static
void
getEffectiveStrengthLMA
(
final
double
[][][][]
target_sequence_multi
,
// modifies certain fields (scores)
final
double
[][][][]
target_sequence_multi
,
// modifies certain fields (scores)
final
double
target_strength
,
final
double
target_strength
,
...
@@ -8650,10 +8697,10 @@ public class CuasMotion {
...
@@ -8650,10 +8697,10 @@ public class CuasMotion {
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
max_mismatch
,
final
double
max_mismatch
,
final
double
good_mismatch
,
// 0.4; // do not add to score if worse
///
final double good_mismatch, // 0.4; // do not add to score if worse
final
double
slow_fast_mismatch
,
final
double
slow_fast_mismatch
,
final
double
match_len_pwr
,
// 0.5; // raise matching length to this power for calculating score
///
final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
final
double
seq_travel
,
///
final double seq_travel,
final
boolean
fail_mismatch
,
final
boolean
fail_mismatch
,
final
double
lma_horizon
,
// horizon as maximal pixel Y
final
double
lma_horizon
,
// horizon as maximal pixel Y
final
int
tilesX
)
{
final
int
tilesX
)
{
...
@@ -8678,7 +8725,10 @@ public class CuasMotion {
...
@@ -8678,7 +8725,10 @@ public class CuasMotion {
if
(
targets
!=
null
)
{
if
(
targets
!=
null
)
{
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
if
(
targets
[
ntarg
]
!=
null
){
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
if
(
targets
[
ntarg
]
!=
null
){
double
[]
lma_rslts
=
targets
[
ntarg
];
double
[]
lma_rslts
=
targets
[
ntarg
];
if
(
lma_rslts
!=
null
)
{
// if ((lma_rslts != null) && (Double.isNaN(lma_rslts[CuasMotionLMA.RSLT_FAIL]) || (lma_rslts[CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NONE))) {
// this method should be called only when [CuasMotionLMA.RSLT_FAIL] is not yet defined, only for the new LMA data is calculated
if
((
lma_rslts
!=
null
)
&&
Double
.
isNaN
(
lma_rslts
[
CuasMotionLMA
.
RSLT_FAIL
]))
{
lma_rslts
[
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_NONE
;
lma_rslts
[
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_NONE
;
double
CENT_STR
=
lma_rslts
[
CuasMotionLMA
.
RSLT_CENT_MX
];
double
CENT_STR
=
lma_rslts
[
CuasMotionLMA
.
RSLT_CENT_MX
];
double
CENT_FRAC
=
lma_rslts
[
CuasMotionLMA
.
RSLT_CENT_F
];
double
CENT_FRAC
=
lma_rslts
[
CuasMotionLMA
.
RSLT_CENT_F
];
...
@@ -8780,7 +8830,7 @@ public class CuasMotion {
...
@@ -8780,7 +8830,7 @@ public class CuasMotion {
double
[]
quality_factors
=
new
double
[
IMPORTANCE_LENGTH
];
double
[]
quality_factors
=
new
double
[
IMPORTANCE_LENGTH
];
if
(!
failed
)
{
if
(!
failed
)
{
lma_rslts
[
CuasMotionLMA
.
RSLT_FAIL
]
=
0
;
lma_rslts
[
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_NONE
;
double
inv_rms
=
1.0
/
RMSE
;
double
inv_rms
=
1.0
/
RMSE
;
double
inv_rms_lim
=
1.0
/
lma_arms
;
double
inv_rms_lim
=
1.0
/
lma_arms
;
double
inv_rel_rms
=
1.0
/
RMSE_A
;
// A/RMSE;
double
inv_rel_rms
=
1.0
/
RMSE_A
;
// A/RMSE;
...
@@ -8790,15 +8840,19 @@ public class CuasMotion {
...
@@ -8790,15 +8840,19 @@ public class CuasMotion {
quality_factors
[
IMPORTANCE_RMS
]
=
Math
.
max
(
0
,(
inv_rms
-
inv_rms_lim
)/
inv_rms_lim
);
// only >0 for small max-es
quality_factors
[
IMPORTANCE_RMS
]
=
Math
.
max
(
0
,(
inv_rms
-
inv_rms_lim
)/
inv_rms_lim
);
// only >0 for small max-es
quality_factors
[
IMPORTANCE_RMS_A
]
=
Math
.
max
(
0
,(
inv_rel_rms
-
inv_rel_rms_lim
)/
inv_rel_rms_lim
);
// only >0 for small max-es
quality_factors
[
IMPORTANCE_RMS_A
]
=
Math
.
max
(
0
,(
inv_rel_rms
-
inv_rel_rms_lim
)/
inv_rel_rms_lim
);
// only >0 for small max-es
if
(
MM_BEFORE
<=
good_mismatch
)
{
quality_factors
[
IMPORTANCE_MISMATCH
]
+=
Math
.
max
(
0
,(
good_mismatch
-
MM_BEFORE
)/
good_mismatch
);
// 0 .. 1
}
if
(
MM_AFTER
<=
good_mismatch
)
{
quality_factors
[
IMPORTANCE_MISMATCH
]
+=
Math
.
max
(
0
,(
good_mismatch
-
MM_AFTER
)/
good_mismatch
);
// 0 .. 1
}
quality_factors
[
IMPORTANCE_MATCH_LEN
]
=
Math
.
pow
(
lma_rslts
[
CuasMotionLMA
.
RSLT_MATCH_LENGTH
],
match_len_pwr
);
// 1.0 if in every scene
quality_factors
[
IMPORTANCE_CENTER
]
=
cxy
*
cxy
;
quality_factors
[
IMPORTANCE_CENTER
]
=
cxy
*
cxy
;
quality_factors
[
IMPORTANCE_TRAVEL
]
=
Math
.
max
((
lma_rslts
[
CuasMotionLMA
.
RSLT_SEQ_TRAVEL
]
-
seq_travel
)/
seq_travel
,
0
);
// if (MM_BEFORE <= good_mismatch) {
// quality_factors[IMPORTANCE_MISMATCH] += Math.max(0,(good_mismatch - MM_BEFORE)/good_mismatch); // 0 .. 1
// }
// if (MM_AFTER <= good_mismatch) {
// quality_factors[IMPORTANCE_MISMATCH] += Math.max(0,(good_mismatch - MM_AFTER)/good_mismatch); // 0 .. 1
// }
/// quality_factors[IMPORTANCE_MATCH_LEN] = Math.pow(lma_rslts[CuasMotionLMA.RSLT_MATCH_LENGTH], match_len_pwr);// 1.0 if in every scene
/// quality_factors[IMPORTANCE_TRAVEL] = Math.max((lma_rslts[CuasMotionLMA.RSLT_SEQ_TRAVEL] - seq_travel)/seq_travel, 0);
// final double seq_travel,
// final double seq_travel,
}
}
...
@@ -8806,10 +8860,10 @@ public class CuasMotion {
...
@@ -8806,10 +8860,10 @@ public class CuasMotion {
lma_rslts
[
CuasMotionLMA
.
RSLT_QA
]
=
quality_factors
[
IMPORTANCE_A
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QA
]
=
quality_factors
[
IMPORTANCE_A
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QRMS
]
=
quality_factors
[
IMPORTANCE_RMS
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QRMS
]
=
quality_factors
[
IMPORTANCE_RMS
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QRMS_A
]
=
quality_factors
[
IMPORTANCE_RMS_A
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QRMS_A
]
=
quality_factors
[
IMPORTANCE_RMS_A
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QMATCH
]
=
quality_factors
[
IMPORTANCE_MISMATCH
];
///
lma_rslts[CuasMotionLMA.RSLT_QMATCH] = quality_factors[IMPORTANCE_MISMATCH];
lma_rslts
[
CuasMotionLMA
.
RSLT_QCENTER
]
=
quality_factors
[
IMPORTANCE_CENTER
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QCENTER
]
=
quality_factors
[
IMPORTANCE_CENTER
];
lma_rslts
[
CuasMotionLMA
.
RSLT_QMATCH_LEN
]
=
quality_factors
[
IMPORTANCE_MATCH_LEN
];
///
lma_rslts[CuasMotionLMA.RSLT_QMATCH_LEN] = quality_factors[IMPORTANCE_MATCH_LEN];
lma_rslts
[
CuasMotionLMA
.
RSLT_QTRAVEL
]
=
quality_factors
[
IMPORTANCE_TRAVEL
];
///
lma_rslts[CuasMotionLMA.RSLT_QTRAVEL] = quality_factors[IMPORTANCE_TRAVEL];
}
}
}
}
}
}
...
@@ -9367,6 +9421,9 @@ public class CuasMotion {
...
@@ -9367,6 +9421,9 @@ public class CuasMotion {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_in
);
parentCLT
.
saveImagePlusInModelDirectory
(
imp_in
);
}
}
// Used non-centered tiles are not needed anymore, mark them as failed to simplify processing
failUsed
(
targets_multi
);
// final double [][][][] target_sequence) {
sortMultiTargets
(
sortMultiTargets
(
targets_multi
,
// final double [][][][] target_multi,
targets_multi
,
// final double [][][][] target_multi,
trim_nulls
);
// final boolean trim_nulls) { // trim null targets
trim_nulls
);
// final boolean trim_nulls) { // trim null targets
...
@@ -9412,6 +9469,8 @@ public class CuasMotion {
...
@@ -9412,6 +9469,8 @@ public class CuasMotion {
// which is better here?
// which is better here?
good_mismatch
,
// max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
good_mismatch
,
// max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
slow_fast_mismatch
,
// final double slow_fast_mismatch,
slow_fast_mismatch
,
// final double slow_fast_mismatch,
match_len_pwr
,
// final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
seq_travel
,
// final double seq_travel,
cuasMotion
.
tilesX
);
//final int tilesX)
cuasMotion
.
tilesX
);
//final int tilesX)
if
(
intermed_low
&&
debug_more
)
{
if
(
intermed_low
&&
debug_more
)
{
ImagePlus
imp_lengths
=
showTargetSequence
(
ImagePlus
imp_lengths
=
showTargetSequence
(
...
@@ -9425,7 +9484,7 @@ public class CuasMotion {
...
@@ -9425,7 +9484,7 @@ public class CuasMotion {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_lengths
);
parentCLT
.
saveImagePlusInModelDirectory
(
imp_lengths
);
}
}
/*
getEffectiveStrengthLMA(
getEffectiveStrengthLMA(
targets_multi, // final double [][][][] target_sequence_multi, // modifies certain fields (scores)
targets_multi, // final double [][][][] target_sequence_multi, // modifies certain fields (scores)
target_strength, // final double target_strength,
target_strength, // final double target_strength,
...
@@ -9442,12 +9501,14 @@ public class CuasMotion {
...
@@ -9442,12 +9501,14 @@ public class CuasMotion {
max_mismatch, // final double max_mismatch,
max_mismatch, // final double max_mismatch,
good_mismatch, // final double good_mismatch, //do not add to score if worse
good_mismatch, // final double good_mismatch, //do not add to score if worse
slow_fast_mismatch, // final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
slow_fast_mismatch, // final double slow_fast_mismatch, // // 1.5; allow larger mismatch between slow and fast
match_len_pwr
,
// final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
///
match_len_pwr, // final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
seq_travel
,
// final double seq_travel,
///
seq_travel, // final double seq_travel,
fail_mismatch, // final boolean fail_mismatch,
fail_mismatch, // final boolean fail_mismatch,
target_horizon, // final double lma_horizon, // target below horizon
target_horizon, // final double lma_horizon, // target below horizon
cuasMotion.tilesX); // final int tilesX,
cuasMotion.tilesX); // final int tilesX,
*/
// order/auto order with getEffectiveStrengthLMA()?
// int [] remain_es =
// int [] remain_es =
getScore
(
// calculates composite sceres
getScore
(
// calculates composite sceres
targets_multi
,
// final double [][][][] target_sequence_multi, // modifies certain fields (scores)
targets_multi
,
// final double [][][][] target_sequence_multi, // modifies certain fields (scores)
...
@@ -9576,6 +9637,8 @@ public class CuasMotion {
...
@@ -9576,6 +9637,8 @@ public class CuasMotion {
// which is better here?
// which is better here?
good_mismatch
,
// max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
good_mismatch
,
// max_mismatch, // final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
slow_fast_mismatch
,
// final double slow_fast_mismatch,
slow_fast_mismatch
,
// final double slow_fast_mismatch,
match_len_pwr
,
// final double match_len_pwr, // 0.5; // raise matching length to this power for calculating score
seq_travel
,
// final double seq_travel,
cuasMotion
.
tilesX
);
//final int tilesX)
cuasMotion
.
tilesX
);
//final int tilesX)
if
(
intermed_low
)
{
// && debug_more) {
if
(
intermed_low
)
{
// && debug_more) {
ImagePlus
imp_lengths
=
showTargetSequence
(
ImagePlus
imp_lengths
=
showTargetSequence
(
...
@@ -9632,8 +9695,7 @@ public class CuasMotion {
...
@@ -9632,8 +9695,7 @@ public class CuasMotion {
if
(
targets
!=
null
)
{
if
(
targets
!=
null
)
{
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
if
(
targets
[
ntarg
]
!=
null
){
for
(
int
ntarg
=
0
;
ntarg
<
targets
.
length
;
ntarg
++)
if
(
targets
[
ntarg
]
!=
null
){
double
[]
target
=
targets
[
ntarg
];
double
[]
target
=
targets
[
ntarg
];
if
((
target
!=
null
)
&&
(
target
[
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
)
&&
if
((
target
!=
null
)
&&
(
target
[
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
))
{
// && (target[CuasMotionLMA.RSLT_CENTERED] != CuasMotionLMA.CENTERED_USED)) {
(
target
[
CuasMotionLMA
.
RSLT_CENTERED
]
!=
CuasMotionLMA
.
CENTERED_USED
))
{
if
(
filter5
[
nSeq
][
ntile
]
>=
0
)
{
if
(
filter5
[
nSeq
][
ntile
]
>=
0
)
{
if
(
filter5
[
nSeq
][
ntile
]
==
ntarg
)
{
if
(
filter5
[
nSeq
][
ntile
]
==
ntarg
)
{
targets
[
ntarg
][
CuasMotionLMA
.
RSLT_STRONGER
]
=
Double
.
NaN
;
targets
[
ntarg
][
CuasMotionLMA
.
RSLT_STRONGER
]
=
Double
.
NaN
;
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
View file @
17265194
...
@@ -124,6 +124,7 @@ public class CuasMotionLMA {
...
@@ -124,6 +124,7 @@ public class CuasMotionLMA {
public
static
final
int
FAIL_MISMATCH
=
17
;
// Mismatch on both ends is too high
public
static
final
int
FAIL_MISMATCH
=
17
;
// Mismatch on both ends is too high
public
static
final
int
FAIL_NEIGHBOR
=
18
;
// failed because some neighbor is stronger
public
static
final
int
FAIL_NEIGHBOR
=
18
;
// failed because some neighbor is stronger
public
static
final
int
FAIL_DUPLICATE
=
19
;
// coordinate are (almost) the same as those of a stronger tile
public
static
final
int
FAIL_DUPLICATE
=
19
;
// coordinate are (almost) the same as those of a stronger tile
public
static
final
int
FAIL_USED
=
20
;
// non-centered used to generate centered, remove this
public
static
final
int
CENTERED_NO
=
0
;
public
static
final
int
CENTERED_NO
=
0
;
public
static
final
int
CENTERED_YES
=
1
;
public
static
final
int
CENTERED_YES
=
1
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
17265194
...
@@ -6171,6 +6171,7 @@ public class QuadCLTCPU {
...
@@ -6171,6 +6171,7 @@ public class QuadCLTCPU {
String
x3d_path
=
readX3dDirectory
(
correctionsParameters
.
getModelName
(
image_name
));
String
x3d_path
=
readX3dDirectory
(
correctionsParameters
.
getModelName
(
image_name
));
String
file_name
=
image_name
+
suffix
;
String
file_name
=
image_name
+
suffix
;
String
file_path
=
x3d_path
+
Prefs
.
getFileSeparator
()
+
file_name
+
".tiff"
;
String
file_path
=
x3d_path
+
Prefs
.
getFileSeparator
()
+
file_name
+
".tiff"
;
System
.
out
.
println
(
"readImagePlusFromModelDirectory(): reading "
+
file_path
);
ImagePlus
imp
=
null
;
ImagePlus
imp
=
null
;
try
{
try
{
imp
=
new
ImagePlus
(
file_path
);
imp
=
new
ImagePlus
(
file_path
);
...
@@ -6184,41 +6185,6 @@ public class QuadCLTCPU {
...
@@ -6184,41 +6185,6 @@ public class QuadCLTCPU {
}
}
/*
public float [][] readFloatArrayFromThisModelDirectory(
String suffix,
int num_slices, // (0 - all)
int [] wh)
{
String x3d_path = getImagePath(); // getX3dDirectory();
String file_name = image_name + suffix;
String file_path = x3d_path + Prefs.getFileSeparator() + file_name + ".tiff";
ImagePlus imp = null;
try {
imp = new ImagePlus(file_path);
} catch (Exception e) {
System.out.println ("Failed to open "+file_path+", will generate it");
}
if ((imp == null) || (imp.getTitle() == null) || (imp.getTitle().equals(""))) {
return null;
}
ImageStack imageStack = imp.getStack();
int nChn=imageStack.getSize();
if ((num_slices > 0) && (num_slices < nChn)) {
nChn = num_slices;
}
float [][] result = new float [nChn][];
for (int n = 0; n < nChn; n++) {
result[n] = (float[]) imageStack.getPixels(n + 1);
}
if (wh != null) {
wh[0] = imp.getWidth();
wh[1] = imp.getHeight();
}
return result;
}*/
public
void
saveDSI
()
{
saveDSI
(
this
.
dsi
);}
public
void
saveDSI
()
{
saveDSI
(
this
.
dsi
);}
...
...
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