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
9fb7ab22
Commit
9fb7ab22
authored
Feb 04, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started with dual-max (FG+BG, such as semi-transparent grass, bushes)
parent
fd67c744
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
22 deletions
+133
-22
Correlation2d.java
...n/java/com/elphel/imagej/tileprocessor/Correlation2d.java
+42
-0
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+61
-5
ImageDttParameters.java
...a/com/elphel/imagej/tileprocessor/ImageDttParameters.java
+7
-0
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+20
-17
TwoQuadCLT.java
...main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
+3
-0
No files found.
src/main/java/com/elphel/imagej/tileprocessor/Correlation2d.java
View file @
9fb7ab22
...
...
@@ -2403,7 +2403,49 @@ public class Correlation2d {
return
rslt
;
}
/**
* Analyze 1d correlation (single centerline of the 3D phase correlation combined output
* from all pairs or only diameters to detect double maximum (simultaneous FG+BG)
* @param combo_corrs 2D phase correlation, now 15x15 = 255 pixels long
* @param min_fraction minimal ratio of weaker maximum to the strongest
* @return array of 1 or 2 {disparity, strength} pairs (zero pairs if no local max)
*/
public
double
[][]
getDoublePoly
(
double
[]
combo_corrs
,
double
min_fraction
){
int
center_x
=
2
*
(
transform_size
-
1
)
*
transform_size
;
// 112
int
[]
imx
=
new
int
[
2
];
for
(
int
i
=
center_x
-
transform_size
+
2
;
i
<
center_x
+
transform_size
-
1
;
i
++)
{
double
c
=
combo_corrs
[
i
];
if
((
c
>
combo_corrs
[
i
-
1
])
&&
(
c
>
combo_corrs
[
i
+
1
]))
{
if
((
imx
[
0
]
==
0
)
||
(
c
>
combo_corrs
[
imx
[
0
]]))
{
imx
[
1
]
=
imx
[
0
];
imx
[
0
]
=
i
;
}
else
if
((
imx
[
1
]
==
0
)
||
(
c
>
combo_corrs
[
imx
[
1
]]))
{
imx
[
1
]
=
i
;
}
i
++;
// skip next after max
}
}
if
(
imx
[
0
]
==
0
)
return
new
double
[
0
][];
int
nm
=
1
;
if
((
imx
[
1
]
>
0
)
&&
(
combo_corrs
[
imx
[
1
]]/
combo_corrs
[
imx
[
0
]]
>
min_fraction
))
{
nm
++;
}
double
[][]
maxes
=
new
double
[
nm
][
2
];
for
(
int
i
=
0
;
i
<
nm
;
i
++)
{
double
c
=
combo_corrs
[
imx
[
i
]];
double
a
=
(
combo_corrs
[
imx
[
i
]
+
1
]
+
combo_corrs
[
imx
[
i
]
-
1
])
/
2
-
c
;
double
b
=
(
combo_corrs
[
imx
[
i
]
+
1
]
-
combo_corrs
[
imx
[
i
]
-
1
]);
maxes
[
i
][
0
]
=
imx
[
i
]-
center_x
-
0.5
*
b
/
a
;
maxes
[
i
][
1
]
=
c
-
0.25
*
b
*
b
/
a
;
}
return
maxes
;
}
//corr_size transform_size
/**
* Calculate 1-d maximum location, strength and half-width for the special strip (odd rows shifted by 0.5
* Negative values are ignored!
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
9fb7ab22
...
...
@@ -2303,7 +2303,7 @@ public class ImageDtt extends ImageDttCPU {
final
int
threadsMax
,
// maximal number of threads to launch
final
int
globalDebugLevel
)
{
final
boolean
diameters_combo
=
(
imgdtt_params
.
mcorr_dual_fract
>
0.0
);
// add diameters-only combo after all-combo
if
(
this
.
gpuQuad
==
null
)
{
System
.
out
.
println
(
"clt_aberrations_quad_corr_GPU(): this.gpuQuad is null, bailing out"
);
return
;
...
...
@@ -2483,13 +2483,18 @@ public class ImageDtt extends ImageDttCPU {
nTile
=
tileY
*
tilesX
+
tileX
;
if
(
tp_tasks
[
iTile
].
getTask
()
==
0
)
continue
;
// nothing to do for this tile
boolean
debugTile0
=(
tileX
==
debug_tileX
)
&&
(
tileY
==
debug_tileY
)
&&
(
globalDebugLevel
>
0
);
boolean
debugTile1
=(
tileX
==
debug_tileX
)
&&
(
tileY
==
debug_tileY
)
&&
(
globalDebugLevel
>
-
10
);
if
(
debugTile0
)
{
System
.
out
.
println
(
"clt_process_tl_correlations(): tileX="
+
tileX
+
", tileY="
+
tileY
+
", iTile="
+
iTile
+
", nTile="
+
nTile
);
}
// TODO: move port coordinates out of color channel loop
// double [][] centersXY = tp_tasks[iTile].getDoubleXY(); // isAux());
// Generate +1/+2
double
[][]
disp_dist
=
tp_tasks
[
iTile
].
getDoubleDispDist
();
double
[][]
corrs
=
new
double
[
correlation2d
.
getNumPairs
()
+
(
combine_corrs
?
1
:
0
)][];
// extra for combo "all"
int
num_combo
=
combine_corrs
?
(
diameters_combo
?
2
:
1
)
:
0
;
double
[][]
corrs
=
new
double
[
correlation2d
.
getNumPairs
()
+
num_combo
][];
// extra for combo "all"
// copy correlation tiles from the GPU's floating point arrays
for
(
int
ipair
=
0
;
ipair
<
used_pairs_list
.
length
;
ipair
++)
{
int
pair
=
used_pairs_list
[
ipair
];
...
...
@@ -2511,7 +2516,8 @@ public class ImageDtt extends ImageDttCPU {
double
[]
disp_str
=
{
0.0
,
0.0
};
// disparity = 0 will be initial approximation for LMA if no averaging
if
(
combine_corrs
)
{
double
[]
corr_combo_tile
=
correlation2d
.
accumulateInit
();
// combine all available pairs
double
sumw
=
0.0
;
double
[]
corr_dia_tile
=
diameters_combo
?
correlation2d
.
accumulateInit
():
null
;
// combine diameters
double
sumw
=
0.0
,
sumw_dia
=
0.0
;
if
(
imgdtt_params
.
mcorr_static_weights
||
imgdtt_params
.
mcorr_dynamic_weights
)
{
double
[]
weights
=
new
double
[
correlation2d
.
getNumPairs
()];
if
(
imgdtt_params
.
mcorr_static_weights
)
{
...
...
@@ -2552,23 +2558,73 @@ public class ImageDtt extends ImageDttCPU {
corr_combo_tile
,
// double [] accum_tile,
corrs
,
// double [][] corr_tiles, may be longer than selection, extra will be ignored
weights
);
// double [] weights);
if
(
corr_dia_tile
!=
null
)
{
double
[]
weights_dia
=
weights
.
clone
();
boolean
[]
sel_dia
=
correlation2d
.
selectDiameters
(
null
);
for
(
int
i
=
0
;
i
<
sel_dia
.
length
;
i
++)
{
if
(!
sel_dia
[
i
])
{
weights_dia
[
i
]
=
0.0
;
}
}
sumw_dia
=
correlation2d
.
accummulatePairs
(
corr_dia_tile
,
// double [] accum_tile,
corrs
,
// double [][] corr_tiles, may be longer than selection, extra will be ignored
weights_dia
);
// double [] weights);
}
}
else
{
// old way, same weight for all pairs
sumw
=
correlation2d
.
accummulatePairs
(
corr_combo_tile
,
// double [] accum_tile,
corrs
,
// double [][] corr_tiles, may be longer than selection, extra will be ignored
correlation2d
.
selectAll
(),
// boolean [] selection,
1.0
);
// double weight);
if
(
corr_dia_tile
!=
null
)
{
sumw_dia
=
correlation2d
.
accummulatePairs
(
corr_dia_tile
,
// double [] accum_tile,
corrs
,
// double [][] corr_tiles, may be longer than selection, extra will be ignored
correlation2d
.
selectDiameters
(
null
),
// boolean [] selection,
1.0
);
// double weight);
}
}
correlation2d
.
normalizeAccumulatedPairs
(
corr_combo_tile
,
sumw
);
// corrs[dcorr_td[iTile].length] = corr_combo_tile; // last element
corrs
[
corrs
.
length
-
1
]
=
corr_combo_tile
;
// last element
// corrs[corrs.length -1] = corr_combo_tile; // last element
corrs
[
correlation2d
.
getNumPairs
()]
=
corr_combo_tile
;
if
(
corr_dia_tile
!=
null
)
{
correlation2d
.
normalizeAccumulatedPairs
(
corr_dia_tile
,
sumw_dia
);
corrs
[
correlation2d
.
getNumPairs
()+
1
]
=
corr_dia_tile
;
}
// copy to output for monitoring if non-null;
if
((
clt_corr_out
!=
null
)
&&
(
clt_corr_out
.
length
>
num_pairs
))
{
clt_corr_out
[
num_pairs
][
tileY
][
tileX
]
=
corr_combo_tile
;
if
((
clt_corr_out
.
length
>
(
num_pairs
+
1
))
&&
(
corr_dia_tile
!=
null
))
{
clt_corr_out
[
num_pairs
+
1
][
tileY
][
tileX
]
=
corr_dia_tile
;
}
}
// calculate 0,1, or 2 maximums
if
(
debugTile1
)
{
System
.
out
.
println
(
"clt_process_tl_correlations(): debugTile1"
);
}
double
[][]
maxes
=
correlation2d
.
getDoublePoly
(
((
corr_dia_tile
!=
null
)
?
corr_dia_tile
:
corr_combo_tile
),
// double [] combo_corrs,
imgdtt_params
.
mcorr_dual_fract
);
//double min_fraction
// TODO: add corr layer - copy of combo with singles as nulls
// if ((maxes.length < 2) && (clt_corr_out != null) && (clt_corr_out.length > num_pairs)) {
if
((
maxes
.
length
<
2
)
&&
(
corr_dia_tile
!=
null
))
{
//FIXME: Debug
// corrs[correlation2d.getNumPairs()] = null; // temporarily keep only with pairs
Arrays
.
fill
(
corrs
[
correlation2d
.
getNumPairs
()+
1
],
Double
.
NaN
);
}
if
(
debugTile1
)
{
System
.
out
.
println
(
"clt_process_tl_correlations() maxes="
);
for
(
int
i
=
0
;
i
<
maxes
.
length
;
i
++)
{
System
.
out
.
println
(
String
.
format
(
"maxes[%d][0]=%f, maxes[%d][1]=%f"
,
i
,
maxes
[
i
][
0
],
i
,
maxes
[
i
][
1
]));
}
}
if
(
disparity_map
!=
null
)
{
int
[]
ixy
=
correlation2d
.
getMaxXYInt
(
// find integer pair or null if below threshold // USED in lwir
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDttParameters.java
View file @
9fb7ab22
...
...
@@ -131,6 +131,7 @@ public class ImageDttParameters {
public
boolean
mcorr_static_weights
=
true
;
// when mixing , apply static weights to pairs depending on their lengths
public
double
mcorr_weights_power
=
2.0
;
// divide pair by horizontal (disparity) width after rotation/scaling (skip negative when measuring width)
public
boolean
mcorr_dynamic_weights
=
true
;
// Apply weights to pairs dependent on the width in disparity direction
public
double
mcorr_dual_fract
=
0.15
;
// Minimal relative strength of the second correlation maximum to treat as FG+BG
/// these are just for testing, actual will be generated specifically for different applications (LY will use closest pairs)
public
int
mcorr_comb_width
=
15
;
...
...
@@ -557,6 +558,8 @@ public class ImageDttParameters {
"Increase weight of pairs with linear features perpendicular to the base direction and long base pairs"
);
gd
.
addCheckbox
(
"Apply dynaminc (feature-dependent) weights defined above"
,
this
.
mcorr_dynamic_weights
,
"Calculate each pairs's width (in the disparity direction) after rotation/scaling and apply"
);
gd
.
addNumericField
(
"Minimal relative strength of the second maximum (0 - ignore)"
,
this
.
mcorr_dual_fract
,
3
,
6
,
""
,
"Minimal relative strength of the second correlation maximum to treat as FG+BG (0 - ignore dual maximums, no special treatment)"
);
gd
.
addMessage
(
"Generating grid for combining visualization, actual will be provided programmatically"
);
gd
.
addNumericField
(
"Width of a combined correlation tile"
,
this
.
mcorr_comb_width
,
0
,
3
,
"pix"
,
...
...
@@ -909,6 +912,7 @@ public class ImageDttParameters {
this
.
mcorr_static_weights
=
gd
.
getNextBoolean
();
this
.
mcorr_weights_power
=
gd
.
getNextNumber
();
this
.
mcorr_dynamic_weights
=
gd
.
getNextBoolean
();
this
.
mcorr_dual_fract
=
gd
.
getNextNumber
();
this
.
mcorr_comb_width
=
(
int
)
gd
.
getNextNumber
();
this
.
mcorr_comb_height
=(
int
)
gd
.
getNextNumber
();
...
...
@@ -1126,6 +1130,7 @@ public class ImageDttParameters {
properties
.
setProperty
(
prefix
+
"mcorr_static_weights"
,
this
.
mcorr_static_weights
+
""
);
properties
.
setProperty
(
prefix
+
"mcorr_weights_power"
,
this
.
mcorr_weights_power
+
""
);
properties
.
setProperty
(
prefix
+
"mcorr_dynamic_weights"
,
this
.
mcorr_dynamic_weights
+
""
);
properties
.
setProperty
(
prefix
+
"mcorr_dual_fract"
,
this
.
mcorr_dual_fract
+
""
);
properties
.
setProperty
(
prefix
+
"mcorr_comb_width"
,
this
.
mcorr_comb_width
+
""
);
properties
.
setProperty
(
prefix
+
"mcorr_comb_height"
,
this
.
mcorr_comb_height
+
""
);
...
...
@@ -1349,6 +1354,7 @@ public class ImageDttParameters {
if
(
properties
.
getProperty
(
prefix
+
"mcorr_static_weights"
)!=
null
)
this
.
mcorr_static_weights
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mcorr_static_weights"
));
if
(
properties
.
getProperty
(
prefix
+
"mcorr_weights_power"
)!=
null
)
this
.
mcorr_weights_power
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"mcorr_weights_power"
));
if
(
properties
.
getProperty
(
prefix
+
"mcorr_dynamic_weights"
)!=
null
)
this
.
mcorr_dynamic_weights
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"mcorr_dynamic_weights"
));
if
(
properties
.
getProperty
(
prefix
+
"mcorr_dual_fract"
)!=
null
)
this
.
mcorr_dual_fract
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"mcorr_dual_fract"
));
if
(
properties
.
getProperty
(
prefix
+
"mcorr_comb_width"
)!=
null
)
this
.
mcorr_comb_width
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"mcorr_comb_width"
));
if
(
properties
.
getProperty
(
prefix
+
"mcorr_comb_height"
)!=
null
)
this
.
mcorr_comb_height
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"mcorr_comb_height"
));
...
...
@@ -1587,6 +1593,7 @@ public class ImageDttParameters {
idp
.
mcorr_static_weights
=
this
.
mcorr_static_weights
;
idp
.
mcorr_weights_power
=
this
.
mcorr_weights_power
;
idp
.
mcorr_dynamic_weights
=
this
.
mcorr_dynamic_weights
;
idp
.
mcorr_dual_fract
=
this
.
mcorr_dual_fract
;
idp
.
mcorr_comb_width
=
this
.
mcorr_comb_width
;
idp
.
mcorr_comb_height
=
this
.
mcorr_comb_height
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
9fb7ab22
...
...
@@ -2590,7 +2590,7 @@ public class OpticalFlow {
for
(
int
indx
=
ai
.
getAndIncrement
();
indx
<
pXpYD
.
length
;
indx
=
ai
.
getAndIncrement
())
if
(
pXpYD
[
indx
]
!=
null
)
{
int
tx
=
(
int
)
Math
.
round
(
pXpYD
[
indx
][
0
]/
tileSize
);
int
ty
=
(
int
)
Math
.
round
(
pXpYD
[
indx
][
1
]/
tileSize
);
if
((
debug_level
>
0
)
&&
(
tx
==
dbg_tileX
)
&&
(
ty
==
dbg_tileY
))
{
if
((
debug_level
>
0
)
&&
(
indx
==
dbg_nTile
))
{
//(
tx == dbg_tileX) && (ty == dbg_tileY)) {
System
.
out
.
println
(
"filterBG(): tx = "
+
tx
+
", ty="
+
ty
+
", indx="
+
indx
);
System
.
out
.
print
(
""
);
}
...
...
@@ -4873,19 +4873,19 @@ public class OpticalFlow {
fs
.
saveAsTiff
(
file_path
);
System
.
out
.
println
(
"intersceneExport(): saved "
+
file_path
);
}
String
offsets_suffix
=
"-DISP_OFFSETS"
;
if
(
randomize_offsets
)
{
offsets_suffix
+=
"-RND"
;
}
if
(
disparity_steps
>
0
)
{
String
offsets_suffix
=
"-DISP_OFFSETS"
;
if
(
randomize_offsets
)
{
offsets_suffix
+=
"-RND"
;
}
ref_scene
.
saveDoubleArrayInModelDirectory
(
offsets_suffix
,
// String suffix,
soffset_centers
,
// null, // String [] labels, // or null
all_offsets
,
// dbg_data, // double [][] data,
tilesX
,
// int width,
tilesY
);
// int height)
ref_scene
.
saveDoubleArrayInModelDirectory
(
offsets_suffix
,
// String suffix,
soffset_centers
,
// null, // String [] labels, // or null
all_offsets
,
// dbg_data, // double [][] data,
tilesX
,
// int width,
tilesY
);
// int height)
}
}
/**
...
...
@@ -6451,16 +6451,19 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
ref_scene
);
// final QuadCLT reference_QuadClt)
double
max_overlap
=
0.6
;
double
[]
disparity_cam
=
null
;
// for now
// double min_str_cam = 0.1;
double
min_adisp_cam
=
0.2
;
double
min_rdisp_cam
=
0.03
;
double
[][]
scene_ds
=
conditionInitialDS
(
clt_parameters
,
// CLTParameters clt_parameters,
scenes
[
nscene
],
// QuadCLT scene,
-
1
);
// int debug_level);
double
[]
disparity_cam
=
scene_ds
[
0
];
// null; // for now
scene_pXpYD
=
filterBG
(
scenes
[
indx_ref
].
getTileProcessor
(),
// final TileProcessor tp,
scene_pXpYD_prefilter
,
// final double [][] pXpYD,
max_overlap
,
// final double max_overlap,
disparity_cam
,
// final double [] disparity_cam,
null
,
//
disparity_cam, // final double [] disparity_cam,
min_adisp_cam
,
// final double min_adisp_cam,
min_rdisp_cam
,
// final double min_rdisp_cam,
clt_parameters
.
tileX
,
// final int dbg_tileX,
...
...
@@ -6663,7 +6666,7 @@ public double[][] correlateIntersceneDebug( // only uses GPU and quad
}
/// Runtime.getRuntime().gc();
/// System.out.println("--- Free memory="+Runtime.getRuntime().freeMemory()+" (of "+Runtime.getRuntime().totalMemory()+")");
// Normalize accumulated corelations
// Normalize accumulated cor
r
elations
if
(
ref_scene
.
hasGPU
())
{
accumulateCorrelationsAcOnly
(
num_acc
,
// final int [][][] num_acc, // number of accumulated tiles [tilesY][tilesX][pair]
...
...
src/main/java/com/elphel/imagej/tileprocessor/TwoQuadCLT.java
View file @
9fb7ab22
...
...
@@ -9104,6 +9104,9 @@ if (debugLevel > -100) return true; // temporarily !
colorProcParameters
,
// ColorProcParameters colorProcParameters,
clt_parameters
.
inp
.
noise_debug_level
// clt_parameters.ofp.debug_level_optical - 1); // 1); // -1); // int debug_level);
);
if
(
ref_step
==
0
)
{
break
;
}
}
System
.
out
.
println
(
"End of interIntraExportML()"
);
}
...
...
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