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
f606663c
Commit
f606663c
authored
Feb 22, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more development
parent
67a6a946
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1791 additions
and
273 deletions
+1791
-273
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+92
-7
EyesisDCT.java
src/main/java/EyesisDCT.java
+740
-171
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+100
-0
GeometryCorrection.java
src/main/java/GeometryCorrection.java
+4
-2
ImageDtt.java
src/main/java/ImageDtt.java
+804
-82
PolynomialApproximation.java
src/main/java/PolynomialApproximation.java
+51
-11
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
f606663c
This diff is collapsed.
Click to expand it.
src/main/java/EyesisDCT.java
View file @
f606663c
This diff is collapsed.
Click to expand it.
src/main/java/Eyesis_Correction.java
View file @
f606663c
...
@@ -496,6 +496,7 @@ private Panel panel1,
...
@@ -496,6 +496,7 @@ private Panel panel1,
addButton
(
"CLT process files"
,
panelClt1
,
color_process
);
addButton
(
"CLT process files"
,
panelClt1
,
color_process
);
addButton
(
"CLT process sets"
,
panelClt1
,
color_process
);
addButton
(
"CLT process sets"
,
panelClt1
,
color_process
);
addButton
(
"CLT process quads"
,
panelClt1
,
color_process
);
addButton
(
"CLT process quads"
,
panelClt1
,
color_process
);
addButton
(
"CLT process corr"
,
panelClt1
,
color_process
);
add
(
panelClt1
);
add
(
panelClt1
);
}
}
pack
();
pack
();
...
@@ -4022,6 +4023,7 @@ private Panel panel1,
...
@@ -4022,6 +4023,7 @@ private Panel panel1,
for
(
int
chn
=
0
;
chn
<
clt_corr
.
length
;
chn
++)
{
for
(
int
chn
=
0
;
chn
<
clt_corr
.
length
;
chn
++)
{
corr_rslt
[
chn
]
=
image_dtt
.
corr_dbg
(
corr_rslt
[
chn
]
=
image_dtt
.
corr_dbg
(
corr_tiles
[
chn
],
corr_tiles
[
chn
],
CLT_PARAMETERS
.
corr_border_contrast
,
THREADS_MAX
,
THREADS_MAX
,
DEBUG_LEVEL
);
DEBUG_LEVEL
);
...
@@ -4413,6 +4415,104 @@ private Panel panel1,
...
@@ -4413,6 +4415,104 @@ private Panel panel1,
return
;
return
;
}
else
if
(
label
.
equals
(
"CLT process corr"
))
{
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
EYESIS_CORRECTIONS
.
setDebug
(
DEBUG_LEVEL
);
if
(
EYESIS_DCT
==
null
){
EYESIS_DCT
=
new
EyesisDCT
(
EYESIS_CORRECTIONS
,
CORRECTION_PARAMETERS
,
DCT_PARAMETERS
);
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Created new EyesisDCT instance, will need to read CLT kernels"
);
}
}
String
configPath
=
null
;
if
(
EYESIS_CORRECTIONS
.
correctionsParameters
.
saveSettings
)
{
configPath
=
EYESIS_CORRECTIONS
.
correctionsParameters
.
selectResultsDirectory
(
true
,
true
);
if
(
configPath
==
null
){
String
msg
=
"No results directory selected, command aborted"
;
System
.
out
.
println
(
"Warning: "
+
msg
);
IJ
.
showMessage
(
"Warning"
,
msg
);
return
;
}
configPath
+=
Prefs
.
getFileSeparator
()+
"autoconfig"
;
try
{
saveTimestampedProperties
(
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
catch
(
Exception
e
){
String
msg
=
"Failed to save configuration to "
+
configPath
+
", command aborted"
;
System
.
out
.
println
(
"Error: "
+
msg
);
IJ
.
showMessage
(
"Error"
,
msg
);
return
;
}
}
EYESIS_CORRECTIONS
.
initSensorFiles
(
DEBUG_LEVEL
);
int
numChannels
=
EYESIS_CORRECTIONS
.
getNumChannels
();
NONLIN_PARAMETERS
.
modifyNumChannels
(
numChannels
);
CHANNEL_GAINS_PARAMETERS
.
modifyNumChannels
(
numChannels
);
if
(!
EYESIS_DCT
.
CLTKernelsAvailable
()){
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Reading CLT kernels"
);
}
EYESIS_DCT
.
readCLTKernels
(
CLT_PARAMETERS
,
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
if
(
DEBUG_LEVEL
>
1
){
EYESIS_DCT
.
showCLTKernels
(
THREADS_MAX
,
UPDATE_STATUS
,
// update status info
DEBUG_LEVEL
);
}
}
if
(!
EYESIS_DCT
.
geometryCorrectionAvailable
()){
if
(
DEBUG_LEVEL
>
0
){
System
.
out
.
println
(
"Calculating geometryCorrection"
);
}
if
(!
EYESIS_DCT
.
initGeometryCorrection
(
DEBUG_LEVEL
+
2
)){
return
;
}
}
///========================================
EYESIS_DCT
.
processCLTQuadCorrs
(
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
NONLIN_PARAMETERS
,
//EyesisCorrectionParameters.NonlinParameters nonlinParameters,
COLOR_PROC_PARAMETERS
,
//EyesisCorrectionParameters.ColorProcParameters colorProcParameters,
CHANNEL_GAINS_PARAMETERS
,
//CorrectionColorProc.ColorGainsParameters channelGainParameters,
RGB_PARAMETERS
,
//EyesisCorrectionParameters.RGBParameters rgbParameters,
EQUIRECTANGULAR_PARAMETERS
,
// EyesisCorrectionParameters.EquirectangularParameters equirectangularParameters,
CONVOLVE_FFT_SIZE
,
//int convolveFFTSize, // 128 - fft size, kernel size should be size/2
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
null
,
// use as default directory if path==null
true
,
PROPERTIES
);
}
return
;
// End of buttons code
// End of buttons code
}
}
...
...
src/main/java/GeometryCorrection.java
View file @
f606663c
...
@@ -330,8 +330,10 @@ public class GeometryCorrection {
...
@@ -330,8 +330,10 @@ public class GeometryCorrection {
double
[]
a
={
this
.
distortionC
,
this
.
distortionB
,
this
.
distortionA
,
this
.
distortionA5
,
this
.
distortionA6
,
this
.
distortionA7
,
this
.
distortionA8
};
double
[]
a
={
this
.
distortionC
,
this
.
distortionB
,
this
.
distortionA
,
this
.
distortionA5
,
this
.
distortionA6
,
this
.
distortionA7
,
this
.
distortionA8
};
for
(
int
i
=
0
;
i
<
numSensors
;
i
++){
for
(
int
i
=
0
;
i
<
numSensors
;
i
++){
// non-distorted XY of the shifted location of the individual sensor
// non-distorted XY of the shifted location of the individual sensor
double
pXci
=
pXc
+
disparity
*
this
.
rXY
[
i
][
0
];
// in pixels
// double pXci = pXc + disparity * this.rXY[i][0]; // in pixels
double
pYci
=
pYc
+
disparity
*
this
.
rXY
[
i
][
1
];
// double pYci = pYc + disparity * this.rXY[i][1];
double
pXci
=
pXc
-
disparity
*
this
.
rXY
[
i
][
0
];
// in pixels
double
pYci
=
pYc
-
disparity
*
this
.
rXY
[
i
][
1
];
// calculate back to distorted
// calculate back to distorted
double
rNDi
=
Math
.
sqrt
(
pXci
*
pXci
+
pYci
*
pYci
);
// in pixels
double
rNDi
=
Math
.
sqrt
(
pXci
*
pXci
+
pYci
*
pYci
);
// in pixels
// Rdist/R=A8*R^7+A7*R^6+A6*R^5+A5*R^4+A*R^3+B*R^2+C*R+(1-A6-A7-A6-A5-A-B-C)");
// Rdist/R=A8*R^7+A7*R^6+A6*R^5+A5*R^4+A*R^3+B*R^2+C*R+(1-A6-A7-A6-A5-A-B-C)");
...
...
src/main/java/ImageDtt.java
View file @
f606663c
This diff is collapsed.
Click to expand it.
src/main/java/PolynomialApproximation.java
View file @
f606663c
...
@@ -163,11 +163,17 @@ public class PolynomialApproximation {
...
@@ -163,11 +163,17 @@ public class PolynomialApproximation {
}
}
public
double
[]
quadraticMax2d
(
double
[][][]
data
){
public
double
[]
quadraticMax2d
(
double
[][][]
data
){
return
quadraticMax2d
(
data
,
1.0
E
-
15
);
return
quadraticMax2d
(
data
,
1.0
E
-
15
);
}
}
public
double
[]
quadraticMax2d
(
double
[][][]
data
,
double
thresholdQuad
){
double
[][]
coeff
=
quadraticApproximation
(
data
,
false
);
public
double
[]
quadraticMax2d
(
double
[][][]
data
,
double
thresholdQuad
){
return
quadraticMax2d
(
data
,
thresholdQuad
,
debugLevel
);
}
public
double
[]
quadraticMax2d
(
double
[][][]
data
,
double
thresholdQuad
,
int
debugLevel
){
double
[][]
coeff
=
quadraticApproximation
(
data
,
false
,
1.0
E
-
20
,
thresholdQuad
,
debugLevel
);
if
(
coeff
==
null
)
return
null
;
if
(
coeff
==
null
)
return
null
;
if
(
coeff
[
0
].
length
<
6
)
return
null
;
if
(
coeff
[
0
].
length
<
6
)
return
null
;
double
[][]
aM
={
double
[][]
aM
={
...
@@ -203,16 +209,28 @@ public class PolynomialApproximation {
...
@@ -203,16 +209,28 @@ public class PolynomialApproximation {
* returns null if not enough data even for the linear approximation
* returns null if not enough data even for the linear approximation
*/
*/
public
double
[][]
quadraticApproximation
(
public
double
[][]
quadraticApproximation
(
double
[][][]
data
,
double
[][][]
data
,
boolean
forceLinear
// use linear approximation
boolean
forceLinear
)
// use linear approximation
{
return
quadraticApproximation
(
data
,
forceLinear
,
// use linear approximation
1.0
E
-
10
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0
E
-
15
,
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this
.
debugLevel
);
}
public
double
[][]
quadraticApproximation
(
double
[][][]
data
,
boolean
forceLinear
,
// use linear approximation
int
debugLevel
){
){
return
quadraticApproximation
(
return
quadraticApproximation
(
data
,
data
,
forceLinear
,
// use linear approximation
forceLinear
,
// use linear approximation
1.0
E
-
10
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0
E
-
10
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0
E
-
15
);
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
1.0
E
-
15
,
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
debugLevel
);
/*
/*
1.0E-12, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0E-12, // threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0E-20); // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
1.0E-20); // threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
...
@@ -222,9 +240,24 @@ public class PolynomialApproximation {
...
@@ -222,9 +240,24 @@ public class PolynomialApproximation {
double
[][][]
data
,
double
[][][]
data
,
boolean
forceLinear
,
// use linear approximation
boolean
forceLinear
,
// use linear approximation
double
thresholdLin
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
double
thresholdLin
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
double
thresholdQuad
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
double
thresholdQuad
)
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
{
return
quadraticApproximation
(
data
,
forceLinear
,
// use linear approximation
1.0
E
-
10
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail) 11.0E-10 failed where it shouldn't?
1.0
E
-
15
,
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
this
.
debugLevel
);
}
public
double
[][]
quadraticApproximation
(
double
[][][]
data
,
boolean
forceLinear
,
// use linear approximation
double
thresholdLin
,
// threshold ratio of matrix determinant to norm for linear approximation (det too low - fail)
double
thresholdQuad
,
// threshold ratio of matrix determinant to norm for quadratic approximation (det too low - fail)
int
debugLevel
){
){
if
(
this
.
debugLevel
>
3
)
System
.
out
.
println
(
"quadraticApproximation(...), debugLevel="
+
this
.
debugLevel
+
":"
);
if
(
debugLevel
>
3
)
System
.
out
.
println
(
"quadraticApproximation(...), debugLevel="
+
debugLevel
+
":"
);
/* ix, iy - the location of the point with maximal value. We'll approximate the vicinity of that maximum using a
/* ix, iy - the location of the point with maximal value. We'll approximate the vicinity of that maximum using a
* second degree polynomial:
* second degree polynomial:
Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F
Z(x,y)~=A*x^2+B*y^2+C*x*y+D*x+E*y+F
...
@@ -365,7 +398,7 @@ public class PolynomialApproximation {
...
@@ -365,7 +398,7 @@ public class PolynomialApproximation {
{
S10
,
S01
,
S00
}};
{
S10
,
S01
,
S00
}};
Matrix
M
=
new
Matrix
(
mAarrayL
);
Matrix
M
=
new
Matrix
(
mAarrayL
);
Matrix
Z
;
Matrix
Z
;
if
(
this
.
debugLevel
>
3
)
System
.
out
.
println
(
">>> n="
+
n
+
" det_lin="
+
M
.
det
()+
" norm_lin="
+
normMatix
(
mAarrayL
));
if
(
debugLevel
>
3
)
System
.
out
.
println
(
">>> n="
+
n
+
" det_lin="
+
M
.
det
()+
" norm_lin="
+
normMatix
(
mAarrayL
));
double
nmL
=
normMatix
(
mAarrayL
);
double
nmL
=
normMatix
(
mAarrayL
);
if
((
nmL
==
0.0
)
||
(
Math
.
abs
(
M
.
det
())/
nmL
<
thresholdLin
)){
if
((
nmL
==
0.0
)
||
(
Math
.
abs
(
M
.
det
())/
nmL
<
thresholdLin
)){
// return average value for each channel
// return average value for each channel
...
@@ -398,10 +431,17 @@ public class PolynomialApproximation {
...
@@ -398,10 +431,17 @@ public class PolynomialApproximation {
{
S21
,
S03
,
S12
,
S11
,
S02
,
S01
},
{
S21
,
S03
,
S12
,
S11
,
S02
,
S01
},
{
S20
,
S02
,
S11
,
S10
,
S01
,
S00
}};
{
S20
,
S02
,
S11
,
S10
,
S01
,
S00
}};
M
=
new
Matrix
(
mAarrayQ
);
M
=
new
Matrix
(
mAarrayQ
);
if
(
debugLevel
>
3
)
System
.
out
.
println
(
" n="
+
n
+
" det_quad="
+
M
.
det
()+
" norm_quad="
+
normMatix
(
mAarrayQ
)+
" data.length="
+
data
.
length
);
if
(
debugLevel
>
3
)
{
System
.
out
.
println
(
" n="
+
n
+
" det_quad="
+
M
.
det
()+
" norm_quad="
+
normMatix
(
mAarrayQ
)+
" data.length="
+
data
.
length
);
M
.
print
(
10
,
5
);
}
double
nmQ
=
normMatix
(
mAarrayQ
);
double
nmQ
=
normMatix
(
mAarrayQ
);
if
((
nmQ
==
0.0
)
||
(
Math
.
abs
(
M
.
det
())/
normMatix
(
mAarrayQ
)<
thresholdQuad
))
{
if
((
nmQ
==
0.0
)
||
(
Math
.
abs
(
M
.
det
())/
normMatix
(
mAarrayQ
)<
thresholdQuad
))
{
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Using linear approximation, M.det()="
+
M
.
det
()+
" normMatix(mAarrayQ)="
+
normMatix
(
mAarrayQ
));
//did not happen
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Using linear approximation, M.det()="
+
M
.
det
()+
" normMatix(mAarrayQ)="
+
normMatix
(
mAarrayQ
)+
", thresholdQuad="
+
thresholdQuad
+
", nmQ="
+
nmQ
+
", Math.abs(M.det())/normMatix(mAarrayQ)="
+(
Math
.
abs
(
M
.
det
())/
normMatix
(
mAarrayQ
)));
//did not happen
return
ABCDEF
;
// not enough data for the quadratic approximation, return linear
return
ABCDEF
;
// not enough data for the quadratic approximation, return linear
}
}
// double [] zAarrayQ={SZ20,SZ02,SZ11,SZ10,SZ01,SZ00};
// double [] zAarrayQ={SZ20,SZ02,SZ11,SZ10,SZ01,SZ00};
...
...
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