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
c14405c9
Commit
c14405c9
authored
Dec 30, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on new LMA correlation
parent
2fab35c1
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1847 additions
and
574 deletions
+1847
-574
Corr2dLMA.java
src/main/java/com/elphel/imagej/tileprocessor/Corr2dLMA.java
+1119
-0
Correlation2d.java
...n/java/com/elphel/imagej/tileprocessor/Correlation2d.java
+252
-98
Correlations2dLMA.java
...va/com/elphel/imagej/tileprocessor/Correlations2dLMA.java
+33
-33
GeometryCorrection.java
...a/com/elphel/imagej/tileprocessor/GeometryCorrection.java
+126
-126
ImageDtt.java
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
+145
-145
QuadCLT.java
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
+172
-172
No files found.
src/main/java/com/elphel/imagej/tileprocessor/Corr2dLMA.java
0 → 100644
View file @
c14405c9
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/Correlation2d.java
View file @
c14405c9
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/Correlations2dLMA.java
View file @
c14405c9
package
com
.
elphel
.
imagej
.
tileprocessor
;
package
com
.
elphel
.
imagej
.
tileprocessor
;
/**
/**
**
**
** Correlation2dLMA - Fit multi - baseline corre
al
tion pairs to the model
** Correlation2dLMA - Fit multi - baseline corre
la
tion pairs to the model
**
**
** Copyright (C) 2018 Elphel, Inc.
** Copyright (C) 2018 Elphel, Inc.
**
**
...
@@ -84,7 +84,7 @@ public class Correlations2dLMA {
...
@@ -84,7 +84,7 @@ public class Correlations2dLMA {
double
[]
poly_coeff
=
null
;
// 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
double
[]
poly_coeff
=
null
;
// 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
double
[]
poly_xyvwh
=
null
;
// result of 2-d polynomial approximation instead of the LMA - used for lazy eye correction
double
[]
poly_xyvwh
=
null
;
// result of 2-d polynomial approximation instead of the LMA - used for lazy eye correction
public
class
NumDiag
{
public
class
NumDiag
{
// USED in lwir
int
num
;
int
num
;
boolean
diag
;
boolean
diag
;
public
NumDiag
(
int
num
,
boolean
diag
)
{
public
NumDiag
(
int
num
,
boolean
diag
)
{
...
@@ -93,7 +93,7 @@ public class Correlations2dLMA {
...
@@ -93,7 +93,7 @@ public class Correlations2dLMA {
}
}
}
}
public
class
Sample
{
public
class
Sample
{
// USED in lwir
double
x
;
// x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double
x
;
// x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double
y
;
// y coordinate (0 - disparity axis)
double
y
;
// y coordinate (0 - disparity axis)
double
v
;
// correlation value at that point
double
v
;
// correlation value at that point
...
@@ -117,7 +117,7 @@ public class Correlations2dLMA {
...
@@ -117,7 +117,7 @@ public class Correlations2dLMA {
}
}
}
}
public
void
printParams
()
{
public
void
printParams
()
{
// not used in lwir
for
(
int
np
=
0
;
np
<
all_pars
.
length
;
np
++)
{
for
(
int
np
=
0
;
np
<
all_pars
.
length
;
np
++)
{
System
.
out
.
println
(
String
.
format
(
"%2d%1s %22s %f"
,
System
.
out
.
println
(
String
.
format
(
"%2d%1s %22s %f"
,
np
,
np
,
...
@@ -127,7 +127,7 @@ public class Correlations2dLMA {
...
@@ -127,7 +127,7 @@ public class Correlations2dLMA {
}
}
}
}
public
void
printInputDataFx
(
boolean
show_fx
){
public
void
printInputDataFx
(
boolean
show_fx
){
// not used in lwir
if
(
show_fx
)
{
if
(
show_fx
)
{
Sample
s
=
null
;
Sample
s
=
null
;
double
[]
fx
=
getPolyFx
();
double
[]
fx
=
getPolyFx
();
...
@@ -151,18 +151,18 @@ public class Correlations2dLMA {
...
@@ -151,18 +151,18 @@ public class Correlations2dLMA {
}
}
}
}
public
double
[]
getRMS
()
{
public
double
[]
getRMS
()
{
// USED in lwir
return
last_rms
;
return
last_rms
;
}
}
public
double
[]
getGoodOrBadRMS
()
{
public
double
[]
getGoodOrBadRMS
()
{
// not used in lwir
return
good_or_bad_rms
;
return
good_or_bad_rms
;
}
}
public
double
[]
getAllPars
()
{
public
double
[]
getAllPars
()
{
// not used in lwir
return
all_pars
;
return
all_pars
;
}
}
public
double
[]
getDisparityStrength
()
{
public
double
[]
getDisparityStrength
()
{
// USED in lwir
if
(
group_weights
==
null
)
return
null
;
if
(
group_weights
==
null
)
return
null
;
double
disparity
=
-
all_pars
[
X0_INDEX
];
double
disparity
=
-
all_pars
[
X0_INDEX
];
double
sum_amp
=
0.0
;
double
sum_amp
=
0.0
;
...
@@ -176,7 +176,7 @@ public class Correlations2dLMA {
...
@@ -176,7 +176,7 @@ public class Correlations2dLMA {
double
[]
ds
=
{
disparity
,
sum_amp
};
double
[]
ds
=
{
disparity
,
sum_amp
};
return
ds
;
return
ds
;
}
}
public
double
[]
getDisparityStrengthWidth
()
{
public
double
[]
getDisparityStrengthWidth
()
{
// USED in lwir
double
[]
ds
=
getDisparityStrength
();
double
[]
ds
=
getDisparityStrength
();
if
(
ds
==
null
)
return
null
;
if
(
ds
==
null
)
return
null
;
double
[]
dsw
=
{
ds
[
0
],
ds
[
1
],
all_pars
[
WM_INDEX
],
all_pars
[
WXY_INDEX
]};
// asymmetry
double
[]
dsw
=
{
ds
[
0
],
ds
[
1
],
all_pars
[
WM_INDEX
],
all_pars
[
WXY_INDEX
]};
// asymmetry
...
@@ -184,16 +184,16 @@ public class Correlations2dLMA {
...
@@ -184,16 +184,16 @@ public class Correlations2dLMA {
}
}
public
Correlations2dLMA
(
public
Correlations2dLMA
(
// USED in lwir
double
[]
scales
// null - use default table
double
[]
scales
// null - use default table
)
{
)
{
if
(
scales
!=
null
)
this
.
scales
=
scales
.
clone
();
if
(
scales
!=
null
)
this
.
scales
=
scales
.
clone
();
}
}
public
void
setDiag
(
boolean
diag_in
)
{
public
void
setDiag
(
boolean
diag_in
)
{
// USED in lwir
this
.
input_diag
=
diag_in
;
this
.
input_diag
=
diag_in
;
}
}
public
void
addSample
(
public
void
addSample
(
// USED in lwir
double
x
,
// x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double
x
,
// x coordinate on the common scale (corresponding to the largest baseline), along the disparity axis
double
y
,
// y coordinate (0 - disparity axis)
double
y
,
// y coordinate (0 - disparity axis)
double
v
,
// correlation value at that point
double
v
,
// correlation value at that point
...
@@ -209,7 +209,7 @@ public class Correlations2dLMA {
...
@@ -209,7 +209,7 @@ public class Correlations2dLMA {
//NumDiag
//NumDiag
// TODO: add auto x0, half-width?
// TODO: add auto x0, half-width?
// should be called ater all samples are entered (to list groups)
// should be called ater all samples are entered (to list groups)
public
void
initVector
(
public
void
initVector
(
// USED in lwir
boolean
adjust_wm
,
boolean
adjust_wm
,
boolean
adjust_wy
,
boolean
adjust_wy
,
boolean
adjust_wxy
,
boolean
adjust_wxy
,
...
@@ -242,7 +242,7 @@ public class Correlations2dLMA {
...
@@ -242,7 +242,7 @@ public class Correlations2dLMA {
toVector
();
toVector
();
}
}
public
void
setWeightsValues
(
public
void
setWeightsValues
(
// USED in lwir
double
half_width
,
// expected width
double
half_width
,
// expected width
double
cost_wm
,
// cost of non-zero this.all_pars[WYD_INDEX]
double
cost_wm
,
// cost of non-zero this.all_pars[WYD_INDEX]
double
cost_wxy
)
{
// cost of non-zero this.all_pars[WXY_INDEX]
double
cost_wxy
)
{
// cost of non-zero this.all_pars[WXY_INDEX]
...
@@ -260,7 +260,7 @@ public class Correlations2dLMA {
...
@@ -260,7 +260,7 @@ public class Correlations2dLMA {
weights
[
i
]
=
s
.
w
;
weights
[
i
]
=
s
.
w
;
values
[
i
]
=
s
.
v
;
values
[
i
]
=
s
.
v
;
group_weights
[
groups
.
get
(
s
.
gi
).
num
]
+=
s
.
w
;
group_weights
[
groups
.
get
(
s
.
gi
).
num
]
+=
s
.
w
;
if
(
Double
.
isNaN
(
values
[
i
])
||
Double
.
isNaN
(
weights
[
i
]))
{
if
(
Double
.
isNaN
(
values
[
i
])
||
Double
.
isNaN
(
weights
[
i
]))
{
// not used in lwir
weights
[
i
]
=
0.0
;
weights
[
i
]
=
0.0
;
values
[
i
]
=
0.0
;
values
[
i
]
=
0.0
;
}
}
...
@@ -277,7 +277,7 @@ public class Correlations2dLMA {
...
@@ -277,7 +277,7 @@ public class Correlations2dLMA {
pure_weight
*=
sw
;
pure_weight
*=
sw
;
}
}
public
void
toVector
()
{
public
void
toVector
()
{
// USED in lwir
int
np
=
0
;
int
np
=
0
;
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
np
++;
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
np
++;
vector
=
new
double
[
np
];
vector
=
new
double
[
np
];
...
@@ -285,12 +285,12 @@ public class Correlations2dLMA {
...
@@ -285,12 +285,12 @@ public class Correlations2dLMA {
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
vector
[
np
++]
=
all_pars
[
i
];
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
vector
[
np
++]
=
all_pars
[
i
];
}
}
public
void
updateFromVector
()
{
public
void
updateFromVector
()
{
// USED in lwir
int
np
=
0
;
int
np
=
0
;
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
all_pars
[
i
]
=
vector
[
np
++];
for
(
int
i
=
0
;
i
<
par_mask
.
length
;
i
++)
if
(
par_mask
[
i
])
all_pars
[
i
]
=
vector
[
np
++];
}
}
public
double
[]
fromVector
(
double
[]
vector
)
{
// mix fixed and variable parameters
public
double
[]
fromVector
(
double
[]
vector
)
{
// mix fixed and variable parameters
// USED in lwir
if
(
all_pars
==
null
)
return
null
;
if
(
all_pars
==
null
)
return
null
;
double
[]
ap
=
all_pars
.
clone
();
double
[]
ap
=
all_pars
.
clone
();
int
np
=
0
;
int
np
=
0
;
...
@@ -298,7 +298,7 @@ public class Correlations2dLMA {
...
@@ -298,7 +298,7 @@ public class Correlations2dLMA {
return
ap
;
return
ap
;
}
}
public
void
debugJt
(
public
void
debugJt
(
// not used in lwir
double
delta
,
double
delta
,
double
[]
vector
)
{
double
[]
vector
)
{
int
num_points
=
this
.
values
.
length
;
int
num_points
=
this
.
values
.
length
;
...
@@ -338,7 +338,7 @@ public class Correlations2dLMA {
...
@@ -338,7 +338,7 @@ public class Correlations2dLMA {
}
}
public
double
[]
getFxJt
(
public
double
[]
getFxJt
(
// not used in lwir
double
delta
,
// for testing derivatives: calculates as delta-F/delta_x
double
delta
,
// for testing derivatives: calculates as delta-F/delta_x
double
[]
vector
,
double
[]
vector
,
double
[][]
jt
)
{
// should be either [vector.length][samples.size()] or null - then only fx is calculated
double
[][]
jt
)
{
// should be either [vector.length][samples.size()] or null - then only fx is calculated
...
@@ -361,11 +361,11 @@ public class Correlations2dLMA {
...
@@ -361,11 +361,11 @@ public class Correlations2dLMA {
public
double
[]
getFx
()
{
public
double
[]
getFx
()
{
// not used in lwir
return
getFxJt
(
this
.
vector
,
null
);
return
getFxJt
(
this
.
vector
,
null
);
}
}
public
double
[]
getFxJt
(
public
double
[]
getFxJt
(
// USED in lwir
double
[]
vector
,
double
[]
vector
,
double
[][]
jt
)
{
// should be either [vector.length][samples.size()] or null - then only fx is calculated
double
[][]
jt
)
{
// should be either [vector.length][samples.size()] or null - then only fx is calculated
if
(
vector
==
null
)
return
null
;
if
(
vector
==
null
)
return
null
;
...
@@ -415,7 +415,7 @@ public class Correlations2dLMA {
...
@@ -415,7 +415,7 @@ public class Correlations2dLMA {
return
fx
;
return
fx
;
}
}
public
double
[][]
getWJtJlambda
(
public
double
[][]
getWJtJlambda
(
// USED in lwir
double
lambda
,
double
lambda
,
double
[][]
jt
){
double
[][]
jt
){
int
num_pars
=
jt
.
length
;
int
num_pars
=
jt
.
length
;
...
@@ -439,7 +439,7 @@ public class Correlations2dLMA {
...
@@ -439,7 +439,7 @@ public class Correlations2dLMA {
}
}
// returns {rms, rms_pure}
// returns {rms, rms_pure}
public
double
[]
getWYmFxRms
(
public
double
[]
getWYmFxRms
(
// USED in lwir
double
[]
fx
)
{
// will be replaced with y-fx
double
[]
fx
)
{
// will be replaced with y-fx
int
num_samples
=
samples
.
size
();
int
num_samples
=
samples
.
size
();
int
num_points
=
fx
.
length
;
// includes 2 extra for regularization
int
num_points
=
fx
.
length
;
// includes 2 extra for regularization
...
@@ -460,7 +460,7 @@ public class Correlations2dLMA {
...
@@ -460,7 +460,7 @@ public class Correlations2dLMA {
return
rslt
;
return
rslt
;
}
}
public
double
[]
getJtWdiff
(
public
double
[]
getJtWdiff
(
// not used in lwir
double
[]
wdiff
,
double
[]
wdiff
,
double
[][]
jt
){
double
[][]
jt
){
int
num_pars
=
jt
.
length
;
int
num_pars
=
jt
.
length
;
...
@@ -474,7 +474,7 @@ public class Correlations2dLMA {
...
@@ -474,7 +474,7 @@ public class Correlations2dLMA {
return
wjtymfx
;
return
wjtymfx
;
}
}
public
boolean
runLma
(
public
boolean
runLma
(
// USED in lwir
double
lambda
,
// 0.1
double
lambda
,
// 0.1
double
lambda_scale_good
,
// 0.5
double
lambda_scale_good
,
// 0.5
double
lambda_scale_bad
,
// 8.0
double
lambda_scale_bad
,
// 8.0
...
@@ -502,7 +502,7 @@ public class Correlations2dLMA {
...
@@ -502,7 +502,7 @@ public class Correlations2dLMA {
}
else
{
}
else
{
lambda
*=
lambda_scale_bad
;
lambda
*=
lambda_scale_bad
;
if
(
lambda
>
lambda_max
)
{
if
(
lambda
>
lambda_max
)
{
break
;
break
;
// not used in lwir
}
}
}
}
}
}
...
@@ -530,7 +530,7 @@ public class Correlations2dLMA {
...
@@ -530,7 +530,7 @@ public class Correlations2dLMA {
// returns {success, done}
// returns {success, done}
public
boolean
[]
lmaStep
(
public
boolean
[]
lmaStep
(
// USED in lwir
double
lambda
,
double
lambda
,
double
rms_diff
,
double
rms_diff
,
int
debug_level
)
{
int
debug_level
)
{
...
@@ -640,7 +640,7 @@ public class Correlations2dLMA {
...
@@ -640,7 +640,7 @@ public class Correlations2dLMA {
}
}
// modify to reuse Samples and apply polynomial approximation to resolve x0,y0 and strength?
// modify to reuse Samples and apply polynomial approximation to resolve x0,y0 and strength?
public
double
[]
getMaxXYPoly
(
// get interpolated maximum coordinates using 2-nd degree polynomial
public
double
[]
getMaxXYPoly
(
// get interpolated maximum coordinates using 2-nd degree polynomial
// not used in lwir
/// double outside, // how much solution may be outside of the samples
/// double outside, // how much solution may be outside of the samples
boolean
debug
boolean
debug
)
{
)
{
...
@@ -703,11 +703,11 @@ public class Correlations2dLMA {
...
@@ -703,11 +703,11 @@ public class Correlations2dLMA {
this
.
poly_xyvwh
=
xyvwh
;
this
.
poly_xyvwh
=
xyvwh
;
return
xyvwh
;
// rslt;
return
xyvwh
;
// rslt;
}
}
public
double
[]
getPoly
()
{
public
double
[]
getPoly
()
{
// not used in lwir
return
poly_xyvwh
;
return
poly_xyvwh
;
}
}
public
double
[]
getPolyFx
()
{
return
getPolyFx
(
this
.
poly_coeff
);}
public
double
[]
getPolyFx
()
{
return
getPolyFx
(
this
.
poly_coeff
);}
// not used in lwir
public
double
[]
getPolyFx
(
public
double
[]
getPolyFx
(
// not used in lwir
double
[]
coeff
)
{
// 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
double
[]
coeff
)
{
// 6 elements - Xc, Yx, f(x,y), A, B, C (from A*x^2 + B*y^2 +C*x*y+...)
if
(
coeff
==
null
)
{
if
(
coeff
==
null
)
{
return
null
;
return
null
;
...
...
src/main/java/com/elphel/imagej/tileprocessor/GeometryCorrection.java
View file @
c14405c9
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/ImageDtt.java
View file @
c14405c9
This diff is collapsed.
Click to expand it.
src/main/java/com/elphel/imagej/tileprocessor/QuadCLT.java
View file @
c14405c9
This diff is collapsed.
Click to expand it.
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