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
61eb0d79
Commit
61eb0d79
authored
Aug 29, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working, contains debug print
parent
8cdf263c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
342 additions
and
75 deletions
+342
-75
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+331
-72
CuasMotionLMA.java
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
+4
-2
TileNeibs.java
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
+7
-1
No files found.
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
61eb0d79
...
...
@@ -1241,8 +1241,8 @@ public class CuasMotion {
param_select
[
CuasMotionLMA
.
INDX_C
]
=
lma_fit_c
;
param_select
[
CuasMotionLMA
.
INDX_RR0
]
=
lma_fit_r
;
param_select
[
CuasMotionLMA
.
INDX_K
]
=
lma_fit_k
;
final
int
dbg_tile
=
-(
33
+
34
*
80
);
//(38 + 45 * 80);
final
int
dbg_seq
=
-
15
;
final
int
dbg_tile
=
(
31
+
45
*
80
);
//(38 + 45 * 80);
final
int
dbg_seq
=
13
;
final
boolean
use_filters
=
(
lmax_flt_hsigma
>
0
)
&&
(
lmax_flt_lsigma
>
0
)
&&
(
lmax_flt_scale
>
0
);
// final boolean[] fpn_mask= no_border? (new boolean[0]) : null;
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
...
@@ -1267,7 +1267,7 @@ public class CuasMotion {
for
(
int
ntile
=
0
;
ntile
<
num_tiles
;
ntile
++)
{
if
(
target_sequence
[
nSeq
][
ntile
]
!=
null
)
{
double
[]
target
=
target_sequence
[
nSeq
][
ntile
].
clone
();
if
(
ntile
==
dbg_tile
)
{
// if (
(nSeq==dbg_seq) && (ntile == dbg_tile)) {
if
((
nSeq
==
dbg_seq
)
&&
(
ntile
==
dbg_tile
))
{
System
.
out
.
println
(
"getAccumulatedCoordinates(): nSeq="
+
nSeq
+
", ntile="
+
ntile
);
}
int
tileX
=
ntile
%
tilesX
;
...
...
@@ -1328,9 +1328,9 @@ public class CuasMotion {
if
(
sky_mask
!=
null
)
{
for
(
int
row
=
0
;
row
<
tile2
;
row
++)
{
int
mask_y
=
Math
.
min
(
height
-
1
,
Math
.
max
(
0
,
py0
+
y_mask_offs
));
int
mask_y
=
Math
.
min
(
height
-
1
,
Math
.
max
(
0
,
py0
+
y_mask_offs
+
row
));
for
(
int
col
=
0
;
col
<
tile2
;
col
++)
{
int
mask_x
=
Math
.
min
(
width
-
1
,
Math
.
max
(
0
,
px0
+
x_mask_offs
));
int
mask_x
=
Math
.
min
(
width
-
1
,
Math
.
max
(
0
,
px0
+
x_mask_offs
+
col
));
int
pindx
=
col
+
row
*
tile2
;
double
mask_val
=
sky_mask
[
mask_x
+
mask_y
*
width
];
pix_tile
[
pindx
]
*=
mask_val
;
...
...
@@ -1339,10 +1339,35 @@ public class CuasMotion {
}
}
}
if
((
nSeq
==
dbg_seq
)
&&
(
ntile
==
dbg_tile
))
{
System
.
out
.
println
(
"getAccumulatedCoordinates(): nSeq="
+
nSeq
+
", ntile="
+
ntile
+
" py0="
+
py0
+
" px0="
+
px0
+
", y_mask_offs="
+
y_mask_offs
+
", x_mask_offs="
+
x_mask_offs
);
for
(
int
row
=
0
;
row
<
tile2
;
row
++)
{
int
mask_y
=
Math
.
min
(
height
-
1
,
Math
.
max
(
0
,
py0
+
y_mask_offs
+
row
));
for
(
int
col
=
0
;
col
<
tile2
;
col
++)
{
int
mask_x
=
Math
.
min
(
width
-
1
,
Math
.
max
(
0
,
px0
+
x_mask_offs
+
col
));
int
pindx
=
col
+
row
*
tile2
;
double
mask_val
=
sky_mask
[
mask_x
+
mask_y
*
width
];
if
(
col
==
0
)
{
System
.
out
.
println
(
"row="
+
row
+
", mask_y="
+
mask_y
+
"col="
+
col
+
", mask_x="
+
mask_x
+
", mask_val="
+
mask_val
+
", pindx="
+
pindx
);
}
// pix_tile[pindx] *= mask_val;
// if (mask_val < sky_threshold) {
// disabled[pindx] = true; // disallow maximums in this area
// }
}
}
}
}
// find absolute maximum (after "hacking" and masking
int
ntile_amax
=
TileNeibs
.
getAmaxTile
(
pix_tile
);
//double [] data)
/*
if (lmax_hack_ridge > 0) {
Arrays.fill(disabled,false);
disabled = new boolean[pix_tile.length];
...
...
@@ -1367,7 +1392,7 @@ public class CuasMotion {
}
}
}
*/
// filtering tile for better maximum selection
if
(
pix_tile_filtered
!=
null
)
{
...
...
@@ -1528,6 +1553,28 @@ public class CuasMotion {
target
[
CuasMotionLMA
.
RSLT_ITERS
]
=
rslt
;
// will save -1 (failure) also
if
(
rslt
>=
0
)
{
cuasMotionLMA
.
setResult
(
target
);
int
col
=
GPUTileProcessor
.
DTT_SIZE
+
(
int
)
Math
.
round
(
target
[
CuasMotionLMA
.
RSLT_X
]);
int
row
=
GPUTileProcessor
.
DTT_SIZE
+
(
int
)
Math
.
round
(
target
[
CuasMotionLMA
.
RSLT_Y
]);
int
pindx
=
col
+
row
*
tile2
;
/*
if (pindx > 256) {
System.out.println("nSeq="+nSeq+", ntile="+ntile+
", target[CuasMotionLMA.RSLT_X]="+target[CuasMotionLMA.RSLT_X]+
", target[CuasMotionLMA.RSLT_Y]="+target[CuasMotionLMA.RSLT_Y]+
", row="+row+", col="+col);
}
*/
if
(!
tn
.
isInside
(
pindx
))
{
target
[
CuasMotionLMA
.
RSLT_ITERS
]
=
-
2
;
// outside of the 16x16 tiles -> LMA failed to converge
}
else
if
(
disabled
[
pindx
])
{
target
[
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_HORIZON
;
/*
if (ntile == dbg_tile) { // if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
System.out.println("getAccumulatedCoordinates(): nSeq="+nSeq+", ntile="+ntile+
", centered="+centered+", pindx="+pindx);
}
*/
}
if
(
centered
&&
!
Double
.
isNaN
(
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_X
]))
{
double
x0
=
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_X
];
double
y0
=
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_Y
];
...
...
@@ -1536,6 +1583,26 @@ public class CuasMotion {
target
[
CuasMotionLMA
.
RSLT_X
]
+=
x0
;
target
[
CuasMotionLMA
.
RSLT_Y
]
+=
y0
;
}
if
((
ntile
==
dbg_tile
)
&&
(
nSeq
==
dbg_seq
))
{
// if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
// px0, py0 - top/left corner of 16x16
int
ipx
=
(
int
)
(
px0
+
GPUTileProcessor
.
DTT_SIZE
+
target
[
CuasMotionLMA
.
RSLT_X
]);
int
ipy
=
(
int
)
(
py0
+
GPUTileProcessor
.
DTT_SIZE
+
target
[
CuasMotionLMA
.
RSLT_Y
]);
int
mask_x
=
Math
.
min
(
width
-
1
,
Math
.
max
(
0
,
ipx
));
int
mask_y
=
Math
.
min
(
height
-
1
,
Math
.
max
(
0
,
ipy
));
double
mask_val
=
sky_mask
[
mask_x
+
mask_y
*
width
];
System
.
out
.
println
(
"getAccumulatedCoordinates(): nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", centered="
+
centered
+
", pindx="
+
pindx
+
", ipx="
+
ipx
+
", ipy="
+
ipy
+
", mask_x="
+
mask_x
+
", mask_y="
+
mask_y
+
", mask_val = "
+
mask_val
);
System
.
out
.
println
();
for
(
int
prow
=
0
;
prow
<
tile2
;
prow
++)
{
for
(
int
pcol
=
0
;
pcol
<
tile2
;
pcol
++)
{
System
.
out
.
print
(
disabled
[
pcol
+
prow
*
tile2
]?
"."
:
"+"
);
}
System
.
out
.
println
();
}
}
}
}
}
...
...
@@ -1614,23 +1681,47 @@ public class CuasMotion {
return
filtered_scan
;
}
public
static
void
f
ailBy
StrongerNeighbor
(
// does not modify "when"
public
static
void
f
ind
StrongerNeighbor
(
// does not modify "when"
final
double
[][][]
target_sequence
,
final
boolean
[][]
filter5
){
final
boolean
[][]
filter5
,
final
boolean
mark_failed
,
final
int
tilesX
)
{
final
int
range
=
2
;
final
int
num_seq
=
target_sequence
.
length
;
final
int
num_tiles
=
target_sequence
[
0
].
length
;
final
int
tilesY
=
num_tiles
/
tilesX
;
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
();
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
TileNeibs
tn
=
new
TileNeibs
(
tilesX
,
tilesY
);
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
)
&&
(
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
)
&&
!
filter5
[
nSeq
][
ntile
])
{
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_NEIGHBOR
;
(
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NONE
))
{
// &&
if
(
filter5
[
nSeq
][
ntile
])
{
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_STRONGER
]
=
Double
.
NaN
;
}
else
{
// find first stronger tile index
check_nebs:
{
for
(
int
dy
=
-
range
;
dy
<=
range
;
dy
++)
{
for
(
int
dx
=
-
range
;
dx
<=
range
;
dx
++)
{
int
indx
=
tn
.
getNeibIndex
(
ntile
,
dx
,
dy
);
if
((
indx
>=
0
)
&&
filter5
[
nSeq
][
indx
])
{
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_STRONGER
]
=
indx
;
break
check_nebs
;
}
}
}
System
.
out
.
println
(
"findStrongerNeighbor(): FIXME: no selected neighbor in 5x5 vicinity, but this is not selected either. nSeq="
+
nSeq
+
", ntile="
+
ntile
);
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_STRONGER
]
=
-
1
;
// not found
}
if
(
mark_failed
)
{
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
=
CuasMotionLMA
.
FAIL_NEIGHBOR
;
}
}
}
}
}
...
...
@@ -1639,6 +1730,7 @@ public class CuasMotion {
ImageDtt
.
startAndJoin
(
threads
);
}
/*
public static void clearFailByStrongerNeighbor(// does not modify "when"
final double [][][] target_sequence){
final int num_seq = target_sequence.length;
...
...
@@ -1651,7 +1743,8 @@ public class CuasMotion {
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
)
&&
(
target_sequence
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]
==
CuasMotionLMA
.
FAIL_NEIGHBOR
))
{
for (int ntile = 0; ntile < num_tiles; ntile++) if ((target_sequence[nSeq][ntile] != null) &&
(target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] == CuasMotionLMA.FAIL_NEIGHBOR)) {
target_sequence[nSeq][ntile][CuasMotionLMA.RSLT_FAIL] = CuasMotionLMA.FAIL_NONE;
}
}
...
...
@@ -1660,7 +1753,7 @@ public class CuasMotion {
}
ImageDtt.startAndJoin(threads);
}
*/
public
static
double
[][][]
applyFilter
(
...
...
@@ -1700,32 +1793,28 @@ public class CuasMotion {
String
title
,
boolean
show
,
int
tilesX
)
{
boolean
condense
=
false
;
// true;
int
num_fields
=
CuasMotionLMA
.
LMA_TITLES
.
length
;
int
num_scenes
=
target_scene_sequence
.
length
;
int
num_tiles
=
target_scene_sequence
[
0
].
length
;
String
[]
frame_titles
=
new
String
[
CuasMotionLMA
.
LMA_TITLES
.
length
+
1
];
for
(
int
i
=
0
;
i
<
CuasMotionLMA
.
LMA_TITLES
.
length
;
i
++)
{
frame_titles
[
i
]
=
CuasMotionLMA
.
LMA_TITLES
[
i
];
}
frame_titles
[
CuasMotionLMA
.
LMA_TITLES
.
length
]
=
"Targets"
;
boolean
[]
has_non_nans
=
new
boolean
[
num_fields
];
double
[][][]
img_data
=
new
double
[
num_fields
][
num_scenes
][
num_tiles
];
double
[][][]
img_data
=
new
double
[
num_fields
+
1
][
num_scenes
][
num_tiles
];
for
(
int
nscene
=
0
;
nscene
<
num_scenes
;
nscene
++)
{
for
(
int
nfi
led
=
0
;
nfiled
<
num_fields
;
nfile
d
++)
{
Arrays
.
fill
(
img_data
[
nfi
le
d
][
nscene
],
Double
.
NaN
);
for
(
int
nfi
eld
=
0
;
nfield
<
img_data
.
length
;
nfiel
d
++)
{
Arrays
.
fill
(
img_data
[
nfi
el
d
][
nscene
],
Double
.
NaN
);
}
for
(
int
ntile
=
0
;
ntile
<
target_scene_sequence
[
nscene
].
length
;
ntile
++)
{
if
(
target_scene_sequence
[
nscene
][
ntile
]
!=
null
)
{
for
(
int
nfield
=
0
;
nfield
<
img_data
.
length
;
nfield
++)
{
double
v
=
target_scene_sequence
[
nscene
][
ntile
][
nfield
];
img_data
[
nfield
][
nscene
][
ntile
]
=
v
;
if
(
condense
)
{
has_non_nans
[
nfield
]
|=
!
Double
.
isNaN
(
v
);
}
double
[]
target
=
target_scene_sequence
[
nscene
][
ntile
];
if
(
target
!=
null
)
{
for
(
int
nfield
=
0
;
nfield
<
num_fields
;
nfield
++)
{
img_data
[
nfield
][
nscene
][
ntile
]
=
target
[
nfield
];
}
}
}
}
if
(
condense
)
{
for
(
int
nfield
=
0
;
nfield
<
has_non_nans
.
length
;
nfield
++)
{
if
(!
has_non_nans
[
nfield
]){
img_data
[
nfield
]
=
null
;
img_data
[
num_fields
][
nscene
][
ntile
]
=
((
target
[
CuasMotionLMA
.
RSLT_FAIL
]==
CuasMotionLMA
.
FAIL_NONE
)
&&
Double
.
isNaN
(
target
[
CuasMotionLMA
.
RSLT_STRONGER
]))?
1
:
0
;
}
}
}
...
...
@@ -1734,7 +1823,7 @@ public class CuasMotion {
tilesX
,
// int width,
title
,
// String title, "time_derivs-rt"+diff_time_rt+"-rxy"+diff_time_rxy,
titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
CuasMotionLMA
.
LMA_TITLES
,
// String [] frame_titles, // frame titles or null
frame_titles
,
//
CuasMotionLMA.LMA_TITLES, // String [] frame_titles, // frame titles or null
show
);
// boolean show)
return
imp
;
}
...
...
@@ -2227,7 +2316,7 @@ public class CuasMotion {
}
// now will skip tiles that have stronger neighbors
public
static
double
[][][]
extendMotionScan
(
final
double
[][][]
motion_scan
,
final
boolean
[][]
filtered
,
// centers, should be non-overlapped . May be [motion_scan.length][] - will be calculated and returned
...
...
@@ -2254,7 +2343,9 @@ public class CuasMotion {
boolean
[]
centers
=
has_filter
?
filtered
[
nSeq
]
:
new
boolean
[
ms
.
length
];
if
(!
has_filter
)
{
for
(
int
i
=
0
;
i
<
centers
.
length
;
i
++)
{
centers
[
i
]
=
(
ms
[
i
]
!=
null
)
&&
(
Double
.
isNaN
(
ms
[
i
][
CuasMotionLMA
.
RSLT_FAIL
])
||
(
ms
[
i
][
CuasMotionLMA
.
RSLT_FAIL
]==
CuasMotionLMA
.
FAIL_NONE
));
centers
[
i
]
=
(
ms
[
i
]
!=
null
)
&&
Double
.
isNaN
(
ms
[
i
][
CuasMotionLMA
.
RSLT_STRONGER
])
&&
// should not have stronger neighbor
(
Double
.
isNaN
(
ms
[
i
][
CuasMotionLMA
.
RSLT_FAIL
])
||
(
ms
[
i
][
CuasMotionLMA
.
RSLT_FAIL
]==
CuasMotionLMA
.
FAIL_NONE
));
}
}
if
((
filtered
!=
null
)
&&
(
filtered
[
nSeq
]
==
null
))
{
...
...
@@ -5129,10 +5220,12 @@ public class CuasMotion {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_filter5_lma
);
}
// apply filter5 to targets_good
f
ailBy
StrongerNeighbor
(
// does not modify "when"
f
ind
StrongerNeighbor
(
// does not modify "when"
target_sequence
,
// final double [][][] target_sequence,
filter5
);
// final boolean [][] filter5)
filter5
,
// final boolean [][] filter5)
false
,
// final boolean mark_failed,
cuasMotion
.
tilesX
);
// final int tilesX) {
// now failed by neighbors are marked as non-NaN (tile index or -1), not as failed
if
(
intermed_low
)
{
// save final
ImagePlus
imp_good
=
showTargetSequence
(
...
...
@@ -5143,7 +5236,9 @@ public class CuasMotion {
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_good
);
// ImagePlus imp)
}
// remove singles here
// remove singles here - no, just calculate
// Is it needed here?
calculateMismatchBeforeAfter
(
target_sequence
,
// final double [][][] targets,
true
,
// false, // final boolean good_only, ???? why it was false
...
...
@@ -5157,7 +5252,7 @@ public class CuasMotion {
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_1
);
}
return
target_sequence
;
// non-overlap
return
target_sequence
;
// non-overlap
if consider marked stronger tiles
}
...
...
@@ -5167,7 +5262,7 @@ public class CuasMotion {
final
boolean
batch_mode
,
QuadCLT
parentCLT
,
//
final
float
[][]
fpixels
,
double
[][][]
target_sequence
,
//
double
[][][]
target_sequence
,
//
non-overlap only if consider marked stronger tiles
CuasMotion
cuasMotion
,
UasLogReader
uasLogReader
,
String
[]
scene_titles
,
// recreate slice_titles from scene titles?
...
...
@@ -5222,6 +5317,29 @@ public class CuasMotion {
boolean
cuas_gaussian_ra
=
clt_parameters
.
imp
.
cuas_gaussian_ra
;
// use temporal Gaussian instead of running average
boolean
center_targ
=
false
;
// clt_parameters.imp.cuas_center_targ;
// for getEffectiveStrengthLMA(), may be moved out of this method to resolveTargetsConflicts()
double
target_strength
=
clt_parameters
.
imp
.
cuas_target_strength
;
double
[][]
target_frac
=
new
double
[
clt_parameters
.
imp
.
cuas_target_frac
.
length
][
2
];
double
lma_rms
=
clt_parameters
.
imp
.
cuas_lma_rms
;
// = 1.5; // Maximal RMS, regardless of amplitude
double
lma_arms
=
clt_parameters
.
imp
.
cuas_lma_arms
;
// = 0.06; // Maximal absolute RMS, sufficient for any amplitude
double
lma_rrms
=
clt_parameters
.
imp
.
cuas_lma_rrms
;
// = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
double
lma_mina
=
clt_parameters
.
imp
.
cuas_lma_mina
;
// = 1.0; // Minimal A (amplitude)
double
lma_maxr
=
clt_parameters
.
imp
.
cuas_lma_maxr
;
// = 5.0; // Maximal radius (>3.8)
double
lma_minr1
=
clt_parameters
.
imp
.
cuas_lma_minr1
;
// = 1.0; // Maximal inner radius
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_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
;
// end of for getEffectiveStrengthLMA(), may be moved out of this method to resolveTargetsConflicts()
// for getScore(), may be moved out of this method to resolveTargetsConflicts()
double
min_score_lma
=
clt_parameters
.
imp
.
cuas_score_lma
;
double
factor_lim
=
clt_parameters
.
imp
.
cuas_factor_lim
;
double
factor_pow
=
clt_parameters
.
imp
.
cuas_factor_pow
;
double
[]
score_coeff
=
clt_parameters
.
imp
.
cuas_score_coeff
.
clone
();
// end of for getScore(), may be moved out of this method to resolveTargetsConflicts()
int
start_frame
=
0
;
int
seq_length
=
corr_offset
+
corr_pairs
;
final
int
frame0
=
start_frame
+
seq_length
/
2
;
...
...
@@ -5230,6 +5348,7 @@ public class CuasMotion {
double
interseq_scale
=
0.5
*
corr_inc
/
corr_offset
;
// multiply target velocity to get offset in the middle between the key frames
final
int
num_corr_samples
=
target_sequence
.
length
;
int
[]
filter5_remain
=
new
int
[
num_corr_samples
];
int
[]
num_all
=
new
int
[
num_corr_samples
];
int
[]
num_undef
=
new
int
[
num_corr_samples
];
int
[]
num_good
=
new
int
[
num_corr_samples
];
...
...
@@ -5293,7 +5412,7 @@ public class CuasMotion {
min_seq_fl
,
// final int min_seq_length_fl,// < min_seq_length minimal sequence length that includes first/last keyframes
max_mismatch
,
// final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
cuasMotion
.
tilesX
);
// int tilesX) {
if
(
intermed_low
)
{
ImagePlus
imp_no_singles_lma
=
showTargetSequence
(
target_sequence
,
// double [][][] target_scene_sequence,
...
...
@@ -5304,11 +5423,116 @@ public class CuasMotion {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_no_singles_lma
);
// ImagePlus imp)
if
(
debugLevel
>
-
4
)
System
.
out
.
println
();
}
// re-calculate score after removing short sequences
calculateMismatchBeforeAfter
(
// fills fields in the target_sequence tiles
target_sequence
,
// final double [][][] targets,
true
,
// final boolean good_only,
cuasMotion
.
tilesX
);
// final int tilesX)
getEffectiveStrengthLMA
(
target_sequence
,
// final double [][][] target_coords, // LMA
target_strength
,
// final double target_strength,
target_frac
,
// final double [][] target_frac, // pairs - strength, minimal fraction for that strength
lma_rms
,
// final double lma_rms, // = 1.5; // Maximal RMS (should always match, regardless if A)
lma_arms
,
// final double lma_arms, // = 0.06; // Maximal absolute RMS (should match one of cuas_lma_arms OR cuas_lma_rrms (0.484)
lma_rrms
,
// final double lma_rrms, // = 0.15; // Maximal relative to A rms. OK is when (RMS < cuas_lma_arms) || (RMS < cuas_lma_rrms * A)
lma_mina
,
// final double lma_mina, // = 1.0; // Minimal A (amplitude)
lma_maxr
,
// final double lma_maxr, // = 5.0; // Minimal K (overshoot) = 3.0
lma_minr1
,
// final double lma_minr1,// = 1.0; // Minimal R1 (radius of positive peak)
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_a2a
,
// final double lma_a2a,
max_mismatch
,
// final double max_mismatch,
false
,
// fail_mismatch, // final boolean fail_mismatch,
target_horizon
,
// final double lma_horizon, // target below horizon
cuasMotion
.
tilesX
);
// final int tilesX,
// int [] remain_es2 =
getScore
(
// calculates composite sceres
target_sequence
,
// final double [][][] target_sequence, // modifies certain fields (scores)
factor_lim
,
// final double importance_limit,
factor_pow
,
// final double importance_power, // Raise each factor to this power before combining
score_coeff
,
// final double [] importance, // for now (each - squared?): [0] - Amplitude (A/A0), 1 - RMS (RMS0/RMS), 2 - RRMS((RMS/A0) / (RMS/A)
cuasMotion
.
tilesX
);
// final int tilesX,
if
(
intermed_low
)
{
ImagePlus
imp_final_score
=
showTargetSequence
(
target_sequence
,
// double [][][] vector_fields_sequence,
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
model_prefix
+
"-FINAL_SCORE"
,
// String title,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_final_score
);
}
// getRemain(target_sequence, num_all, num_undef, num_good, num_bad);
getRemain
(
target_sequence
,
null
,
null
,
num_good
,
null
);
if
(
debugLevel
>
-
4
)
printStats
(
"After final score"
,
true
,
null
,
null
,
num_good
,
null
);
boolean
[][]
filter5
=
filter5Targets
(
target_sequence
,
// final double [][][] target_sequence,
false
,
// final boolean use_motion, // true - use motion vectros confidence, false - use target confidence
false
,
// final boolean select_new, // true - use only untested tiles, false - use good tiles
min_score_lma
,
// min_mv_strength, // double min_confidence,
target_horizon
,
// final double lma_horizon, // target below horizon
cuasMotion
.
tilesX
,
// final int tilesX,
2
,
// max_range, // final int range, // 1 or 2
filter5_remain
,
// final int [] remain){
null
,
// passes, // final int [] passes, // debugging - number of passes required
debugLevel
);
// final int debugLevel)
if
(
debugLevel
>
-
4
)
printStatsLine
(
"After filter5 remaining non-conflicting targets"
,
true
,
filter5_remain
);
// apply filter5 to targets_good
findStrongerNeighbor
(
// does not modify "when"
target_sequence
,
// final double [][][] target_sequence,
filter5
,
// final boolean [][] filter5)
true
,
// final boolean mark_failed,
cuasMotion
.
tilesX
);
// final int tilesX) {
// now failed by neighbors are marked as non-NaN (tile index or -1), not as failed
getRemain
(
target_sequence
,
null
,
null
,
num_good
,
null
);
if
(
debugLevel
>
-
4
)
printStats
(
"After removing by neighbors"
,
true
,
null
,
null
,
num_good
,
null
);
if
(
intermed_low
)
{
ImagePlus
imp_neibs
=
showTargetSequence
(
target_sequence
,
// double [][][] vector_fields_sequence,
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
model_prefix
+
"-NO_CONFLICTS"
,
// String title,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_neibs
);
}
calculateMismatchBeforeAfter
(
// fills fields in the target_sequence tiles
target_sequence
,
// final double [][][] targets,
true
,
// final boolean good_only,
cuasMotion
.
tilesX
);
// final int tilesX)
filterIsolatedTargets
(
// overwrites "good", does not change "when"
target_sequence
,
// final double [][][] targets,
min_seq
,
// final int min_seq_length, // minimal sequence length not including first/last keyframes (may include)
min_seq_fl
,
// final int min_seq_length_fl,// < min_seq_length minimal sequence length that includes first/last keyframes
max_mismatch
,
// final double max_mismatch, // if <=0, do not calculate mismatch_ba and filter
cuasMotion
.
tilesX
);
// int tilesX) {
if
(
intermed_low
)
{
ImagePlus
imp_no_singles_lma
=
showTargetSequence
(
target_sequence
,
// double [][][] target_scene_sequence,
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
model_prefix
+
"-NOSINGLES3"
,
// String title,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_no_singles_lma
);
// ImagePlus imp)
if
(
debugLevel
>
-
4
)
System
.
out
.
println
();
}
}
getRemain
(
target_sequence
,
num_all
,
num_undef
,
num_good
,
num_bad
);
if
(
debugLevel
>
-
4
)
printStats
(
"generateExtractFilterMovingTargets(): after isolated removal"
,
true
,
num_all
,
num_undef
,
num_good
,
num_bad
);
// create larger, 5x5 vector field for accumulation -> 3x3
double
[][][]
extended_targets
=
extendMotionScan
(
target_sequence
,
// final double [][][] motion_scan,
...
...
@@ -5493,6 +5717,8 @@ public class CuasMotion {
final
boolean
[][]
good_tiles
=
new
boolean
[
num_seq
][
num_tiles
];
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
();
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
final
int
dbg_tile
=
38
+
46
*
80
;
// final int dbg_seq=14;
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
...
...
@@ -5502,21 +5728,28 @@ public class CuasMotion {
&&
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_FAIL
]==
CuasMotionLMA
.
FAIL_NONE
)
&&
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
]>
0
))
{
double
[]
ba
=
{
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
],
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
]};
int
[]
dirs
=
decodeDirs
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
]);
int
[]
dirs
=
decodeDirs
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
]);
for
(
int
i
=
0
;
i
<
ba
.
length
;
i
++)
{
if
((
dirs
[
i
]
==
0
)
||
(
ba
[
i
]
>
max_mismatch
))
{
if
((
dirs
[
i
]
<
0
)
||
(
ba
[
i
]
>
max_mismatch
))
{
ba
[
i
]
=
Double
.
NaN
;
}
}
boolean
has_fl
=
(
nSeq
==
0
)
||
(
nSeq
==
(
num_seq
-
1
));
int
seq_len
=
1
;
if
(
Double
.
isNaN
(
ba
[
0
])
&&
Double
.
isNaN
(
ba
[
1
]))
{
// no connections either way
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():1: nSeq="
+
nSeq
+
", ntile="
+
ntile
);
}
continue
;
}
int
nseq1
=
nSeq
;
int
ntile1
=
ntile
;
check_long_enough:
{
if
((
seq_len
>=
min_seq_length
)
||
(
has_fl
&&
(
seq_len
>=
min_seq_length_fl
)))
{
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():2: nSeq="
+
nSeq
+
", ntile="
+
ntile
);
}
break
check_long_enough
;
}
// check after
...
...
@@ -5526,25 +5759,31 @@ public class CuasMotion {
if
(
(
targets
[
nseq1
][
ntile1
]
==
null
)
||
(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_FAIL
]
!=
CuasMotionLMA
.
FAIL_NONE
)
||
!(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
]
<=
max_mismatch
))
{
/*
if (targets[nseq1][ntile1] == null) {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
} else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER] <= max_mismatch)){
System.out.println("check after: targets["+nseq1+"]["+ntile1+"]["+
CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+
", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+
", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+
", seq_len="+seq_len);
} else {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len);
if
(
ntile
==
dbg_tile
)
{
// && (nSeq==dbg_seq)) {
if
(
targets
[
nseq1
][
ntile1
]
==
null
)
{
System
.
out
.
println
(
"check after: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"] == null, nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", seq_len="
+
seq_len
);
}
else
if
(!(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
]
<=
max_mismatch
)){
System
.
out
.
println
(
"check after: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"]["
+
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
]+
", ...["
+
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
]+
", ...["
+
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
]+
", seq_len="
+
seq_len
);
}
else
{
System
.
out
.
println
(
"check after: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"] == null, nSeq="
+
nSeq
+
", ntile="
+
ntile
+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_FAIL
]+
", seq_len="
+
seq_len
);
}
}
*/
break
;
}
int
dir
=
decodeDirs
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
])[
ba_index
];
// direction to the tile in the next/previous keyframe
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():3: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", dir="
+
dir
+
", seq_len="
+
seq_len
);
}
if
(
dir
<
0
)
{
System
.
out
.
println
(
"check after: nseq1="
+
nseq1
+
", ntile1="
+
ntile1
+
", dir="
+
dir
+
", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="
+
...
...
@@ -5568,6 +5807,10 @@ public class CuasMotion {
" has_fl="
+
has_fl
+
", min_seq_length="
+
min_seq_length
+
", min_seq_length_fl="
+
min_seq_length_fl
);
break
check_long_enough
;
}
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():4: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", dir="
+
dir
+
", seq_len="
+
seq_len
);
}
}
// check before
nseq1
=
nSeq
;
...
...
@@ -5577,23 +5820,30 @@ public class CuasMotion {
if
(
(
targets
[
nseq1
][
ntile1
]
==
null
)
||
(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_FAIL
]!=
CuasMotionLMA
.
FAIL_NONE
)
||
!(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
]
<=
max_mismatch
))
{
/*
if (targets[nseq1][ntile1] == null) {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+", seq_len="+seq_len);
} else if (!(targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE] <= max_mismatch)){
System.out.println("check before: targets["+nseq1+"]["+ntile1+"]["+
CuasMotionLMA.RSLT_MISMATCH_BEFORE+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_BEFORE]+
", ...["+CuasMotionLMA.RSLT_MISMATCH_AFTER+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_AFTER]+
", ...["+CuasMotionLMA.RSLT_MISMATCH_DIRS+"] = "+targets[nseq1][ntile1][CuasMotionLMA.RSLT_MISMATCH_DIRS]+
", seq_len="+seq_len);
} else {
System.out.println("check after: targets["+nseq1+"]["+ntile1+"] == null, nSeq="+nSeq+", ntile="+ntile+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="+targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]+", seq_len="+seq_len);
if
(
ntile
==
dbg_tile
)
{
if
(
targets
[
nseq1
][
ntile1
]
==
null
)
{
System
.
out
.
println
(
"check before: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"] == null, nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", seq_len="
+
seq_len
);
}
else
if
(!(
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
]
<=
max_mismatch
)){
System
.
out
.
println
(
"check before: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"]["
+
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_BEFORE
]+
", ...["
+
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_AFTER
]+
", ...["
+
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
+
"] = "
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
]+
", seq_len="
+
seq_len
);
}
else
{
System
.
out
.
println
(
"check before: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", targets["
+
nseq1
+
"]["
+
ntile1
+
"] == null, nSeq="
+
nSeq
+
", ntile="
+
ntile
+
"targets[nseq1][ntile1][CuasMotionLMA.RSLT_FAIL]="
+
targets
[
nseq1
][
ntile1
][
CuasMotionLMA
.
RSLT_FAIL
]+
", seq_len="
+
seq_len
);
}
}
*/
break
;
}
int
dir
=
decodeDirs
(
targets
[
nSeq
][
ntile
][
CuasMotionLMA
.
RSLT_MISMATCH_DIRS
])[
ba_index
];
// direction to the tile in the next/previous keyframe
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():5: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", dir="
+
dir
+
", seq_len="
+
seq_len
);
}
if
(
dir
<
0
)
{
System
.
out
.
println
(
"check before: nseq1="
+
nseq1
+
", ntile1="
+
ntile1
+
", dir="
+
dir
+
", targets[nSeq][ntile][CuasMotionLMA.RSLT_MISMATCH_DIRS]="
+
...
...
@@ -5617,6 +5867,12 @@ public class CuasMotion {
" has_fl="
+
has_fl
+
", min_seq_length="
+
min_seq_length
+
", min_seq_length_fl="
+
min_seq_length_fl
);
break
check_long_enough
;
}
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():6: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", dir="
+
dir
+
", seq_len="
+
seq_len
);
}
}
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():7: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", seq_len="
+
seq_len
);
}
continue
;
// not long enough to match requirements - not a good target
}
...
...
@@ -5626,6 +5882,9 @@ public class CuasMotion {
", seq_len="+seq_len+
" has_fl="+has_fl+", min_seq_length="+min_seq_length+", min_seq_length_fl="+min_seq_length_fl);
*/
if
(
ntile
==
dbg_tile
)
{
System
.
out
.
println
(
"filterIsolatedTargets():8: nSeq="
+
nSeq
+
", ntile="
+
ntile
+
", seq_len="
+
seq_len
);
}
good_tiles
[
nSeq
][
ntile
]
=
true
;
}
}
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
View file @
61eb0d79
...
...
@@ -74,9 +74,10 @@ public class CuasMotionLMA {
public
static
final
int
RSLT_QMATCH
=
30
;
public
static
final
int
RSLT_QCENTER
=
31
;
public
static
final
int
RSLT_QSCORE
=
32
;
public
static
final
int
RSLT_STRONGER
=
33
;
// index of stronger neighbor (may be more)
public
static
final
int
RSLT_WHEN
=
3
3
;
public
static
final
int
RSLT_FAIL
=
3
4
;
public
static
final
int
RSLT_WHEN
=
3
4
;
public
static
final
int
RSLT_FAIL
=
3
5
;
public
static
final
int
RSLT_LEN
=
RSLT_FAIL
+
1
;
...
...
@@ -88,6 +89,7 @@ public class CuasMotionLMA {
"ERR-BEFORE"
,
"ERR-AFTER"
,
"BA-DIRS"
,
// before dir + 16*after dir
"*MOTION-SCORE"
,
"*Q-AMPL"
,
"*Q-RMSE"
,
"*Q-RMSE/A"
,
"*Q-MATCH"
,
"*Q-CENTER"
,
"*Q-SCORE"
,
"Stronger"
,
"WHEN"
,
"FAILURE"
};
public
static
final
int
FAIL_NONE
=
0
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
View file @
61eb0d79
...
...
@@ -168,7 +168,13 @@ public class TileNeibs{
if
(
indx
<
0
)
return
false
;
int
y
=
indx
/
sizeX
;
int
x
=
indx
%
sizeX
;
return
(
y
>=
roi
.
y
)
&&
(
x
>=
roi
.
x
)
||
(
y
<
roi
.
y
+
roi
.
height
)
||
(
x
<
roi
.
x
+
roi
.
width
);
return
(
y
>=
roi
.
y
)
&&
(
x
>=
roi
.
x
)
&&
(
y
<
roi
.
y
+
roi
.
height
)
&&
(
x
<
roi
.
x
+
roi
.
width
);
}
public
boolean
isInside
(
int
indx
)
{
if
(
indx
<
0
)
return
false
;
int
y
=
indx
/
sizeX
;
int
x
=
indx
%
sizeX
;
return
(
y
>=
0
)
&&
(
x
>=
0
)
&&
(
y
<
sizeY
)
&&
(
x
<
sizeX
);
}
/**
...
...
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