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
f0ca9c38
Commit
f0ca9c38
authored
Sep 16, 2025
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started ranging
parent
6f8ae877
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1051 additions
and
85 deletions
+1051
-85
CorrectionFPN.java
src/main/java/com/elphel/imagej/cuas/CorrectionFPN.java
+1
-1
Cuas.java
src/main/java/com/elphel/imagej/cuas/Cuas.java
+1
-1
CuasMotion.java
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
+142
-24
CuasMotionLMA.java
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
+5
-2
CuasRanging.java
src/main/java/com/elphel/imagej/cuas/CuasRanging.java
+606
-14
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+20
-21
IntersceneMatchParameters.java
...lphel/imagej/tileprocessor/IntersceneMatchParameters.java
+83
-2
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+9
-12
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+163
-5
QuadCLTCPU.java
...main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
+21
-3
No files found.
src/main/java/com/elphel/imagej/cuas/CorrectionFPN.java
View file @
f0ca9c38
...
...
@@ -866,7 +866,7 @@ public class CorrectionFPN {
ImageDtt
.
THREADS_MAX
);
// int threadsMax)
if
(
window
!=
null
)
{
center_CLT
.
windowP
s
PyD
(
center_CLT
.
windowP
x
PyD
(
scene_pXpYD
,
// final double [][] pXpYD,
window
,
// final Rectangle window) // window in pixels!
max_fold
,
// final double max_fold)
...
...
src/main/java/com/elphel/imagej/cuas/Cuas.java
View file @
f0ca9c38
...
...
@@ -135,7 +135,7 @@ public class Cuas {
imp
);
// ImagePlus imp)
}
}
ref_CLT
.
windowP
s
PyD
(
ref_CLT
.
windowP
x
PyD
(
ref_pXpYD
,
// final double [][] pXpYD,
window
,
// final Rectangle window) // window in pixels!
max_fold
,
// final double max_fold)
...
...
src/main/java/com/elphel/imagej/cuas/CuasMotion.java
View file @
f0ca9c38
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/cuas/CuasMotionLMA.java
View file @
f0ca9c38
...
...
@@ -86,8 +86,10 @@ public class CuasMotionLMA {
public
static
final
int
RSLT_SLOW
=
41
;
// 1 - slow, 0 - fast
public
static
final
int
RSLT_WHEN
=
42
;
public
static
final
int
RSLT_FAIL
=
43
;
public
static
final
int
RSLT_DISPARITY
=
44
;
public
static
final
int
RSLT_LEN
=
RSLT_FAIL
+
1
;
public
static
final
int
RSLT_LEN
=
RSLT_DISPARITY
+
1
;
public
static
final
String
[]
LMA_TITLES
=
{
"X-OFFS"
,
"Y-OFFS"
,
"AMPLITUDE"
,
"RADIUS"
,
"RAD_POS"
,
"OVERSHOOT"
,
"OFFSET"
,
"RMSE"
,
"RMSE/A"
,
"MAX2A"
,
"ITERATIONS"
,
...
...
@@ -102,7 +104,8 @@ public class CuasMotionLMA {
"*MOTION-SCORE"
,
"*Q-AMPL"
,
"*Q-RMSE"
,
"*Q-RMSE/A"
,
"*Q-CENTER"
,
"*Q-MATCH"
,
"*Q-LENGTH"
,
"*QTRAVEL"
,
"*Q-SCORE"
,
"Stronger"
,
"Slow"
,
"WHEN"
,
"FAILURE"
};
"WHEN"
,
"FAILURE"
,
"Disparity"
};
public
static
final
int
FAIL_NONE
=
0
;
public
static
final
int
FAIL_MOTION
=
1
;
// motion strength/fraction too low
...
...
src/main/java/com/elphel/imagej/cuas/CuasRanging.java
View file @
f0ca9c38
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
f0ca9c38
...
...
@@ -1399,27 +1399,6 @@ public class ImageDtt extends ImageDttCPU {
globalDebugLevel
);
// final int globalDebugLevel)
/*
final float [][] lpf_rgb = new float[][] {
floatGetCltLpfFd(gpu_sigma_r),
floatGetCltLpfFd(gpu_sigma_b),
floatGetCltLpfFd(gpu_sigma_g),
floatGetCltLpfFd(gpu_sigma_m)
};
gpuQuad.setLpfRbg( // constants memory - same for all cameras
lpf_rgb,
globalDebugLevel > 2);
gpuQuad.setTasks( // copy tp_tasks to the GPU memory
tp_tasks, // TpTask [] tile_tasks,
false, // use_aux); // boolean use_aux)
imgdtt_params.gpu_verify); // boolean verify
// Why always NON-UNIFORM grid? Already set in tp_tasks
gpuQuad.execSetTilesOffsets(false); // false); // prepare tiles offsets in GPU memory, using NON-UNIFORM grid (pre-calculated)
// update tp_tasks
gpuQuad.updateTasks(
tp_tasks,
false); // boolean use_aux // while is it in class member? - just to be able to free
*/
if
(
fclt
!=
null
)
{
gpuQuad
.
handleWH
(
// allocate/reallocate GPU memory, that was normally done by gpuQuad.execConvertDirect()
wh
,
// int [] wh,
...
...
@@ -1490,6 +1469,26 @@ public class ImageDtt extends ImageDttCPU {
return
;
}
public
void
preSetReferenceTD
(
// do not run execConvertDirect, exit after updating tasks
final
ImageDttParameters
imgdtt_params
,
// Now just extra correlation parameters, later will include, most others
final
TpTask
[]
tp_tasks
,
final
int
globalDebugLevel
)
{
gpuQuad
.
setTasks
(
// copy tp_tasks to the GPU memory
tp_tasks
,
// TpTask [] tile_tasks,
false
,
// use_aux); // boolean use_aux)
imgdtt_params
.
gpu_verify
);
// boolean verify
// Why always NON-UNIFORM grid? Already set in tp_tasks
gpuQuad
.
execSetTilesOffsets
(
false
);
// false); // prepare tiles offsets in GPU memory, using NON-UNIFORM grid (pre-calculated)
// update tp_tasks - execute even w/o execSetTilesOffsets
gpuQuad
.
updateTasks
(
tp_tasks
,
false
);
// boolean use_aux // while is it in class member? - just to be able to free
return
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/IntersceneMatchParameters.java
View file @
f0ca9c38
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
f0ca9c38
...
...
@@ -6410,7 +6410,7 @@ public class OpticalFlow {
if
(
generate_mapped
)
{
double
[][]
ds_vantage
=
new
double
[][]
{
selected_disparity
,
selected_strength
};
if
((
views
[
ibase
][
0
]
!=
0
)
||
(
views
[
ibase
][
1
]
!=
0
)
||
(
views
[
ibase
][
2
]
!=
0
)
||
(
master_CLT
.
hasCenterClt
())
&&
(
mode3d
>
0
))
{
boolean
debug_vantage
=
true
;
boolean
debug_vantage
=
false
;
//
true;
//dls
double
[][]
dbg_vantage
=
debug_vantage
?
(
new
double
[
7
][]):
null
;
if
(
dbg_vantage
!=
null
)
{
...
...
@@ -8198,15 +8198,15 @@ public class OpticalFlow {
int
num_virtual_refines
=
2
;
String
debugSuffix
=
null
;
// "virtual";
ref_pXpYD
=
Cuas
.
transformFromVirtual
(
clt_parameters
,
// CLTParameters clt_parameters,
ref_disparity
,
// double [] disparity_ref,
stereo_xyz
,
// final double [] scene_xyz, // camera center in world (reference) coordinates
stereo_atr
,
// final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene
,
// final QuadCLT reference_QuadClt,
around
,
// final int around, // 2 search around for interpolation
around_sigma
,
// final double sigma,
clt_parameters
,
// CLTParameters clt_parameters,
ref_disparity
,
// double [] disparity_ref,
stereo_xyz
,
// final double [] scene_xyz, // camera center in world (reference) coordinates
stereo_atr
,
// final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene
,
// final QuadCLT reference_QuadClt,
around
,
// final int around, // 2 search around for interpolation
around_sigma
,
// final double sigma,
num_virtual_refines
,
// final int num_refines,
debugSuffix
);
// final String debugSuffix)
debugSuffix
);
// final String debugSuffix)
ref_pXpYD_or_null
=
ref_pXpYD
;
ref_scene
.
getErsCorrection
().
setupERS
();
System
.
out
.
println
(
"Calculated virtual_PxPyD"
);
...
...
@@ -8280,9 +8280,6 @@ public class OpticalFlow {
double
[][]
dxyzatr_dt
=
null
;
// should get velocities from HashMap at reference scene from timestamp , not re-calculate.
if
(
mb_en
)
{
// dxyzatr_dt = getVelocities(
// quadCLTs, // QuadCLT [] quadCLTs,
// nscene); // int nscene)
dxyzatr_dt
=
new
double
[][]
{
// for all, including ref
quadCLTs
[
nscene
].
getErsCorrection
().
getErsXYZ_dt
(),
quadCLTs
[
nscene
].
getErsCorrection
().
getErsATR_dt
()};
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
f0ca9c38
...
...
@@ -59,6 +59,8 @@ import com.elphel.imagej.ims.UasLogReader;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
//import java.io.FilterOutputStream;
//import ij.Prefs;
//import ij.io.FileSaver;
public
class
QuadCLT
extends
QuadCLTCPU
{
...
...
@@ -1680,9 +1682,7 @@ public class QuadCLT extends QuadCLTCPU {
scene_atr
,
// double [] scene_atr, // camera orientation relative to world frame
scene
,
//final QuadCLT scene,
ref_scene
,
// final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
// toRGB, // final boolean toRGB,
show_nan
,
// final boolean show_nan,
// suffix, // String suffix,
threadsMax
,
// int threadsMax,
debugLevel
);
// final int debugLevel)
int
[]
wh
=
(
full_woi_in
==
null
)?
null
:
new
int
[]{
...
...
@@ -1701,6 +1701,64 @@ public class QuadCLT extends QuadCLTCPU {
return
imp_render
;
}
public
static
double
[][]
renderDoubleGPUFromDSI
(
final
int
sensor_mask
,
final
boolean
merge_channels
,
final
Rectangle
full_woi_in
,
// show larger than sensor WOI in tiles (or null)
CLTParameters
clt_parameters
,
double
[]
disparity_ref
,
double
[][]
ref_pXpYD
,
// alternative to disparity_ref when reference is not uniform
// motion blur compensation
double
mb_tau
,
// 0.008; // time constant, sec
double
mb_max_gain
,
// 5.0; // motion blur maximal gain (if more - move second point more than a pixel
double
[][]
mb_vectors
,
// now [2][ntiles];
double
[]
scene_xyz
,
// camera center in world coordinates. If null - no shift, no ers
double
[]
scene_atr
,
// camera orientation relative to world frame
final
QuadCLT
scene
,
final
QuadCLT
ref_scene
,
// now - may be null - for testing if scene is rotated ref
final
boolean
toRGB
,
final
boolean
show_nan
,
final
int
debugLevel
){
preRenderGPUFromDSI
(
sensor_mask
,
// final int sensor_mask,
merge_channels
,
// final boolean merge_channels,
0
,
// final int discard_border,
0
,
// final double max_fold,
0
,
// final int min_in_row_col, // Minimal number of defined tiles in a row/column
full_woi_in
,
// final Rectangle full_woi_in, // show larger than sensor WOI in tiles (or null)
clt_parameters
,
// CLTParameters clt_parameters,
disparity_ref
,
// double [] disparity_ref,
ref_pXpYD
,
// double [][] ref_pXpYD, // alternative to disparity_ref when reference is not uniform
// motion blur compensation
mb_tau
,
// double mb_tau, // 0.008; // time constant, sec
mb_max_gain
,
// double mb_max_gain, // 5.0; // motion blur maximal gain (if more - move second point more than a pixel
mb_vectors
,
// double [][] mb_vectors, // now [2][ntiles];
scene_xyz
,
// double [] scene_xyz, // camera center in world coordinates. If null - no shift, no ers
scene_atr
,
// double [] scene_atr, // camera orientation relative to world frame
scene
,
//final QuadCLT scene,
ref_scene
,
// final QuadCLT ref_scene, // now - may be null - for testing if scene is rotated ref
show_nan
,
// final boolean show_nan,
ImageDtt
.
THREADS_MAX
,
// threadsMax, // int threadsMax,
debugLevel
);
// final int debugLevel)
int
[]
wh
=
(
full_woi_in
==
null
)?
null
:
new
int
[]{
full_woi_in
.
width
*
GPUTileProcessor
.
DTT_SIZE
,
full_woi_in
.
height
*
GPUTileProcessor
.
DTT_SIZE
};
double
[][]
drender
=
scene
.
renderDoubleFromTDMono
(
// [scene][color][pixel]
sensor_mask
,
// int sensor_mask,
wh
,
// int [] wh, // may be null, or {width, height}
false
);
// boolean use_reference)
return
drender
;
}
public
static
float
[][]
getTDCombo
(
final
int
sensor_mask
,
final
boolean
merge_channels
,
...
...
@@ -1720,7 +1778,6 @@ public class QuadCLT extends QuadCLTCPU {
double
[]
scene_atr
,
// camera orientation relative to world frame
final
QuadCLT
scene
,
final
QuadCLT
ref_scene
,
// now - may be null - for testing if scene is rotated ref
// final boolean toRGB,
final
boolean
show_nan
,
final
double
[][][]
dbg_PxPyD_slice
,
int
threadsMax
,
...
...
@@ -1826,7 +1883,7 @@ public class QuadCLT extends QuadCLTCPU {
}
}
if
(
window
!=
null
)
{
ref_scene
.
windowP
s
PyD
(
ref_scene
.
windowP
x
PyD
(
pXpYD
,
// final double [][] pXpYD,
window
,
// final Rectangle window) // window in pixels!
max_fold
,
// final double max_fold)
...
...
@@ -1947,7 +2004,7 @@ public class QuadCLT extends QuadCLTCPU {
return
pXpYD
;
}
public
void
windowP
s
PyD
(
public
void
windowP
x
PyD
(
final
double
[][]
pXpYD
,
final
Rectangle
window
,
// window in pixels!
final
double
max_fold
,
...
...
@@ -6011,5 +6068,106 @@ if (debugLevel < -100) {
scene_titles
,
// String [] scene_titles, // recreate slice_titles from scene titles?
debugLevel
);
// final int debugLevel)
}
public
static
double
[][][]
unsharpMaskSourceMono
(
final
QuadCLT
[]
scenes
,
final
int
start_scene
,
final
int
num_scenes
,
final
boolean
um_en
,
final
boolean
unsharped
,
final
double
um_sigma
,
final
double
um_weight
,
final
int
debugLevel
){
double
[][][][]
um_color
=
unsharpMaskSource
(
scenes
,
// final QuadCLT[] scenes,
start_scene
,
// final int start_scene,
num_scenes
,
// final int num_scenes,
um_en
,
// final boolean um_en,
unsharped
,
// final boolean unsharped,
false
,
// update_source, // final boolean update_source, // if update_source will not generate output, return null
um_sigma
,
// final double um_sigma,
um_weight
,
// final double um_weight,
debugLevel
);
// final int debugLevel)
double
[][][]
um_mono
=
new
double
[
um_color
.
length
][
um_color
[
0
].
length
][];
for
(
int
nscene
=
0
;
nscene
<
um_mono
.
length
;
nscene
++)
{
for
(
int
nsens
=
0
;
nsens
<
um_mono
[
nscene
].
length
;
nsens
++)
{
um_mono
[
nscene
][
nsens
]
=
um_color
[
nscene
][
nsens
][
0
];
}
}
return
um_mono
;
}
public
static
double
[][][][]
unsharpMaskSource
(
final
QuadCLT
[]
scenes
,
final
int
start_scene
,
final
int
num_scenes
,
final
boolean
um_en
,
final
boolean
unsharped
,
final
boolean
update_source
,
// if update_source will not generate output, return null
final
double
um_sigma
,
final
double
um_weight
,
final
int
debugLevel
){
final
int
num_sens
=
scenes
[
start_scene
].
getNumSensors
();
int
[]
whc
=
scenes
[
start_scene
].
getWHC
(
false
);
final
int
width
=
whc
[
0
];
final
int
height
=
whc
[
1
];
final
int
num_col
=
whc
[
2
];
final
double
[][][][]
images_um
=
update_source
?
null
:
new
double
[
num_scenes
][
num_sens
][
num_col
][];
final
int
num_sens_col
=
num_sens
*
num_col
;
final
int
num_img
=
num_scenes
*
num_sens_col
;
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
()
{
double
[]
img_buf
=
new
double
[
width
*
height
];
DoubleGaussianBlur
gb
=
new
DoubleGaussianBlur
();
// may be faster if process only where vector_field[nseq][ntile] is not null
for
(
int
nImg
=
ai
.
getAndIncrement
();
nImg
<
num_img
;
nImg
=
ai
.
getAndIncrement
())
{
int
dscene
=
nImg
/
num_sens_col
;
int
nscene
=
dscene
+
start_scene
;
int
nsens_col
=
nImg
%
num_sens_col
;
int
nsens
=
nsens_col
/
num_col
;
int
ncol
=
nsens_col
%
num_col
;
double
[]
img_src
=
scenes
[
nscene
].
getImageData
()[
nsens
][
ncol
];
if
(!
unsharped
&&
um_en
)
{
System
.
arraycopy
(
img_src
,
0
,
img_buf
,
0
,
img_buf
.
length
);
gb
.
blurDouble
(
img_buf
,
//
width
,
height
,
um_sigma
,
// double sigmaX,
um_sigma
,
// double sigmaY,
0.01
);
// double accuracy)
if
(
um_weight
!=
1.0
)
{
for
(
int
i
=
0
;
i
<
img_buf
.
length
;
i
++)
{
img_buf
[
i
]
*=
um_weight
;
}
}
if
(
update_source
)
{
for
(
int
i
=
0
;
i
<
img_buf
.
length
;
i
++)
{
img_src
[
i
]
-=
img_buf
[
i
];
}
}
else
{
for
(
int
i
=
0
;
i
<
img_buf
.
length
;
i
++)
{
img_buf
[
i
]
=
img_src
[
i
]
-
img_buf
[
i
];
}
images_um
[
dscene
][
nsens
][
ncol
]
=
img_buf
.
clone
();
}
}
else
{
// just copy
images_um
[
dscene
][
nsens
][
ncol
]
=
img_src
.
clone
();
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
images_um
;
}
}
src/main/java/com/elphel/imagej/tileprocessor/QuadCLTCPU.java
View file @
f0ca9c38
...
...
@@ -172,6 +172,7 @@ public class QuadCLTCPU {
public
String
image_path
=
null
;
double
[]
gps_lla
=
null
;
public
double
[][][]
image_data
=
null
;
// [channel][color][pixel]
public
double
[][][]
image_data_alt
=
null
;
// [channel][color][pixel] If not null - will use instead of image_data
public
double
[][]
image_center
=
null
;
// reference to a common sensor-combined center view image (set for center instance)
public
boolean
no_kernels
=
false
;
// debug feature
...
...
@@ -6317,11 +6318,20 @@ public class QuadCLTCPU {
public
double
[][][]
getResetImageData
(){
new_image_data
=
false
;
return
image_data
;
if
(
image_data_alt
!=
null
)
{
return
image_data_alt
;
}
else
{
return
image_data
;
}
}
public
double
[][][]
getImageData
(){
// does not reset new data
return
image_data
;
if
(
image_data_alt
!=
null
)
{
return
image_data_alt
;
}
else
{
return
image_data
;
}
}
public
void
setImageData
(
double
[][][]
data
)
{
image_data
=
data
;
new_image_data
=
true
;
...
...
@@ -6329,9 +6339,17 @@ public class QuadCLTCPU {
image_fpn
=
null
;
}
public
void
setImageDataAlt
(
double
[][][]
data
)
{
image_data_alt
=
data
;
new_image_data
=
true
;
// even if null set new data as it will use image_data after image_data_alt
// image_fpn_applied = null;
// image_fpn = null;
}
public
double
[][]
getResetImageCenter
(){
new_image_data
=
false
;
boolean
debug
=
false
;
boolean
debug
=
true
;
//
false;
if
(
debug
)
{
if
(
image_center
==
null
)
{
System
.
out
.
println
(
"--- getResetImageCenter(): image_center== null"
);
...
...
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