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
bcba8c48
Commit
bcba8c48
authored
Aug 10, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugging
parent
cbc0a783
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
22 deletions
+125
-22
ShowDoubleFloatArrays.java
.../java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
+23
-0
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+95
-16
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+4
-4
TileNeibs.java
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
+3
-2
No files found.
src/main/java/com/elphel/imagej/common/ShowDoubleFloatArrays.java
View file @
bcba8c48
...
@@ -529,6 +529,29 @@ import ij.process.ImageProcessor;
...
@@ -529,6 +529,29 @@ import ij.process.ImageProcessor;
return
null
;
return
null
;
}
}
public
static
ImagePlus
makeArrays
(
boolean
[][]
pixels
,
int
width
,
int
height
,
String
title
,
String
[]
titles
)
{
int
i
,
j
;
if
(
pixels
==
null
)
{
System
.
out
.
println
(
"showDoubleFloatArrays.makeArrays(): - pixel array is null"
);
}
float
[]
fpixels
;
ImageStack
array_stack
=
new
ImageStack
(
width
,
height
);
boolean
not_empty
=
false
;
for
(
i
=
0
;
i
<
pixels
.
length
;
i
++)
if
(
pixels
[
i
]!=
null
)
{
not_empty
=
true
;
fpixels
=
new
float
[
pixels
[
i
].
length
];
for
(
j
=
0
;
j
<
fpixels
.
length
;
j
++)
fpixels
[
j
]=
pixels
[
i
][
j
]?
1.0f
:
0.0f
;
array_stack
.
addSlice
(
titles
[
i
],
fpixels
);
}
if
(
not_empty
)
{
ImagePlus
imp_stack
=
new
ImagePlus
(
title
,
array_stack
);
imp_stack
.
getProcessor
().
resetMinAndMax
();
return
imp_stack
;
}
return
null
;
}
public
static
ImagePlus
makeArrays
(
double
[][]
pixels
,
int
width
,
int
height
,
String
title
,
String
[]
titles
)
{
public
static
ImagePlus
makeArrays
(
double
[][]
pixels
,
int
width
,
int
height
,
String
title
,
String
[]
titles
)
{
int
i
,
j
;
int
i
,
j
;
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
bcba8c48
...
@@ -1042,11 +1042,13 @@ public class CuasMotion {
...
@@ -1042,11 +1042,13 @@ public class CuasMotion {
final
double
lambda_max
,
final
double
lambda_max
,
final
double
rms_diff
,
final
double
rms_diff
,
final
int
num_iter
,
final
int
num_iter
,
final
float
[][]
accum_debug
,
final
int
debugLevel
){
final
int
debugLevel
){
final
int
tile2
=
2
*
GPUTileProcessor
.
DTT_SIZE
;
final
int
tile2
=
2
*
GPUTileProcessor
.
DTT_SIZE
;
final
int
lmax_iradius
=
(
int
)
Math
.
floor
(
lmax_radius
);
final
int
lmax_iradius
=
(
int
)
Math
.
floor
(
lmax_radius
);
final
int
num_seq
=
vector_fields
.
length
;
// same as accum_data.length
final
int
num_seq
=
vector_fields
.
length
;
// same as accum_data.length
final
int
num_tiles
=
vector_fields
[
0
].
length
;
final
int
num_tiles
=
vector_fields
[
0
].
length
;
final
int
num_pixels
=
accum_data
[
0
].
length
;
// final int num_pix = accum_data[0].length;
// final int num_pix = accum_data[0].length;
// final int tilesY = num_tiles/tilesX;
// final int tilesY = num_tiles/tilesX;
final
int
width
=
GPUTileProcessor
.
DTT_SIZE
*
tilesX
;
final
int
width
=
GPUTileProcessor
.
DTT_SIZE
*
tilesX
;
...
@@ -1077,34 +1079,46 @@ public class CuasMotion {
...
@@ -1077,34 +1079,46 @@ public class CuasMotion {
wnd_pedestal
);
wnd_pedestal
);
// may be faster if process only where vector_field[nseq][ntile] is not null
// may be faster if process only where vector_field[nseq][ntile] is not null
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
for
(
int
nSeq
=
ai
.
getAndIncrement
();
nSeq
<
num_seq
;
nSeq
=
ai
.
getAndIncrement
())
{
if
(
accum_debug
!=
null
)
{
accum_debug
[
nSeq
]
=
new
float
[
num_pixels
];
Arrays
.
fill
(
accum_debug
[
nSeq
],
Float
.
NaN
);
}
for
(
int
ntile
=
0
;
ntile
<
num_tiles
;
ntile
++)
{
for
(
int
ntile
=
0
;
ntile
<
num_tiles
;
ntile
++)
{
if
((
nSeq
==
dbg_seq
)
&&
(
ntile
==
dbg_tile
))
{
System
.
out
.
println
(
"getAccumulatedCoordinates(): nSeq="
+
nSeq
+
", ntile="
+
ntile
);
}
if
(
vector_fields
[
nSeq
][
ntile
]
!=
null
)
{
if
(
vector_fields
[
nSeq
][
ntile
]
!=
null
)
{
if
(
ntile
==
dbg_tile
)
{
// if ((nSeq==dbg_seq) && (ntile == dbg_tile)) {
System
.
out
.
println
(
"getAccumulatedCoordinates(): nSeq="
+
nSeq
+
", ntile="
+
ntile
);
}
int
tileX
=
ntile
%
tilesX
;
int
tileX
=
ntile
%
tilesX
;
int
tileY
=
ntile
/
tilesX
;
int
tileY
=
ntile
/
tilesX
;
int
px0
=
tileX
*
GPUTileProcessor
.
DTT_SIZE
-
GPUTileProcessor
.
DTT_SIZE
/
2
;
// top-left of 16x16 tile
int
px0
=
tileX
*
GPUTileProcessor
.
DTT_SIZE
-
GPUTileProcessor
.
DTT_SIZE
/
2
;
// top-left of 16x16 tile
int
py0
=
tileY
*
GPUTileProcessor
.
DTT_SIZE
-
GPUTileProcessor
.
DTT_SIZE
/
2
;
// top-left of 16x16 tile
int
py0
=
tileY
*
GPUTileProcessor
.
DTT_SIZE
-
GPUTileProcessor
.
DTT_SIZE
/
2
;
// top-left of 16x16 tile
// copy 16x16 tile
// copy 16x16 tile
int
indx_dst
=
0
;
{
for
(
int
y
=
0
;
y
<
tile2
;
y
++)
{
int
indx_dst
=
0
;
int
indx_src
=
px0
+
(
py0
+
y
)
*
width
;
for
(
int
y
=
0
;
y
<
tile2
;
y
++)
{
for
(
int
x
=
0
;
x
<
tile2
;
x
++)
{
int
indx_src
=
px0
+
(
py0
+
y
)
*
width
;
pix_tile
[
indx_dst
++]
=
accum_data
[
nSeq
][
indx_src
++];
// float-> double
for
(
int
x
=
0
;
x
<
tile2
;
x
++)
{
pix_tile
[
indx_dst
++]
=
accum_data
[
nSeq
][
indx_src
++];
// float-> double
}
}
}
}
}
// find absolute maximum
// find absolute maximum
int
ntile_amax
=
TileNeibs
.
getAmaxTile
(
int
ntile_amax
=
TileNeibs
.
getAmaxTile
(
pix_tile
);
//double [] data)
pix_tile
);
//double [] data)
double
amax_val
=
pix_tile
[
ntile_amax
];
int
use_max
=
-
1
;
int
use_max
=
-
1
;
if
(!
tn
.
isEdge
(
ntile_amax
)
&&
tn
.
isMaxIsolated
(
if
(!
tn
.
isEdge
(
ntile_amax
))
{
boolean
isolated
=
tn
.
isMaxIsolated
(
pix_tile
,
// double [] data,
pix_tile
,
// double [] data,
ntile_amax
,
// int ntile,
ntile_amax
,
// int ntile,
lmax_fraction
,
// double fraction,
lmax_fraction
,
// double fraction,
lmax_iradius
))
{
//int radius)) {
lmax_iradius
);
//int radius)) {
use_max
=
ntile_amax
;
if
(
isolated
)
{
use_max
=
ntile_amax
;
}
}
}
boolean
max_abs
=
(
use_max
>=
0
);
// maximum is absolute maximum
if
(
use_max
<
0
)
{
// find alternative maximum
if
(
use_max
<
0
)
{
// find alternative maximum
int
[]
max_indices
=
tn
.
getLocalMaxes
(
int
[]
max_indices
=
tn
.
getLocalMaxes
(
pix_tile
,
//double [] data,
pix_tile
,
//double [] data,
...
@@ -1112,8 +1126,8 @@ public class CuasMotion {
...
@@ -1112,8 +1126,8 @@ public class CuasMotion {
double
best_val
=
Double
.
NaN
;
double
best_val
=
Double
.
NaN
;
for
(
int
indx:
max_indices
)
{
for
(
int
indx:
max_indices
)
{
boolean
isolated
=
tn
.
isMaxIsolated
(
boolean
isolated
=
tn
.
isMaxIsolated
(
pix_tile
,
// double [] data,
pix_tile
,
// double [] data,
ntile_amax
,
// int ntile,
indx
,
// int ntile,
lmax_fraction
,
// double fraction,
lmax_fraction
,
// double fraction,
lmax_iradius
);
//int radius)) {
lmax_iradius
);
//int radius)) {
if
(
isolated
)
{
if
(
isolated
)
{
...
@@ -1129,8 +1143,8 @@ public class CuasMotion {
...
@@ -1129,8 +1143,8 @@ public class CuasMotion {
// no candidate for the centroid/lma
// no candidate for the centroid/lma
continue
;
continue
;
}
}
// zero out outside the circle
// zero out outside the circle
if maximum is not the absolute maximum or
if
(
lmax_zero
)
{
if
(
lmax_zero
||
!
max_abs
)
{
double
lmax_iradius2
=
(
int
)
Math
.
ceil
(
lmax_radius
*
lmax_radius
);
double
lmax_iradius2
=
(
int
)
Math
.
ceil
(
lmax_radius
*
lmax_radius
);
int
x0
=
use_max
%
tile2
;
int
x0
=
use_max
%
tile2
;
...
@@ -1144,10 +1158,24 @@ public class CuasMotion {
...
@@ -1144,10 +1158,24 @@ public class CuasMotion {
int
r2
=
dy2
+
dx
*
dx
;
int
r2
=
dy2
+
dx
*
dx
;
if
(
r2
>
lmax_iradius2
)
{
if
(
r2
>
lmax_iradius2
)
{
pix_tile
[
x
+
tile2
*
y
]
=
0.0
;
pix_tile
[
x
+
tile2
*
y
]
=
0.0
;
}
else
{
double
rratio
=
Math
.
sqrt
(
r2
)/
lmax_iradius
;
pix_tile
[
x
+
tile2
*
y
]
*=
Math
.
cos
(
0.5
*
Math
.
PI
*
rratio
);
}
}
}
}
}
}
}
}
if
(
accum_debug
!=
null
)
{
int
indx_src
=
0
;
for
(
int
y
=
0
;
y
<
tile2
;
y
++)
{
int
indx_dst
=
px0
+
(
py0
+
y
)
*
width
;
for
(
int
x
=
0
;
x
<
tile2
;
x
++)
{
accum_debug
[
nSeq
][
indx_dst
++]
=
(
float
)
pix_tile
[
indx_src
++];
// double -> float
}
}
}
double
[]
mv
=
Correlation2d
.
getMaxXYCm
(
// last, average (Will be relative to the center of the tile)
double
[]
mv
=
Correlation2d
.
getMaxXYCm
(
// last, average (Will be relative to the center of the tile)
pix_tile
,
// corrs.length-1], // double [] data,
pix_tile
,
// corrs.length-1], // double [] data,
tile2
,
// int data_width, // = 2 * transform_size - 1; // negative - will return center fraction
tile2
,
// int data_width, // = 2 * transform_size - 1; // negative - will return center fraction
...
@@ -3587,6 +3615,23 @@ public class CuasMotion {
...
@@ -3587,6 +3615,23 @@ public class CuasMotion {
speed_pref
,
// double speed_pref,
speed_pref
,
// double speed_pref,
speed_boost
);
// double speed_boost);
speed_boost
);
// double speed_boost);
if
(
debugLevel
>
-
4
)
printRemain
(
remain
,
"filter5"
,
true
);
if
(
debugLevel
>
-
4
)
printRemain
(
remain
,
"filter5"
,
true
);
if
(
save_filtered_low
)
{
ImagePlus
imp_filter5
=
ShowDoubleFloatArrays
.
makeArrays
(
filter5
,
// double[][] pixels,
cuasMotion
.
gpu_max_width
,
cuasMotion
.
gpu_max_height
,
model_prefix
+
"-FILTER5-n"
+
niter
,
// String title,
slice_titles
);
if
(!
batch_mode
)
{
imp_filter5
.
show
();
}
parentCLT
.
saveImagePlusInModelDirectory
(
imp_filter5
);
// ImagePlus imp)
}
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)
...
@@ -3759,6 +3804,7 @@ public class CuasMotion {
...
@@ -3759,6 +3804,7 @@ public class CuasMotion {
lambda_max
,
// final double lambda_max,
lambda_max
,
// final double lambda_max,
rms_diff
,
// final double rms_diff,
rms_diff
,
// final double rms_diff,
num_iter
,
// final int num_iter,
num_iter
,
// final int num_iter,
null
,
// final float [][] accum_debug,
debugLevel
);
// final int debugLevel);
debugLevel
);
// final int debugLevel);
double
[][][]
coord_centroid
=
coord_data2
[
0
];
// centroid
double
[][][]
coord_centroid
=
coord_data2
[
0
];
// centroid
double
[][][]
coord_lma
=
coord_data2
[
1
];
// lma
double
[][][]
coord_lma
=
coord_data2
[
1
];
// lma
...
@@ -3835,6 +3881,7 @@ public class CuasMotion {
...
@@ -3835,6 +3881,7 @@ public class CuasMotion {
!
batch_mode
,
// boolean show,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_good
);
// ImagePlus imp)
parentCLT
.
saveImagePlusInModelDirectory
(
imp_good
);
// ImagePlus imp)
}
}
// remove all good (by the LMA)
// remove all good (by the LMA)
double
[][][]
targets_bad_last
=
subtractMotionScans
(
// centroids
double
[][][]
targets_bad_last
=
subtractMotionScans
(
// centroids
...
@@ -3851,6 +3898,21 @@ public class CuasMotion {
...
@@ -3851,6 +3898,21 @@ public class CuasMotion {
remain
);
//
remain
);
//
if
(
debugLevel
>
-
4
)
printRemain
(
remain
,
"targets_bad"
,
true
);
if
(
debugLevel
>
-
4
)
printRemain
(
remain
,
"targets_bad"
,
true
);
if
(
save_filtered_low
)
{
// targets_good now has
ImagePlus
imp_bad
=
showVectorFieldsSequence
(
targets_bad
,
// double [][][] vector_fields_sequence,
0.0
,
// double speed_min, //
0.0
,
// double speed_pref,
1.0
,
// double speed_boost,
slice_titles
,
// String [] titles, // all slices*frames titles or just slice titles or null
model_prefix
+
"-BAD-n"
+
niter
,
// String title,
false
,
// boolean nan_effective_strength,
!
batch_mode
,
// boolean show,
cuasMotion
.
tilesX
);
// int tilesX) {
parentCLT
.
saveImagePlusInModelDirectory
(
imp_bad
);
// ImagePlus imp)
}
// TODO See if they are needed here at all
// TODO See if they are needed here at all
/*
/*
fpixels_accumulated_filtered = getTargetImages(
fpixels_accumulated_filtered = getTargetImages(
...
@@ -4032,7 +4094,7 @@ public class CuasMotion {
...
@@ -4032,7 +4094,7 @@ public class CuasMotion {
}
}
float
[][]
accum_debug
=
intermed_high
?
(
new
float
[
accum
.
length
][])
:
null
;
double
[][][][]
coord_data2
=
getAccumulatedCoordinates
(
double
[][][][]
coord_data2
=
getAccumulatedCoordinates
(
vf_sequence
,
// final double [][][] vector_fields, // centers
vf_sequence
,
// final double [][][] vector_fields, // centers
accum
,
// final double [][] accum_data, // should be around 0, no low-freq
accum
,
// final double [][] accum_data, // should be around 0, no low-freq
...
@@ -4061,7 +4123,24 @@ public class CuasMotion {
...
@@ -4061,7 +4123,24 @@ public class CuasMotion {
lambda_max
,
// final double lambda_max,
lambda_max
,
// final double lambda_max,
rms_diff
,
// final double rms_diff,
rms_diff
,
// final double rms_diff,
num_iter
,
// final int num_iter,
num_iter
,
// final int num_iter,
accum_debug
,
// final float [][] accum_debug,
debugLevel
);
// final int debugLevel);
debugLevel
);
// final int debugLevel);
if
(
accum_debug
!=
null
)
{
ImagePlus
imp_accumulated_filtered
=
ShowDoubleFloatArrays
.
makeArrays
(
accum_debug
,
// float[][] pixels,
cuasMotion
.
gpu_max_width
,
// int width,
cuasMotion
.
gpu_max_height
,
// int height,
model_prefix
+
"-ACCUMULATED-FILT"
,
//String title,
slice_titles
);
//String [] titles)
imp_accumulated_filtered
.
getProcessor
().
setMinAndMax
(-
input_range
/
2
,
input_range
/
2
);
if
(!
batch_mode
)
{
imp_accumulated_filtered
.
show
();
}
parentCLT
.
saveImagePlusInModelDirectory
(
imp_accumulated_filtered
);
// ImagePlus imp)
}
double
[][][]
coord_data
=
coord_data2
[
0
];
double
[][][]
coord_data
=
coord_data2
[
0
];
double
[][][]
coord_lma
=
coord_data2
[
1
];
double
[][][]
coord_lma
=
coord_data2
[
1
];
if
(
intermed_low
)
{
if
(
intermed_low
)
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
bcba8c48
...
@@ -724,10 +724,10 @@ min_str_neib_fpn 0.35
...
@@ -724,10 +724,10 @@ min_str_neib_fpn 0.35
public
double
cuas_speed_boost
=
1.0
;
// speed boost limit
public
double
cuas_speed_boost
=
1.0
;
// speed boost limit
// target filtering after constant velocity accumulation
// target filtering after constant velocity accumulation
public
double
cuas_lmax_fraction
=
0.
7
;
// Check if local maximum is separated from tye surrounding by this fraction of the maximum value
public
double
cuas_lmax_fraction
=
0.
6
;
// Check if local maximum is separated from tye surrounding by this fraction of the maximum value
public
double
cuas_lmax_radius
=
3
.5
;
// look inside ((int)cuas_lmax_radius) * 2 + 1 square for the local maximum isolation
public
double
cuas_lmax_radius
=
4
.5
;
// look inside ((int)cuas_lmax_radius) * 2 + 1 square for the local maximum isolation
public
boolean
cuas_lmax_zero
=
true
;
// zero all data outside this radius from the maximum
public
boolean
cuas_lmax_zero
=
false
;
//
true; // zero all data outside this radius from the maximum
public
double
cuas_target_radius
=
3.0
;
// target centroids center radius
public
double
cuas_target_radius
=
3.0
;
// target centroids center radius
public
double
cuas_target_strength
=
0.8
;
// target centroids center radius
public
double
cuas_target_strength
=
0.8
;
// target centroids center radius
...
...
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
View file @
bcba8c48
...
@@ -1546,8 +1546,9 @@ public class TileNeibs{
...
@@ -1546,8 +1546,9 @@ public class TileNeibs{
* @return
* @return
*/
*/
public
boolean
isEdge
(
int
indx
)
{
public
boolean
isEdge
(
int
indx
)
{
return
!
getFullRectangle
().
contains
(
getPoint
(
indx
));
boolean
isedge
=
!
getInnerRectangle
().
contains
(
getPoint
(
indx
));
return
isedge
;
}
}
}
}
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