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
8d033226
Commit
8d033226
authored
Feb 16, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optional common gains for all pairs
parent
c3ee5b3f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
46 deletions
+188
-46
Corr2dLMA.java
src/main/java/com/elphel/imagej/tileprocessor/Corr2dLMA.java
+131
-22
Correlation2d.java
...n/java/com/elphel/imagej/tileprocessor/Correlation2d.java
+29
-21
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+2
-2
ImageDttParameters.java
...a/com/elphel/imagej/tileprocessor/ImageDttParameters.java
+26
-1
No files found.
src/main/java/com/elphel/imagej/tileprocessor/Corr2dLMA.java
View file @
8d033226
...
...
@@ -110,7 +110,7 @@ public class Corr2dLMA {
private
double
[]
last_rms
=
null
;
// {rms, rms_pure}, matching this.vector
private
double
[]
good_or_bad_rms
=
null
;
// just for diagnostics, to read last (failed) rms
private
double
[]
initial_rms
=
null
;
// {rms, rms_pure}, first-calcu
al
ted rms
private
double
[]
initial_rms
=
null
;
// {rms, rms_pure}, first-calcu
la
ted rms
private
double
[]
last_ymfx
=
null
;
private
double
[][]
last_jt
=
null
;
...
...
@@ -121,7 +121,8 @@ public class Corr2dLMA {
private
int
[]
used_cams_rmap
;
// variable-length list of used cameras numbers
private
int
[][]
used_pairs_map
;
// [tile][pair] -1 for unused pairs, >=0 for used ones
private
boolean
[]
last_common_scale
=
null
;
//When switching from common to individual the
// scale[0] is cloned, reverse - averaged to [0]
private
boolean
[]
used_tiles
;
private
final
int
transform_size
;
...
...
@@ -882,6 +883,7 @@ public class Corr2dLMA {
* Set/modify parameters mask. May be called after preparePars () or after updateFromVector() if LMA was ran
* @param adjust_disparities null to adjust all (1 or 2) disparities or a boolean array of per maximum
* individual disparity adjusts
* @param common_scales per-maximum, if true - common scale for all pairs. Null - all individual (old mode)
* @param adjust_width adjust correlation maximum width
* @param adjust_scales adjust per-pair amplitude
* @param adjust_ellipse adjust per-pair maximum shape as an ellipse
...
...
@@ -891,8 +893,9 @@ public class Corr2dLMA {
* @param cost_lazyeye_odtho cost of lazy eye orthogonal to disparity
* @return OK/failure
*/
public
boolean
setParMask
(
// USED in lwir
public
boolean
setParMask
(
boolean
[]
adjust_disparities
,
// null - adjust all, otherwise - per maximum
boolean
[]
common_scale
,
// per-maximum, if true - common scale for all pairs
boolean
adjust_width
,
// adjust width of the maximum - lma_adjust_wm
boolean
adjust_scales
,
// adjust 2D correlation scales - lma_adjust_ag
boolean
adjust_ellipse
,
// allow non-circular correlation maximums lma_adjust_wy
...
...
@@ -905,17 +908,56 @@ public class Corr2dLMA {
adjust_disparities
=
new
boolean
[
numMax
];
Arrays
.
fill
(
adjust_disparities
,
true
);
}
if
(
common_scale
==
null
)
{
common_scale
=
new
boolean
[
numMax
];
Arrays
.
fill
(
common_scale
,
false
);
}
if
(
last_common_scale
==
null
)
{
// first time - same as it was {false, ...,false}
last_common_scale
=
new
boolean
[
numMax
];
Arrays
.
fill
(
last_common_scale
,
false
);
}
total_tiles
=
0
;
// now
// per-tile parameters
for
(
int
nTile
=
0
;
nTile
<
numTiles
;
nTile
++)
if
(
used_tiles
[
nTile
])
{
for
(
int
nmax
=
0
;
nmax
<
numMax
;
nmax
++)
{
int
offs
=
(
nTile
*
numMax
+
nmax
)
*
tile_params
;
// Do scales need to be changed??
if
(
common_scale
[
nmax
]
!=
last_common_scale
[
nmax
])
{
double
cs
=
0.0
;
// Do scales need to be averaged into [0]?
if
(
common_scale
[
nmax
])
{
int
num_used_pairs
=
0
;
for
(
int
np
=
0
;
np
<
num_pairs
;
np
++)
if
(
used_pairs
[
nTile
][
np
])
{
//this.all_pars[G0_INDEX + i + offs] = Double.NaN; // will be assigned later for used - should be for all !
cs
+=
this
.
all_pars
[
G0_INDEX
+
np
+
offs
];
num_used_pairs
++;
}
if
(
num_used_pairs
>
0
)
{
cs
/=
num_used_pairs
;
}
}
else
{
// need to be copied
cs
=
this
.
all_pars
[
G0_INDEX
+
0
+
offs
];
}
for
(
int
np
=
0
;
np
<
num_pairs
;
np
++)
{
// if (used_pairs[nTile][np]) {
this
.
all_pars
[
G0_INDEX
+
np
+
offs
]
=
cs
;
}
last_common_scale
[
nmax
]
=
common_scale
[
nmax
];
}
this
.
par_mask
[
DISP_INDEX
+
offs
]
=
adjust_disparities
[
nmax
];
// true;
this
.
par_mask
[
A_INDEX
+
offs
]
=
adjust_width
;
this
.
par_mask
[
B_INDEX
+
offs
]
=
adjust_ellipse
;
this
.
par_mask
[
CMA_INDEX
+
offs
]
=
adjust_ellipse
;
for
(
int
i
=
0
;
i
<
num_pairs
;
i
++)
{
this
.
par_mask
[
G0_INDEX
+
i
+
offs
]
=
used_pairs
[
nTile
][
i
]
&
adjust_scales
;
if
(
last_common_scale
[
nmax
])
{
this
.
par_mask
[
G0_INDEX
+
0
+
offs
]
=
adjust_scales
;
for
(
int
np
=
1
;
np
<
num_pairs
;
np
++)
{
this
.
par_mask
[
G0_INDEX
+
np
+
offs
]
=
false
;
}
}
else
{
for
(
int
np
=
0
;
np
<
num_pairs
;
np
++)
{
this
.
par_mask
[
G0_INDEX
+
np
+
offs
]
=
used_pairs
[
nTile
][
np
]
&
adjust_scales
;
}
}
}
total_tiles
++;
...
...
@@ -1201,7 +1243,9 @@ public class Corr2dLMA {
double
B
=
BT
[
nmax
][
s
.
tile
];
double
C
=
CT
[
nmax
][
s
.
tile
];
double
Gp
=
av
[
G0_INDEX
+
pair
+
offs
];
int
cpair
=
last_common_scale
[
nmax
]?
0
:
pair
;
double
Gp
=
av
[
G0_INDEX
+
cpair
+
offs
];
// either common or individual;
double
Wp
=
corr_wnd
[
s
.
ix
][
s
.
iy
];
double
WGp
=
Wp
*
Gp
;
// double xmxp = s.ix - xp_yp[s.tile][s.fcam][s.scam][0];
...
...
@@ -1234,11 +1278,19 @@ public class Corr2dLMA {
if
(
par_map
[
CMA_INDEX
+
offs
]
>=
0
)
{
jt
[
par_map
[
CMA_INDEX
+
offs
]][
ns
]
=
-
WGp
*
ymyp2
;
}
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
d
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
if
(
last_common_scale
[
nmax
])
{
if
(
par_map
[
G0_INDEX
+
0
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
0
+
offs
]][
ns
]
=
d
;
// (par_mask[G0_INDEX + pair])? d;
}
}
else
{
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
d
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
}
}
}
if
(
lazy_eye
)
{
if
(
nmax
==
0
)
{
// only zero during first pass, then accumulate only
for
(
int
f
=
0
;
f
<
num_cams
;
f
++)
{
// -1 for the last_cam and pre_last_cam
...
...
@@ -1382,7 +1434,9 @@ public class Corr2dLMA {
double
B
=
BT
[
nmax
][
s
.
tile
];
double
C
=
CT
[
nmax
][
s
.
tile
];
double
Gp
=
av
[
G0_INDEX
+
pair
+
offs
];
int
cpair
=
last_common_scale
[
nmax
]?
0
:
pair
;
double
Gp
=
av
[
G0_INDEX
+
cpair
+
offs
];
// either common or individual;
double
Wp
=
corr_wnd
[
s
.
ix
][
s
.
iy
];
double
WGp
=
Wp
*
Gp
;
// double xmxp = s.ix - xp_yp[s.tile][s.fcam][s.scam][0];
...
...
@@ -1421,12 +1475,27 @@ public class Corr2dLMA {
if
(
par_map
[
CMA_INDEX
+
offs
]
>=
0
)
{
jt
[
par_map
[
CMA_INDEX
+
offs
]][
ns
]
=
-
WGp
*
ymyp2
*
lim_negative
;
}
// for (int p = 0; p < npairs[s.tile]; p++) { // par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
/*
for (int p = 0; p < num_pairs; p++) { // par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if (par_map[G0_INDEX + p + offs] >= 0) {
jt[par_map[G0_INDEX + p + offs]][ns] = (p== pair)? d : 0.0; // (par_mask[G0_INDEX + pair])? d;
}
}
*/
if
(
last_common_scale
[
nmax
])
{
if
(
par_map
[
G0_INDEX
+
0
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
0
+
offs
]][
ns
]
=
d
;
// (par_mask[G0_INDEX + pair])? d;
}
}
else
{
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
d
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
}
}
}
if
(
lazy_eye
)
{
if
(
nmax
==
0
)
{
// only zero during first pass, then accumulate only // ****
for
(
int
f
=
0
;
f
<
num_cams
;
f
++)
{
// -1 for the last_cam and pre_last_cam
...
...
@@ -1568,7 +1637,8 @@ public class Corr2dLMA {
double
A
=
AT
[
nmax
][
s
.
tile
];
double
B
=
BT
[
nmax
][
s
.
tile
];
double
C
=
CT
[
nmax
][
s
.
tile
];
double
Gp
=
av
[
G0_INDEX
+
pair
+
offs
];
int
cpair
=
last_common_scale
[
nmax
]?
0
:
pair
;
double
Gp
=
av
[
G0_INDEX
+
cpair
+
offs
];
// either common or individual;
double
Wp
=
corr_wnd
[
s
.
ix
][
s
.
iy
];
double
WGp
=
Wp
*
Gp
;
double
xmxp
=
s
.
ix
-
xp_yp
[
nmax
][
s
.
tile
][
fs
[
0
]][
fs
[
1
]][
0
];
// TODO - change format of xp_yp
...
...
@@ -1608,11 +1678,19 @@ public class Corr2dLMA {
if
(
par_map
[
CMA_INDEX
+
offs
]
>=
0
)
{
jt
[
par_map
[
CMA_INDEX
+
offs
]][
ns
]
=
-
WGp
*
ymyp2
*
lim_negative_2d
;
}
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
(
d
*
d
)
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
if
(
last_common_scale
[
nmax
])
{
if
(
par_map
[
G0_INDEX
+
0
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
0
+
offs
]][
ns
]
=
d
*
d
;
// (par_mask[G0_INDEX + pair])? d;
}
}
else
{
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
(
d
*
d
)
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
}
}
}
if
(
lazy_eye
)
{
if
(
nmax
==
0
)
{
// only zero during first pass, then accumulate only // ****
for
(
int
f
=
0
;
f
<
num_cams
;
f
++)
{
// -1 for the last_cam and pre_last_cam
...
...
@@ -1751,7 +1829,8 @@ public class Corr2dLMA {
double
A
=
AT
[
nmax
][
s
.
tile
];
double
B
=
BT
[
nmax
][
s
.
tile
];
double
C
=
CT
[
nmax
][
s
.
tile
];
double
Gp
=
av
[
G0_INDEX
+
pair
+
offs
];
int
cpair
=
last_common_scale
[
nmax
]?
0
:
pair
;
double
Gp
=
av
[
G0_INDEX
+
cpair
+
offs
];
// either common or individual;
double
Wp
=
corr_wnd
[
s
.
ix
][
s
.
iy
];
double
WGp
=
Wp
*
Gp
;
double
xmxp
=
s
.
ix
-
xp_yp
[
nmax
][
s
.
tile
][
fs
[
0
]][
fs
[
1
]][
0
];
...
...
@@ -1793,10 +1872,23 @@ public class Corr2dLMA {
if
(
par_map
[
A_INDEX
+
offs
]
>=
0
)
jt
[
par_map
[
A_INDEX
+
offs
]][
ns
]
=
-
WGpexp
*(
xmxp2
+
ymyp2
);
if
(
par_map
[
B_INDEX
+
offs
]
>=
0
)
jt
[
par_map
[
B_INDEX
+
offs
]][
ns
]
=
-
WGpexp
*
2
*
xmxp_ymyp
;
if
(
par_map
[
CMA_INDEX
+
offs
]
>=
0
)
jt
[
par_map
[
CMA_INDEX
+
offs
]][
ns
]
=
-
WGpexp
*
ymyp2
;
/*
for (int p = 0; p < npairs[s.tile]; p++) { // par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if (par_map[G0_INDEX + p + offs] >= 0) jt[par_map[G0_INDEX + p + offs]][ns] = (p== pair)? comm : 0.0; // (par_mask[G0_INDEX + pair])? d;
}
*/
if
(
last_common_scale
[
nmax
])
{
if
(
par_map
[
G0_INDEX
+
0
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
0
+
offs
]][
ns
]
=
comm
;
// (par_mask[G0_INDEX + pair])? d;
}
}
else
{
for
(
int
p
=
0
;
p
<
num_pairs
;
p
++)
{
// par_mask[G0_INDEX + p] as all pairs either used, or not - then npairs == 0
if
(
par_map
[
G0_INDEX
+
p
+
offs
]
>=
0
)
{
jt
[
par_map
[
G0_INDEX
+
p
+
offs
]][
ns
]
=
(
p
==
pair
)?
comm
:
0.0
;
// (par_mask[G0_INDEX + pair])? d;
}
}
}
// process ddisp (last camera not used, is equal to minus sum of others to make a sum == 0)
if
(
lazy_eye
)
{
if
(
nmax
==
0
)
{
// only zero during first pass, then accumulate only
...
...
@@ -2498,6 +2590,7 @@ public class Corr2dLMA {
return
rslt
;
}
// has common threshold for scale ratios for foreground and background corr. maximums
public
double
[][]
lmaDisparityStrength
(
double
lmas_min_amp
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
double
lma_max_rel_rms
,
// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
...
...
@@ -2509,7 +2602,8 @@ public class Corr2dLMA {
double
lma_str_offset
// convert lma-generated strength to match previous ones - add to result
){
return
lmaDisparityStrengths
(
lmas_min_amp
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
lmas_min_amp
,
// double lmas_min_amp_fg, // minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
lmas_min_amp
,
// double lmas_min_amp_bg, // Same for bg correlation max (only used for multi-max)
lma_max_rel_rms
,
// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
lma_min_strength
,
// minimal composite strength (sqrt(average amp squared over absolute RMS)
lma_min_max_ac
,
// minimal of A and C coefficients maximum (measures sharpest point/line)
...
...
@@ -2518,11 +2612,12 @@ public class Corr2dLMA {
lma_str_scale
,
// convert lma-generated strength to match previous ones - scale
lma_str_offset
// convert lma-generated strength to match previous ones - add to result
)[
0
];
}
// has separate thresholds for scale ratios for foreground and background corr. maximums
public
double
[][][]
lmaDisparityStrengths
(
double
lmas_min_amp
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
double
lmas_min_amp_fg
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
double
lmas_min_amp_bg
,
// Same for bg correlation max (only used for multi-max)
double
lma_max_rel_rms
,
// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
double
lma_min_strength
,
// minimal composite strength (sqrt(average amp squared over absolute RMS)
double
lma_min_max_ac
,
// minimal of A and C coefficients maximum (measures sharpest point/line)
...
...
@@ -2545,6 +2640,20 @@ public class Corr2dLMA {
if
(
maxmin_amp
[
tile
][
1
]
<
0.0
)
{
continue
;
// inverse maximum - discard tile
}
double
lmas_min_amp
=
lmas_min_amp_fg
;
double
disparity
=
-
all_pars
[
DISP_INDEX
+
offs
];
if
(
numMax
>
1
)
{
for
(
int
nmax1
=
0
;
nmax1
<
numMax
;
nmax1
++)
if
(
nmax1
!=
nmax
){
int
offs1
=
(
tile
*
numMax
+
nmax1
)
*
tile_params
;
double
disparity1
=
-
all_pars
[
DISP_INDEX
+
offs1
];
if
(
disparity1
>
disparity
)
{
lmas_min_amp
=
lmas_min_amp_bg
;
break
;
}
}
}
if
((
maxmin_amp
[
tile
][
1
]/
maxmin_amp
[
tile
][
0
])
<
lmas_min_amp
)
{
continue
;
// inverse maximum - discard tile
}
...
...
@@ -2570,7 +2679,7 @@ public class Corr2dLMA {
}
double
strength
=
Math
.
sqrt
(
avg
/
rrms
);
double
disparity
=
-
all_pars
[
DISP_INDEX
+
offs
];
//
double disparity = -all_pars[DISP_INDEX + offs];
if
((
strength
<
lma_min_strength
)
||
Double
.
isNaN
(
disparity
))
{
continue
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/Correlation2d.java
View file @
8d033226
...
...
@@ -4410,14 +4410,7 @@ public class Correlation2d {
boolean
debug_graphic
=
imgdtt_params
.
lma_debug_graphic
&&
(
imgdtt_params
.
lma_debug_level1
>
3
)
&&
(
debug_level
>
0
)
;
debug_graphic
|=
imgdtt_params
.
lmamask_dbg
&&
(
debug_level
>
0
)
;
// TODO: Remove me
debug_graphic
|=
true
;
/*
String dbg_title = null;
if (debug_graphic) {
dbg_title = String.format("tX%d_tY%d",tileX,tileY);
}
*/
double
[][]
dbg_corr
=
debug_graphic
?
new
double
[
corrs
.
length
][]
:
null
;
DoubleGaussianBlur
gb
=
null
;
if
(
imgdtt_params
.
lma_sigma
>
0
)
gb
=
new
DoubleGaussianBlur
();
...
...
@@ -4449,50 +4442,69 @@ public class Correlation2d {
double
[][]
disp_str_all
;
double
[][][]
own_masks
;
double
[][][]
pair_offsets
;
boolean
[]
common_scale
;
// = {false,false}; // true}; {true,true}; // // TODO: implement
if
(
lma_corr_weights0
.
length
<
2
)
{
pair_offsets
=
pair_offsets0
;
lma_corr_weights
=
lma_corr_weights0
;
disp_str_all
=
disp_str_dual
;
own_masks
=
own_masks0
;
}
else
{
int
nearest_max
=
(
Math
.
abs
(
disp_str_dual
[
0
][
0
])
<
Math
.
abs
(
disp_str_dual
[
0
][
0
]))?
0
:
1
;
int
fg_max
=
(
disp_str_dual
[
0
][
0
]
>
disp_str_dual
[
0
][
0
])
?
0
:
1
;
common_scale
=
new
boolean
[]
{
imgdtt_params
.
bimax_common_fg
};
}
else
{
// only 2 max are supported
if
(
lma_corr_weights0
.
length
>
2
)
{
System
.
out
.
println
(
"corrLMA2DualMax(): Only 2 correlation maximums are currently supported, all but 2 strongest are discarded"
);
}
int
nearest_max
=
(
Math
.
abs
(
disp_str_dual
[
0
][
0
])
<
Math
.
abs
(
disp_str_dual
[
1
][
0
]))?
0
:
1
;
int
fg_max
=
(
disp_str_dual
[
0
][
0
]
>
disp_str_dual
[
1
][
0
])
?
0
:
1
;
switch
(
combine_mode
)
{
case
0
:
// keep both
pair_offsets
=
pair_offsets0
;
lma_corr_weights
=
lma_corr_weights0
;
disp_str_all
=
disp_str_dual
;
own_masks
=
own_masks0
;
common_scale
=
new
boolean
[
disp_str_dual
.
length
];
for
(
int
i
=
0
;
i
<
common_scale
.
length
;
i
++)
{
common_scale
[
i
]
=
(
i
==
fg_max
)
?
imgdtt_params
.
bimax_common_fg
:
imgdtt_params
.
bimax_common_bg
;
}
break
;
case
1
:
// keep strongest
pair_offsets
=
new
double
[][][]
{
pair_offsets0
[
0
]};
lma_corr_weights
=
new
double
[][][]
{
lma_corr_weights0
[
0
]};
disp_str_all
=
new
double
[][]
{
disp_str_dual
[
0
]};
own_masks
=
new
double
[][][]
{
own_masks0
[
0
]};
common_scale
=
new
boolean
[]
{(
0
==
fg_max
)
?
imgdtt_params
.
bimax_common_fg
:
imgdtt_params
.
bimax_common_bg
};
break
;
case
2
:
// keep nearest
pair_offsets
=
new
double
[][][]
{
pair_offsets0
[
nearest_max
]};
lma_corr_weights
=
new
double
[][][]
{
lma_corr_weights0
[
nearest_max
]};
disp_str_all
=
new
double
[][]
{
disp_str_dual
[
nearest_max
]};
own_masks
=
new
double
[][][]
{
own_masks0
[
nearest_max
]};
common_scale
=
new
boolean
[]
{(
nearest_max
==
fg_max
)
?
imgdtt_params
.
bimax_common_fg
:
imgdtt_params
.
bimax_common_bg
};
break
;
case
3
:
// keep foreground
pair_offsets
=
new
double
[][][]
{
pair_offsets0
[
fg_max
]};
lma_corr_weights
=
new
double
[][][]
{
lma_corr_weights0
[
fg_max
]};
disp_str_all
=
new
double
[][]
{
disp_str_dual
[
fg_max
]};
own_masks
=
new
double
[][][]
{
own_masks0
[
fg_max
]};
common_scale
=
new
boolean
[]
{
imgdtt_params
.
bimax_common_fg
};
break
;
case
4
:
// keep background
pair_offsets
=
new
double
[][][]
{
pair_offsets0
[
1
-
fg_max
]};
lma_corr_weights
=
new
double
[][][]
{
lma_corr_weights0
[
1
-
fg_max
]};
disp_str_all
=
new
double
[][]
{
disp_str_dual
[
1
-
fg_max
]};
own_masks
=
new
double
[][][]
{
own_masks0
[
1
-
fg_max
]};
common_scale
=
new
boolean
[]
{
imgdtt_params
.
bimax_common_bg
};
break
;
default
:
// keep both
pair_offsets
=
pair_offsets0
;
lma_corr_weights
=
lma_corr_weights0
;
disp_str_all
=
disp_str_dual
;
own_masks
=
own_masks0
;
common_scale
=
new
boolean
[
disp_str_dual
.
length
];
for
(
int
i
=
0
;
i
<
common_scale
.
length
;
i
++)
{
common_scale
[
i
]
=
(
i
==
fg_max
)
?
imgdtt_params
.
bimax_common_fg
:
imgdtt_params
.
bimax_common_bg
;
}
}
}
...
...
@@ -4505,9 +4517,6 @@ public class Correlation2d {
int
num_used_pairs
=
0
;
for
(
int
npair
=
0
;
npair
<
pair_mask
.
length
;
npair
++)
if
((
corrs
[
npair
]
!=
null
)
&&
(
pair_mask
[
npair
])){
double
[]
corr_blur
=
null
;
// if (npair == 65) {
// System.out.println("---npair == "+npair);
// }
if
(
imgdtt_params
.
cnvx_en
)
{
// || (pair_shape_masks == null)) {
corr_blur
=
corrs
[
npair
].
clone
();
if
(
corr_wnd_inv_limited
!=
null
)
{
...
...
@@ -4655,16 +4664,12 @@ public class Correlation2d {
for
(
int
i
=
0
;
i
<
disp_str_all
.
length
;
i
++)
if
(
disp_str_all
[
i
]
!=
null
){
disp_str2
[
i
][
0
]
=
disp_str_all
[
i
];
}
// double [][] disp_str2 = {disp_str_all[0]}; // temporary // will be calculated/set later
boolean
lmaSuccess
=
false
;
// int num_lma_retries = 0;
// When running LMA - first do not touch disparity?
// int lma_pass = imgdtt_params.bimax_dual_pass? 0 : 1; // pass0 - w/o disparity, pass 1 - with
boolean
[]
adjust_disparities
=
new
boolean
[
disp_str_all
.
length
];
// all false;
boolean
needprep
=
true
;
//t npass = 0;
for
(
int
npass
=
(
imgdtt_params
.
bimax_dual_pass
?
00
:
1
);
npass
<
2
;
npass
++)
{
// may break while (!lmaSuccess) {
// num_lma_retries ++; // debug
for
(
int
npass
=
(
imgdtt_params
.
bimax_dual_pass
?
0
:
1
);
npass
<
2
;
npass
++)
{
// may break while (!lmaSuccess) {
if
(
needprep
)
{
lma
.
preparePars
(
disp_str2
,
// double [][][] disp_str_all, initial value of disparity [max][tile]{disp, strength}
...
...
@@ -4679,8 +4684,10 @@ public class Correlation2d {
if
(
npass
>
0
)
{
adjust_disparities
=
null
;
}
// boolean [] common_scale = {false,false}; // true}; {true,true}; // // TODO: implement
lma
.
setParMask
(
// USED in lwir
adjust_disparities
,
// null, // boolean [] adjust_disparities, // null - adjust all, otherwise - per maximum
common_scale
,
//boolean [] common_scale, // per-maximum, if true - common scale for all pairs
imgdtt_params
.
lmas_adjust_wm
,
// boolean adjust_width, // adjust width of the maximum - lma_adjust_wm
imgdtt_params
.
lmas_adjust_ag
,
// boolean adjust_scales, // adjust 2D correlation scales - lma_adjust_ag
imgdtt_params
.
lmas_adjust_wy
,
// boolean adjust_ellipse, // allow non-circular correlation maximums lma_adjust_wy
...
...
@@ -4713,6 +4720,7 @@ public class Correlation2d {
lma
.
updateFromVector
();
double
[][][]
dispStrs
=
lma
.
lmaDisparityStrengths
(
//TODO: add parameter to filter out negative minimums ?
imgdtt_params
.
lmas_min_amp
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
imgdtt_params
.
lmas_min_amp_bg
,
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
imgdtt_params
.
lmas_max_rel_rms
,
// maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
imgdtt_params
.
lmas_min_strength
,
// minimal composite strength (sqrt(average amp squared over absolute RMS)
imgdtt_params
.
lmas_min_ac
,
// minimal of A and C coefficients maximum (measures sharpest point/line)
...
...
@@ -4721,7 +4729,7 @@ public class Correlation2d {
imgdtt_params
.
lma_str_scale
,
// convert lma-generated strength to match previous ones - scale
imgdtt_params
.
lma_str_offset
// convert lma-generated strength to match previous ones - add to result
);
for
(
int
nmax
=
0
;
nmax
<
dispStrs
.
length
;
nmax
++)
if
(
dispStrs
[
nmax
][
0
][
1
]
<=
0
)
{
for
(
int
nmax
=
0
0
;
nmax
<
dispStrs
.
length
;
nmax
++)
if
(
dispStrs
[
nmax
][
0
][
1
]
<=
0
)
{
lmaSuccess
=
false
;
break
;
}
...
...
@@ -4876,7 +4884,7 @@ public class Correlation2d {
int
tileX
,
// just for debug output
int
tileY
){
boolean
debug_graphic
=
imgdtt_params
.
lma_debug_graphic
&&
(
imgdtt_params
.
lma_debug_level1
>
3
)
&&
(
debug_level
>
0
)
;
debug_graphic
|=
imgdtt_params
.
lmamask_dbg
&&
(
debug_level
>
0
)
||
true
;
debug_graphic
|=
imgdtt_params
.
lmamask_dbg
&&
(
debug_level
>
0
)
;
//
|| true;
String
dbg_title
=
null
;
if
(
debug_graphic
)
{
dbg_title
=
String
.
format
(
"tX%d_tY%d"
,
tileX
,
tileY
);
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
8d033226
...
...
@@ -2624,14 +2624,14 @@ public class ImageDtt extends ImageDttCPU {
}
if
(
debugTile1
)
{
System
.
out
.
println
(
"clt_process_tl_correlations() maxes="
);
for
(
int
i
=
0
;
i
<
maxes
.
length
;
i
++)
{
for
(
int
i
=
0
0
;
i
<
maxes
.
length
;
i
++)
{
System
.
out
.
println
(
String
.
format
(
"maxes[%d][0]=%f (quadcam disparity pixels, not combo pixels), maxes[%d][1]=%f"
,
i
,
maxes
[
i
][
0
],
i
,
maxes
[
i
][
1
]));
}
}
if
(
debugTile1
)
{
Corr2dLMA
lma_dual
=
correlation2d
.
corrLMA2DualMax
(
// null pointer
imgdtt_params
,
// ImageDttParameters imgdtt_params,
0
,
// 3, // 0, // 1, // int combine_mode, // 0 - both, 1 - strongest, 2 - nearest to zero, 3 - FG, 4 - BG
0
0
,
// 3, // 0, // 1, // int combine_mode, // 0 - both, 1 - strongest, 2 - nearest to zero, 3 - FG, 4 - BG
// imgdtt_params.lmas_LY_single, // false, // boolean adjust_ly, // adjust Lazy Eye
corr_wnd
,
// double [][] corr_wnd, // correlation window to save on re-calculation of the window
corr_wnd_inv_limited
,
// corr_wnd_limited, // correlation window, limited not to be smaller than threshold - used for finding max/convex areas (or null)
...
...
src/main/java/com/elphel/imagej/tileprocessor/ImageDttParameters.java
View file @
8d033226
...
...
@@ -85,6 +85,9 @@ public class ImageDttParameters {
public
int
bimax_min_num_samples
=
4
;
// minimal number of samples per pair per maximum
public
int
bimax_min_num_pairs
=
8
;
// minimal number of used pairs
public
boolean
bimax_dual_pass
=
true
;
// First pass - do not adjust disparity
public
boolean
bimax_common_fg
=
true
;
// Common gains for foreground/single correlation maximum
public
boolean
bimax_common_bg
=
true
;
// Common gains for background correlation maximum
//lmamask_
public
boolean
lmamask_dbg
=
false
;
// show LMA images, exit after single BG
...
...
@@ -188,6 +191,9 @@ public class ImageDttParameters {
public
boolean
lmas_adjust_wm
=
true
;
// used in new for width
public
boolean
lmas_adjust_wy
=
true
;
// adjust non-circular
public
boolean
lmas_adjust_ag
=
true
;
// adjust gains gains
// Pre-lma poly
public
double
lmas_poly_str_scale
=
1.0
;
// scale pre-lma poly strength
public
double
lmas_poly_str_min
=
0.05
;
// ignore tiles with poly strength (scaled) below
...
...
@@ -202,7 +208,8 @@ public class ImageDttParameters {
// Filtering and strength calculation
// High ratio of amplitudes may be caused by "neighbors" correlations when the same object disappears from the tile
// for small disparities 0.5...0.7 is OK, for larger, and small objects on uniform background, may need 0.2
public
double
lmas_min_amp
=
0.25
;
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
public
double
lmas_min_amp
=
0.1
;
// minimal ratio of minimal pair correlation amplitude to maximal pair correlation amplitude
public
double
lmas_min_amp_bg
=
0.01
;
// same for background objects (all but fg)
public
double
lmas_max_rel_rms
=
0.3
;
// LWIR16: 0.5 maximal relative (to average max/min amplitude LMA RMS) // May be up to 0.3)
public
double
lmas_min_strength
=
0.7
;
// LWIR16: 0.4 minimal composite strength (sqrt(average amp squared over absolute RMS)
public
double
lmas_min_ac
=
0.02
;
// LWIR16: 0.01 minimal of a and C coefficients maximum (measures sharpest point/line)
...
...
@@ -475,6 +482,10 @@ public class ImageDttParameters {
"Do not use LMA if total number of used pairs is lower"
);
gd
.
addCheckbox
(
"Dual-pass LMA"
,
this
.
bimax_dual_pass
,
"First adjust other parameters (keeping disparities), then add disparities"
);
gd
.
addCheckbox
(
"Common gains for foreground/single correlation maximum"
,
this
.
bimax_common_fg
,
"Use common gain for all pairs for FG/single correlation (unchecked - use individual gain for each pair)"
);
gd
.
addCheckbox
(
"Common gains for background correlation maximum"
,
this
.
bimax_common_bg
,
"Use common gain for all pairs for BG correlation(s) (unchecked - use individual gain for each pair)"
);
gd
.
addMessage
(
"LMA samples filter based on estimated disparity"
);
gd
.
addCheckbox
(
"Debug LMA"
,
this
.
lmamask_dbg
,
...
...
@@ -698,6 +709,8 @@ public class ImageDttParameters {
gd
.
addMessage
(
"LMA (single) results filtering"
);
gd
.
addNumericField
(
"Minimal weakest pair to strongest pair correlation amplitude ratio"
,
this
.
lmas_min_amp
,
6
,
8
,
""
,
"Discard tile if ratio of the weakest correlation pair amplitude to that of the strongest one is lower than this"
);
gd
.
addNumericField
(
"Same for BG objects (dual max)"
,
this
.
lmas_min_amp_bg
,
6
,
8
,
""
,
"Discard tile if ratio of the weakest correlation pair amplitude to that of the strongest one is lower than this (BG objects, far maximum)"
);
gd
.
addNumericField
(
"Maximal relative RMS "
,
this
.
lmas_max_rel_rms
,
6
,
8
,
""
,
"Discard tile if ratio of RMS to average of min and max amplitude exceeds this value"
);
gd
.
addNumericField
(
"Minimal composite strength"
,
this
.
lmas_min_strength
,
6
,
8
,
""
,
...
...
@@ -892,6 +905,8 @@ public class ImageDttParameters {
this
.
bimax_min_num_samples
=
(
int
)
gd
.
getNextNumber
();
this
.
bimax_min_num_pairs
=
(
int
)
gd
.
getNextNumber
();
this
.
bimax_dual_pass
=
gd
.
getNextBoolean
();
this
.
bimax_common_fg
=
gd
.
getNextBoolean
();
this
.
bimax_common_bg
=
gd
.
getNextBoolean
();
this
.
lmamask_dbg
=
gd
.
getNextBoolean
();
this
.
lmamask_en
=
gd
.
getNextBoolean
();
...
...
@@ -1002,6 +1017,7 @@ public class ImageDttParameters {
this
.
lmas_rms_diff
=
gd
.
getNextNumber
();
this
.
lmas_num_iter
=
(
int
)
gd
.
getNextNumber
();
this
.
lmas_min_amp
=
gd
.
getNextNumber
();
this
.
lmas_min_amp_bg
=
gd
.
getNextNumber
();
this
.
lmas_max_rel_rms
=
gd
.
getNextNumber
();
this
.
lmas_min_strength
=
gd
.
getNextNumber
();
this
.
lmas_min_ac
=
gd
.
getNextNumber
();
...
...
@@ -1119,6 +1135,8 @@ public class ImageDttParameters {
properties
.
setProperty
(
prefix
+
"bimax_min_num_samples"
,
this
.
bimax_min_num_samples
+
""
);
properties
.
setProperty
(
prefix
+
"bimax_min_num_pairs"
,
this
.
bimax_min_num_pairs
+
""
);
properties
.
setProperty
(
prefix
+
"bimax_dual_pass"
,
this
.
bimax_dual_pass
+
""
);
properties
.
setProperty
(
prefix
+
"bimax_common_fg"
,
this
.
bimax_common_fg
+
""
);
properties
.
setProperty
(
prefix
+
"bimax_common_bg"
,
this
.
bimax_common_bg
+
""
);
properties
.
setProperty
(
prefix
+
"lmamask_dbg"
,
this
.
lmamask_dbg
+
""
);
properties
.
setProperty
(
prefix
+
"lmamask_en"
,
this
.
lmamask_en
+
""
);
...
...
@@ -1228,6 +1246,7 @@ public class ImageDttParameters {
properties
.
setProperty
(
prefix
+
"lmas_rms_diff"
,
this
.
lmas_rms_diff
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_num_iter"
,
this
.
lmas_num_iter
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_min_amp"
,
this
.
lmas_min_amp
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_min_amp_bg"
,
this
.
lmas_min_amp_bg
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_max_rel_rms"
,
this
.
lmas_max_rel_rms
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_min_strength"
,
this
.
lmas_min_strength
+
""
);
properties
.
setProperty
(
prefix
+
"lmas_min_ac"
,
this
.
lmas_min_ac
+
""
);
...
...
@@ -1350,6 +1369,8 @@ public class ImageDttParameters {
if
(
properties
.
getProperty
(
prefix
+
"bimax_min_num_samples"
)!=
null
)
this
.
bimax_min_num_samples
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"bimax_min_num_samples"
));
if
(
properties
.
getProperty
(
prefix
+
"bimax_min_num_pairs"
)!=
null
)
this
.
bimax_min_num_pairs
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"bimax_min_num_pairs"
));
if
(
properties
.
getProperty
(
prefix
+
"bimax_dual_pass"
)!=
null
)
this
.
bimax_dual_pass
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"bimax_dual_pass"
));
if
(
properties
.
getProperty
(
prefix
+
"bimax_common_fg"
)!=
null
)
this
.
bimax_common_fg
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"bimax_common_fg"
));
if
(
properties
.
getProperty
(
prefix
+
"bimax_common_bg"
)!=
null
)
this
.
bimax_common_bg
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"bimax_common_bg"
));
if
(
properties
.
getProperty
(
prefix
+
"lmamask_dbg"
)!=
null
)
this
.
lmamask_dbg
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"lmamask_dbg"
));
if
(
properties
.
getProperty
(
prefix
+
"lmamask_en"
)!=
null
)
this
.
lmamask_en
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"lmamask_en"
));
...
...
@@ -1466,6 +1487,7 @@ public class ImageDttParameters {
if
(
properties
.
getProperty
(
prefix
+
"lmas_rms_diff"
)!=
null
)
this
.
lmas_rms_diff
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_rms_diff"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_num_iter"
)!=
null
)
this
.
lmas_num_iter
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"lmas_num_iter"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_min_amp"
)!=
null
)
this
.
lmas_min_amp
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_min_amp"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_min_amp_bg"
)!=
null
)
this
.
lmas_min_amp_bg
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_min_amp_bg"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_max_rel_rms"
)!=
null
)
this
.
lmas_max_rel_rms
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_max_rel_rms"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_min_strength"
)!=
null
)
this
.
lmas_min_strength
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_min_strength"
));
if
(
properties
.
getProperty
(
prefix
+
"lmas_min_ac"
)!=
null
)
this
.
lmas_min_ac
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"lmas_min_ac"
));
...
...
@@ -1598,6 +1620,8 @@ public class ImageDttParameters {
idp
.
bimax_min_num_samples
=
this
.
bimax_min_num_samples
;
idp
.
bimax_min_num_pairs
=
this
.
bimax_min_num_pairs
;
idp
.
bimax_dual_pass
=
this
.
bimax_dual_pass
;
idp
.
bimax_common_fg
=
this
.
bimax_common_fg
;
idp
.
bimax_common_bg
=
this
.
bimax_common_bg
;
idp
.
lmamask_dbg
=
this
.
lmamask_dbg
;
idp
.
lmamask_en
=
this
.
lmamask_en
;
...
...
@@ -1705,6 +1729,7 @@ public class ImageDttParameters {
idp
.
lmas_rms_diff
=
this
.
lmas_rms_diff
;
idp
.
lmas_num_iter
=
this
.
lmas_num_iter
;
idp
.
lmas_min_amp
=
this
.
lmas_min_amp
;
idp
.
lmas_min_amp_bg
=
this
.
lmas_min_amp_bg
;
idp
.
lmas_max_rel_rms
=
this
.
lmas_max_rel_rms
;
idp
.
lmas_min_strength
=
this
.
lmas_min_strength
;
idp
.
lmas_min_ac
=
this
.
lmas_min_ac
;
...
...
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