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
eae75ef1
Commit
eae75ef1
authored
Jul 02, 2026
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving renderSceneSequence()
parent
d3c015c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
110 deletions
+57
-110
CuasRanging.java
src/main/java/com/elphel/imagej/cuas/CuasRanging.java
+39
-1
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+14
-105
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+4
-4
No files found.
src/main/java/com/elphel/imagej/cuas/CuasRanging.java
View file @
eae75ef1
...
...
@@ -75,6 +75,7 @@ public class CuasRanging {
}
public
ImagePlus
prepareFpixels
(){
boolean
dbg_save_fpixels
=
true
;
double
[][]
combo_dsi
=
getCenter_CLT
().
comboFromMain
();
double
[][]
dls
=
{
combo_dsi
[
OpticalFlow
.
COMBO_DSN_INDX_DISP
],
// **** null on second scene sequence
...
...
@@ -135,6 +136,37 @@ public class CuasRanging {
double
[]
cuas_atr
=
OpticalFlow
.
ZERO3
;
String
scenes_suffix
=
getCenter_CLT
().
getImageName
()+
"-CUAS"
;
// "1747829900_781803-SEQ-FG-MONO-FPN";
boolean
merge_all
=
false
;
// clt_parameters.imp.merge_all || !um_mono; // no unsharp mask -> terrain->merge_all
int
sensor_mask
=
merge_all
?
1
:
-
1
;
if
(
dbg_save_fpixels
)
{
ImagePlus
imp_targets
=
OpticalFlow
.
renderSceneSequence
(
clt_parameters
,
// CLTParameters clt_parameters,
true
,
// center_CLT.hasCenterClt(), // boolean mode_cuas,
false
,
// clt_parameters.imp.um_mono, // boolean um_mono,
clt_parameters
.
imp
.
calculate_average
,
// boolean insert_average, // then add new parameter, keep add average
null
,
// int [] average_range,
null
,
// average_channels, // average_slice,
clt_parameters
.
imp
.
subtract_average
,
// boolean subtract_average,
clt_parameters
.
imp
.
running_average
,
// int running_average,
null
,
// fov_tiles, // Rectangle fov_tiles,
1
,
// mode3d, // int mode3d,
false
,
// toRGB, // boolean toRGB,
xyz_offset
,
// double [] stereo_offset, // offset reference camera {x,y,z}
cuas_atr
,
// double [] stereo_atr, // offset reference orientation (cuas)
sensor_mask
,
// sensor_mask, // int sensor_mask,
merge_all
,
// boolean merge_all,
scenes_suffix
,
// String suffix,
ds_vantage
[
0
],
// selected_disparity, // double [] ref_disparity,
scenes
,
// QuadCLT [] quadCLTs,
getCenter_CLT
(),
// ref_index, // int ref_index,
ImageDtt
.
THREADS_MAX
,
// threadsMax, // int threadsMax,
debugLevel
);
// int debugLevel);
getCenter_CLT
().
saveImagePlusInModelDirectory
(
imp_targets
.
getTitle
()+
"-DBG"
,
// "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_targets
);
// imp_scenes); // ImagePlus imp)
}
merge_all
=
true
;
// clt_parameters.imp.merge_all || !um_mono; // no unsharp mask -> terrain->merge_all
sensor_mask
=
merge_all
?
1
:
-
1
;
ImagePlus
imp_targets
=
OpticalFlow
.
renderSceneSequence
(
clt_parameters
,
// CLTParameters clt_parameters,
true
,
// center_CLT.hasCenterClt(), // boolean mode_cuas,
...
...
@@ -149,13 +181,19 @@ public class CuasRanging {
false
,
// toRGB, // boolean toRGB,
xyz_offset
,
// double [] stereo_offset, // offset reference camera {x,y,z}
cuas_atr
,
// double [] stereo_atr, // offset reference orientation (cuas)
1
,
// sensor_mask, // int sensor_mask,
sensor_mask
,
// sensor_mask, // int sensor_mask,
merge_all
,
// boolean merge_all,
scenes_suffix
,
// String suffix,
ds_vantage
[
0
],
// selected_disparity, // double [] ref_disparity,
scenes
,
// QuadCLT [] quadCLTs,
getCenter_CLT
(),
// ref_index, // int ref_index,
ImageDtt
.
THREADS_MAX
,
// threadsMax, // int threadsMax,
debugLevel
);
// int debugLevel);
if
(
dbg_save_fpixels
)
{
getCenter_CLT
().
saveImagePlusInModelDirectory
(
imp_targets
.
getTitle
()+
"-DBG"
,
// "GPU-SHIFTED-D"+clt_parameters.disparity, // String suffix,
imp_targets
);
// imp_scenes); // ImagePlus imp)
}
return
imp_targets
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
eae75ef1
...
...
@@ -7272,6 +7272,8 @@ java.lang.NullPointerException
quadCLTs
,
// QuadCLT [] scenes,
debugLevel
);
ImagePlus
imp_targets
=
cuasRangingRT
.
prepareFpixels
();
// GPU generator (explicit, CUDA-sensitive); also builds the QuadCLT instances = borrowed-calibration source
if
(
clt_parameters
.
imp
.
curt_cond_test
)
{
// Conditioning/calibration isolation test (curt_cond_test): reuse the QuadCLT instances just built as the
// borrowed-calibration source and print the per-sensor average spread. Baseline reads the current-scene TD
...
...
@@ -7518,6 +7520,7 @@ java.lang.NullPointerException
}
float
[]
average_pixels
=
(
master_CLT
.
getCenterAverage
()
!=
null
)
?
((
float
[])
master_CLT
.
getCenterAverage
().
getProcessor
().
getPixels
()):
null
;
float
[][]
average_channels
=
new
float
[][]
{
average_pixels
};
// for future color images
boolean
merge_all
=
clt_parameters
.
imp
.
merge_all
||
!
um_mono
;
// no unsharp mask -> terrain->merge_all
imp_scenes_pair
[
nstereo
]=
renderSceneSequence
(
clt_parameters
,
// CLTParameters clt_parameters,
master_CLT
.
hasCenterClt
(),
// boolean mode_cuas,
...
...
@@ -7533,6 +7536,7 @@ java.lang.NullPointerException
xyz_offset
,
// double [] stereo_offset, // offset reference camera {x,y,z}
cuas_atr
,
// double [] stereo_atr, // offset reference orientation (cuas)
sensor_mask
,
// int sensor_mask,
merge_all
,
// boolean merge_all,
scenes_suffix
,
// String suffix,
ds_vantage
[
0
],
// selected_disparity, // double [] ref_disparity,
quadCLTs
,
// QuadCLT [] quadCLTs,
...
...
@@ -8208,6 +8212,7 @@ java.lang.NullPointerException
if
((
combo_dsn_final
==
null
)
||
(
combo_dsn_final
.
length
<=
COMBO_DSN_INDX_TERRAIN
)
||
(
combo_dsn_final
[
COMBO_DSN_INDX_TERRAIN
]
==
null
))
{
System
.
out
.
println
(
"No terrain data available"
);
}
else
{
boolean
merge_all
=
clt_parameters
.
imp
.
merge_all
||
!
um_mono
;
// no unsharp mask -> terrain->merge_all
double
[]
elevation_disparity
=
combo_dsn_final
[
COMBO_DSN_INDX_DISP
];
String
scenes_suffix
=
master_CLT
.
getImageName
()+
"-ELEVATION"
;
// quadCLTs[quadCLTs.length-1].getImageName()+"-ELEVATION";
ImagePlus
imp_elevation
=
renderSceneSequence
(
...
...
@@ -8225,6 +8230,7 @@ java.lang.NullPointerException
ZERO3
,
// double [] stereo_offset, // offset reference camera {x,y,z}
null
,
// double [] stereo_atr, // offset reference orientation (cuas)
1
,
// int sensor_mask,
merge_all
,
// boolean merge_all,
scenes_suffix
,
// String suffix,
elevation_disparity
,
// selected_disparity, // double [] ref_disparity,
quadCLTs
,
// QuadCLT [] quadCLTs,
...
...
@@ -10250,6 +10256,7 @@ java.lang.NullPointerException
average_range
[
1
]
=
Math
.
max
(
average_range
[
0
],
average_range
[
1
]);
average_range
[
1
]
=
Math
.
min
(
num_scenes
-
1
,
average_range
[
1
]);
}
boolean
merge_all
=
clt_parameters
.
imp
.
merge_all
||
!
um_mono
;
// no unsharp mask -> terrain->merge_all
return
renderSceneSequence
(
clt_parameters
,
// CLTParameters clt_parameters,
false
,
// boolean mode_cuas,
...
...
@@ -10267,6 +10274,7 @@ java.lang.NullPointerException
null
,
// double [] stereo_atr_in, // offset reference orientation (cuas)
null
,
// double [][] post_rotate,
sensor_mask
,
// int sensor_mask,
merge_all
,
// boolean merge_all,
suffix_in
,
// String suffix_in,
ref_disparity
,
// double [] ref_disparity,
selected_scenes
,
// QuadCLT [] quadCLTs,
...
...
@@ -10291,6 +10299,7 @@ java.lang.NullPointerException
double
[]
stereo_xyz
,
// offset reference camera {x,y,z}
double
[]
stereo_atr_in
,
// offset reference orientation (cuas)
int
sensor_mask
,
boolean
merge_all
,
String
suffix_in
,
double
[]
ref_disparity
,
QuadCLT
[]
quadCLTs
,
...
...
@@ -10314,6 +10323,7 @@ java.lang.NullPointerException
stereo_atr_in
,
// double [] stereo_atr_in, // offset reference orientation (cuas)
null
,
// double [][] post_rotate,
sensor_mask
,
// int sensor_mask,
merge_all
,
// boolean merge_all,
suffix_in
,
// String suffix_in,
ref_disparity
,
// double [] ref_disparity,
quadCLTs
,
// QuadCLT [] quadCLTs,
...
...
@@ -10338,6 +10348,7 @@ java.lang.NullPointerException
double
[]
stereo_atr_in
,
// offset reference orientation (cuas)
double
[][]
post_rotate
,
int
sensor_mask
,
boolean
merge_all
,
String
suffix_in
,
double
[]
ref_disparity
,
// may be ground disparity
QuadCLT
[]
quadCLTs
,
...
...
@@ -10359,15 +10370,14 @@ java.lang.NullPointerException
if
(
mode3d
!=
1
)
{
running_average
=
0
;
}
final
float
fum_weight
=
(
float
)
um_weight
;
boolean
merge_all
=
clt_parameters
.
imp
.
merge_all
||
!
um_mono
;
// no unsharp mask -> terrain->merge_all
// boolean merge_all = clt_parameters.imp.merge_all || !um_mono; // no unsharp mask -> terrain->merge_all
if
(
mode3d
<
1
)
{
merge_all
=
false
;
}
if
(
merge_all
)
{
sensor_mask
=
1
;
sensor_mask
=
1
;
// should it define - which channels to merge?
}
String
suffix
=
suffix_in
+((
mode3d
>
0
)?(
merge_all
?
"-MERGED"
:
"-
SINGLE"
):
""
);
String
suffix
=
suffix_in
+((
mode3d
>
0
)?(
merge_all
?
"-MERGED"
:
"-
INDIVIDUAL"
):
""
);
// "SINGLE
if
((
mode3d
<
0
)
&&
(
corr_raw_ers
))
{
suffix
+=
"-RAW_ERS"
;
}
...
...
@@ -10401,62 +10411,12 @@ java.lang.NullPointerException
ref_disparity
,
// final double [] ground_disparity,
ground_xyzatr
,
// final double [][] ground_xyzatr,
ref_scene
);
// final QuadCLT ref_scene)
/*
final double [] ground_disparity = ref_disparity; // input
final int tilesX=ref_scene.getTilesX();
final int tilesY=ref_scene.getTilesY();
final int transform_size = ref_scene.getTileSize();
final int tiles = tilesX * tilesY;
final Thread[] threads = ImageDtt.newThreadArray();
final AtomicInteger ai = new AtomicInteger(0);
final double [][] fgnd_pXpYD = new double [tiles][];
for (int ithread = 0; ithread < threads.length; ithread++) {
threads[ithread] = new Thread() {
public void run() {
for (int nTile = ai.getAndIncrement(); nTile < tiles; nTile = ai.getAndIncrement()) if (!Double.isNaN(ground_disparity[nTile])){
double disparity = ground_disparity[nTile];
int tileY = nTile / tilesX;
int tileX = nTile % tilesX;
double centerX = (tileX + 0.5) * transform_size; // - shiftX;
double centerY = (tileY + 0.5) * transform_size; // - shiftY;
if (disparity < 0) {
disparity = 1.0* disparity; // 0.0;
}
fgnd_pXpYD[nTile] = new double[] {centerX, centerY, disparity};
// fgnd_pXpYD[nTile] = new double[] {transform_size*tilesX-centerX, transform_size*tilesY-centerY, disparity};
}
}
};
}
ImageDtt.startAndJoin(threads);
*/
ref_pXpYD
=
OpticalFlow
.
transformToScenePxPyD
(
fgnd_pXpYD
,
// final double [][] reference_pXpYD,// invalid tiles - NaN in disparity. Should be no nulls, no NaN disparity
ground_xyzatr
[
0
],
// final double [] scene_xyz, // camera center in world (reference) coordinates
ground_xyzatr
[
1
],
// final double [] scene_atr, // camera orientation relative to world (reference) frame
ref_scene
,
// final QuadCLT reference_QuadClt) //
null
);
// final QuadCLT scene_QuadClt) //
/*
double [] disp_dbg = new double[tiles];
Arrays.fill(disp_dbg, Double.NaN);
for (int i = 0; i < tiles; i++) {
if (ref_pXpYD[i] != null) {
disp_dbg[i] = ref_pXpYD[i][2];
}
}
for (int i = 0; i < tiles; i++) {
int i1 = tiles-i-1;
if (ref_pXpYD[i] != null) {
if (ref_pXpYD[i1] != null) {
ref_pXpYD[i][2]=disp_dbg[i1];
} else {
ref_pXpYD[i] = null;
}
}
}
*/
ref_pXpYD_or_null
=
ref_pXpYD
;
ref_scene
.
getErsCorrection
().
setupERS
();
if
(
debugLevel
>
-
3
)
{
...
...
@@ -10723,57 +10683,6 @@ java.lang.NullPointerException
}
}
}
/*
if (average_slice != null) {
for (int nchn = 0; nchn < channels.length; nchn++) {
float [] avg_slice = (float[]) stack_scenes.getPixels(nchn+1);
System.arraycopy(
average_slice[nchn],
0,
avg_slice,
0,
average_slice[nchn].length);
}
} else {
int num_scenes = (stack_scenes.getSize() / channels.length) - num_avg_slices; // remove averages (1 or 2)
// single-threaded
int first_scene = 0;
int last_scene = num_scenes - 1;
if (average_range != null) {
if (average_range.length == 0) {
average_range = new int [] {last_scene/4, (3*last_scene)/4};
}
first_scene = Math.max(first_scene, average_range[0]);
last_scene = Math.min(last_scene, average_range[1]);
}
for (int nchn = 0; nchn < channels.length; nchn++) {
String label_avg = (channels.length==1) ? "average":("average-"+nchn);
if ((first_scene != 0) || (last_scene != (num_scenes - 1))) {
label_avg+="-+"+first_scene+":"+last_scene;
}
stack_scenes.setSliceLabel(label_avg, nchn+1);
float [] avg_slice = (float[]) stack_scenes.getPixels(nchn+1);
int [] avg_n = new int[avg_slice.length];
int num_pix = avg_slice.length;
for (int nscene = first_scene; nscene <= last_scene; nscene++) {
float [] fpixels = (float[]) stack_scenes.getPixels(nchn + (nscene+1)*channels.length + 1);
for (int npix = 0; npix < num_pix; npix++) if (!Float.isNaN(fpixels[npix])){
avg_slice[npix] += fpixels[npix];
avg_n[npix]++;
}
}
for (int npix = 0; npix < num_pix; npix++) {
if (avg_n[npix] > 0) {
avg_slice[npix] /= avg_n[npix];
}else {
avg_slice[npix] = Float.NaN;
}
}
}
}
*/
// seems that fpixels are automatically updated in the images
}
if
(
running_average
>
1
)
{
int
scene_0
=
insert_average
?
1
:
0
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
eae75ef1
...
...
@@ -1690,7 +1690,7 @@ public class QuadCLT extends QuadCLTCPU {
toRGB
,
// boolean toRGB,
false
,
// use_reference, // boolean use_reference
suffix
);
// String suffix)
return
imp_render
;
return
imp_render
;
}
...
...
@@ -1862,9 +1862,9 @@ public class QuadCLT extends QuadCLTCPU {
public
static
double
[][]
preRenderGPUFromDSI
(
// will return PxPyD
final
boolean
accumulate
,
final
double
global_scale
,
// <=1.0
final
int
sensor_mask
,
final
boolean
merge_channels
,
final
double
global_scale
,
// <=1.0
final
int
sensor_mask
,
// not used
final
boolean
merge_channels
,
// not used
final
int
discard_border
,
final
double
max_fold
,
final
int
min_in_row_col
,
// Minimal number of defined tiles in a row/column
...
...
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