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
08b36456
Commit
08b36456
authored
Sep 21, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified other distance measurements (like for temperature coefficient)
to use lens aberration model
parent
77c3afd4
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
287 additions
and
99 deletions
+287
-99
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+116
-22
CalibrationHardwareInterface.java
src/main/java/CalibrationHardwareInterface.java
+86
-20
FocusingField.java
src/main/java/FocusingField.java
+73
-56
LensAdjustment.java
src/main/java/LensAdjustment.java
+12
-1
No files found.
src/main/java/Aberration_Calibration.java
View file @
08b36456
This diff is collapsed.
Click to expand it.
src/main/java/CalibrationHardwareInterface.java
View file @
08b36456
...
@@ -2977,7 +2977,25 @@ public class CalibrationHardwareInterface {
...
@@ -2977,7 +2977,25 @@ public class CalibrationHardwareInterface {
fullResults
fullResults
);
);
}
}
public
FocusingField
.
FocusingFieldMeasurement
getThisFFMeasurement
(
FocusingField
focusingField
,
String
sTimestamp
,
double
temperature
,
double
[][]
psfMetrics
,
double
[][][][]
fullResults
){
return
focusingField
.
getFocusingFieldMeasurement
(
sTimestamp
,
//focusingState.getTimestamp(),
temperature
,
//focusingState.getTemperature(),
this
.
curpos
,
//focusingState.motorsPos,
fullResults
);
//focusingState.getSamples());
}
/*
/*
* FocusingHistory.FocusingState focusingState
public void addToHistory( String sTimestamp,double temperature, double[][] psfMetrics){ // null OK
public void addToHistory( String sTimestamp,double temperature, double[][] psfMetrics){ // null OK
this.focusingHistory.add(
this.focusingHistory.add(
sTimestamp,
sTimestamp,
...
@@ -3004,6 +3022,7 @@ public class CalibrationHardwareInterface {
...
@@ -3004,6 +3022,7 @@ public class CalibrationHardwareInterface {
}
}
public
void
listHistory
(
public
void
listHistory
(
boolean
useLMA
,
String
path
,
String
path
,
String
lensSerial
,
String
lensSerial
,
String
comment
,
String
comment
,
...
@@ -3015,6 +3034,7 @@ public class CalibrationHardwareInterface {
...
@@ -3015,6 +3034,7 @@ public class CalibrationHardwareInterface {
double
weightY
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
double
weightY
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
){
){
listHistory
(
listHistory
(
useLMA
,
path
,
path
,
""
,
""
,
lensSerial
,
lensSerial
,
...
@@ -3033,6 +3053,7 @@ public class CalibrationHardwareInterface {
...
@@ -3033,6 +3053,7 @@ public class CalibrationHardwareInterface {
}
}
public
void
listHistory
(
public
void
listHistory
(
boolean
useLMA
,
String
path
,
String
path
,
String
serialNumber
,
String
serialNumber
,
String
lensSerial
,
String
lensSerial
,
...
@@ -3051,6 +3072,7 @@ public class CalibrationHardwareInterface {
...
@@ -3051,6 +3072,7 @@ public class CalibrationHardwareInterface {
){
){
this
.
focusingHistory
.
list
(
this
.
focusingHistory
.
list
(
useLMA
,
path
,
path
,
serialNumber
,
serialNumber
,
lensSerial
,
lensSerial
,
...
@@ -3084,6 +3106,7 @@ public class CalibrationHardwareInterface {
...
@@ -3084,6 +3106,7 @@ public class CalibrationHardwareInterface {
pY0
,
pY0
,
sampleCoord
);
sampleCoord
);
}
}
public
FocusingField
.
FocusingFieldMeasurement
getThisFFMeasurement
(
FocusingField
focusingField
){
public
FocusingField
.
FocusingFieldMeasurement
getThisFFMeasurement
(
FocusingField
focusingField
){
return
getThisFFMeasurement
(
focusingField
,
-
1
);
return
getThisFFMeasurement
(
focusingField
,
-
1
);
}
}
...
@@ -3899,6 +3922,14 @@ public class CalibrationHardwareInterface {
...
@@ -3899,6 +3922,14 @@ public class CalibrationHardwareInterface {
if
((
index
<
0
)
||
(
index
>=
this
.
history
.
size
()))
return
null
;
if
((
index
<
0
)
||
(
index
>=
this
.
history
.
size
()))
return
null
;
return
this
.
history
.
get
(
index
).
getCenterResolutions
();
return
this
.
history
.
get
(
index
).
getCenterResolutions
();
}
}
public
double
[]
getzTxTy
(
int
index
){
if
((
index
<
0
)
||
(
index
>=
this
.
history
.
size
()))
return
null
;
return
this
.
history
.
get
(
index
).
getzTxTy
();
}
public
double
[]
getzTxTy
(){
if
(
this
.
history
.
size
()<
1
)
return
null
;
return
getzTxTy
(
this
.
history
.
size
()-
1
);
}
public
int
size
(){
public
int
size
(){
return
this
.
history
.
size
();
return
this
.
history
.
size
();
}
}
...
@@ -5067,6 +5098,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5067,6 +5098,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
* @return array of 2 elements - {length at 0C, microns/degree}
* @return array of 2 elements - {length at 0C, microns/degree}
*/
*/
public
double
[]
temperatureLinearApproximation
(
public
double
[]
temperatureLinearApproximation
(
boolean
useLMA
,
int
numSamples
,
// number of last samples from history to use, 0 - use all
int
numSamples
,
// number of last samples from history to use, 0 - use all
double
lensDistanceWeightK
,
// used in distance calculation
double
lensDistanceWeightK
,
// used in distance calculation
double
lensDistanceWeightY
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
double
lensDistanceWeightY
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
...
@@ -5079,8 +5111,11 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5079,8 +5111,11 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
int
firstSample
=
this
.
history
.
size
()-
numSamples
;
int
firstSample
=
this
.
history
.
size
()-
numSamples
;
for
(
int
nSample
=
0
;
nSample
<
numSamples
;
nSample
++){
for
(
int
nSample
=
0
;
nSample
<
numSamples
;
nSample
++){
resolutions
=
this
.
history
.
get
(
firstSample
+
nSample
).
getCenterResolutions
();
data
[
nSample
][
0
]=
this
.
history
.
get
(
firstSample
+
nSample
).
getTemperature
();
data
[
nSample
][
0
]=
this
.
history
.
get
(
firstSample
+
nSample
).
getTemperature
();
if
(
useLMA
){
data
[
nSample
][
1
]=
this
.
history
.
get
(
firstSample
+
nSample
).
getzTxTy
()[
0
];
}
else
{
resolutions
=
this
.
history
.
get
(
firstSample
+
nSample
).
getCenterResolutions
();
data
[
nSample
][
1
]=
getLensDistance
(
data
[
nSample
][
1
]=
getLensDistance
(
resolutions
,
// {R-sharpness,G-sharpness,B-sharpness}
resolutions
,
// {R-sharpness,G-sharpness,B-sharpness}
true
,
// boolean absolute, // return absolutely calibrated data
true
,
// boolean absolute, // return absolutely calibrated data
...
@@ -5089,6 +5124,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5089,6 +5124,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
1
//debugLevel
1
//debugLevel
);
);
}
}
}
PolynomialApproximation
pa
=
new
PolynomialApproximation
(
debugLevel
);
PolynomialApproximation
pa
=
new
PolynomialApproximation
(
debugLevel
);
double
[]
polyCoeff
=
pa
.
polynomialApproximation1d
(
data
,
1
);
// just linear
double
[]
polyCoeff
=
pa
.
polynomialApproximation1d
(
data
,
1
);
// just linear
return
polyCoeff
;
return
polyCoeff
;
...
@@ -5524,6 +5560,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5524,6 +5560,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
// todo - add "probe around" - 6/3 points, +/- for each direction (fraction of sigma?)
// todo - add "probe around" - 6/3 points, +/- for each direction (fraction of sigma?)
public
void
list
(
public
void
list
(
boolean
useLMA
,
String
path
,
String
path
,
String
lensSerial
,
// if null - do not add average
String
lensSerial
,
// if null - do not add average
String
comment
,
String
comment
,
...
@@ -5533,8 +5570,10 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5533,8 +5570,10 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
double
weightRatioBlueToGreen
,
double
weightRatioBlueToGreen
,
double
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
double
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
double
weightY
){
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
double
weightY
){
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
list
(
path
,
list
(
""
,
useLMA
,
path
,
""
,
// serial; number
lensSerial
,
// if null - do not add average
lensSerial
,
// if null - do not add average
comment
,
comment
,
showIndividualComponents
,
showIndividualComponents
,
...
@@ -5641,6 +5680,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5641,6 +5680,7 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
}
}
public
void
list
(
public
void
list
(
boolean
useLMA
,
String
path
,
String
path
,
String
serialNumber
,
String
serialNumber
,
String
lensSerial
,
// if null - do not add average
String
lensSerial
,
// if null - do not add average
...
@@ -5701,15 +5741,22 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5701,15 +5741,22 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
if
(
showIndividualComponents
)
{
if
(
showIndividualComponents
)
{
for
(
int
i
=
0
;
i
<
this
.
history
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
this
.
history
.
size
();
i
++){
FocusingState
focusingState
=
this
.
history
.
get
(
i
);
FocusingState
focusingState
=
this
.
history
.
get
(
i
);
double
[]
zTxTy
=
useLMA
?
focusingState
.
getzTxTy
():
null
;
double
[][]
metrics
=
focusingState
.
getMetrics
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
metrics
=
focusingState
.
getMetrics
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
resolution
=
focusingState
.
getSharpness
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
resolution
=
focusingState
.
getSharpness
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
dist
=
getLensDistance
(
double
dist
=
(
zTxTy
==
null
)?
getLensDistance
(
focusingState
.
getCenterResolutions
(),
// {R-sharpness,G-sharpness,B-sharpness}
focusingState
.
getCenterResolutions
(),
// {R-sharpness,G-sharpness,B-sharpness}
true
,
//boolean absolute, // return absolutely calibrated data
true
,
//boolean absolute, // return absolutely calibrated data
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
weightY
,
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
weightY
,
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
1
);
//int debugLevel
1
):
//int debugLevel
zTxTy
[
0
];
double
[]
averageMetrics
=
metrics
[
3
];
double
[]
averageMetrics
=
metrics
[
3
];
if
(
zTxTy
!=
null
){
averageMetrics
=
metrics
[
3
].
clone
();
// to modify w/o changing original
averageMetrics
[
1
]=
zTxTy
[
1
];
// tiltX
averageMetrics
[
2
]=
zTxTy
[
2
];
// tiltY
}
double
[]
averageResolution
=
resolution
[
3
];
double
[]
averageResolution
=
resolution
[
3
];
sb
.
append
((
i
+
1
)+
"\t"
);
sb
.
append
((
i
+
1
)+
"\t"
);
String
timestamp
=
focusingState
.
getTimestamp
();
String
timestamp
=
focusingState
.
getTimestamp
();
...
@@ -5779,9 +5826,15 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5779,9 +5826,15 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
for
(
int
i
=
0
;
i
<
this
.
history
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
this
.
history
.
size
();
i
++){
// int parIndex=0;
// int parIndex=0;
FocusingState
focusingState
=
this
.
history
.
get
(
i
);
FocusingState
focusingState
=
this
.
history
.
get
(
i
);
double
[]
zTxTy
=
useLMA
?
focusingState
.
getzTxTy
():
null
;
double
[][]
metrics
=
focusingState
.
getMetrics
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
metrics
=
focusingState
.
getMetrics
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
resolution
=
focusingState
.
getSharpness
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[][]
resolution
=
focusingState
.
getSharpness
(
weightRatioRedToGreen
,
weightRatioBlueToGreen
);
double
[]
averageMetrics
=
metrics
[
3
];
double
[]
averageMetrics
=
metrics
[
3
];
if
(
zTxTy
!=
null
){
averageMetrics
=
metrics
[
3
].
clone
();
// to modify w/o changing original
averageMetrics
[
1
]=
zTxTy
[
1
];
// tiltX
averageMetrics
[
2
]=
zTxTy
[
2
];
// tiltY
}
double
[]
averageResolution
=
resolution
[
3
];
double
[]
averageResolution
=
resolution
[
3
];
if
(!
justSummary
)
sb
.
append
((
i
+
1
)+
"\t"
);
if
(!
justSummary
)
sb
.
append
((
i
+
1
)+
"\t"
);
String
timestamp
=
focusingState
.
getTimestamp
();
String
timestamp
=
focusingState
.
getTimestamp
();
...
@@ -5806,12 +5859,13 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -5806,12 +5859,13 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
sums
[
4
]+=
focusingState
.
motorsPos
[
0
];
sums
[
4
]+=
focusingState
.
motorsPos
[
0
];
sums
[
5
]+=
focusingState
.
motorsPos
[
1
];
sums
[
5
]+=
focusingState
.
motorsPos
[
1
];
sums
[
6
]+=
focusingState
.
motorsPos
[
2
];
sums
[
6
]+=
focusingState
.
motorsPos
[
2
];
double
dist
=
getLensDistance
(
double
dist
=
(
zTxTy
==
null
)?
getLensDistance
(
focusingState
.
getCenterResolutions
(),
// {R-sharpness,G-sharpness,B-sharpness}
focusingState
.
getCenterResolutions
(),
// {R-sharpness,G-sharpness,B-sharpness}
true
,
//boolean absolute, // return absolutely calibrated data
true
,
//boolean absolute, // return absolutely calibrated data
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
weightK
,
// 0.0 - all 3 component errors are combined with the same weights. 1.0 - proportional to squared first derivatives
weightY
,
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
weightY
,
// R-frac, Y-frac have the same scale regardless of the sharpness, but not Y. This is to balance Y contribution
1
);
//int debugLevel
1
):
//int debugLevel
zTxTy
[
0
];
if
(
Double
.
isNaN
(
dist
)){
if
(
Double
.
isNaN
(
dist
)){
if
(!
justSummary
)
sb
.
append
(
"\t---"
);
if
(!
justSummary
)
sb
.
append
(
"\t---"
);
}
else
{
}
else
{
...
@@ -6199,7 +6253,19 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
...
@@ -6199,7 +6253,19 @@ if (debugLevel>=debugThreshold) System.out.println(i+" "+diff[0]+" "+diff[1]+" "
1.0
,
1.0
,
weightRatioBlueToGreen
);
weightRatioBlueToGreen
);
}
}
// alternative mode (from aberration model) ising metrics[6][]
public
double
[]
getzTxTy
(){
if
(
this
.
psfMetricses
==
null
){
return
null
;
}
if
((
this
.
psfMetricses
.
length
<
7
)
||
(
this
.
psfMetricses
[
6
]==
null
))
{
System
.
out
.
println
(
"BUG? psfMetrics does not have line 6 with lens berration model z, tx, ty"
);
return
null
;
}
double
[]
zTxTy
={
this
.
psfMetricses
[
6
][
0
],
this
.
psfMetricses
[
6
][
1
],
this
.
psfMetricses
[
6
][
2
]};
return
zTxTy
;
}
public
double
[][]
getMetrics
(
public
double
[][]
getMetrics
(
double
weightRed
,
double
weightRed
,
double
weightGreen
,
double
weightGreen
,
...
...
src/main/java/FocusingField.java
View file @
08b36456
...
@@ -5121,20 +5121,39 @@ public boolean LevenbergMarquardt(
...
@@ -5121,20 +5121,39 @@ public boolean LevenbergMarquardt(
public
double
[][]
getAllZTM
(
public
double
[][]
getAllZTM
(
boolean
noTiltScan
,
boolean
noTiltScan
,
FocusingField
ff
){
FocusingField
ff
,
double
[][]
result
=
new
double
[
ff
.
measurements
.
size
()][
6
];
boolean
noMotors
){
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]=
adjustLMA
(
noTiltScan
,
ff
.
measurements
.
get
(
i
),
false
);
double
[][]
result
=
new
double
[
ff
.
measurements
.
size
()][];
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]=
adjustLMA
(
noTiltScan
,
ff
.
measurements
.
get
(
i
),
false
,
// boolean parallelMove,
true
,
// boolean noQualB, // do not re-claculate testQualB
noMotors
);
// boolean noAdjust) // do not calculate correction
return
result
;
return
result
;
}
}
public
double
[]
averageZTM
(
// results relative to optimal
public
double
[]
averageZTM
(
// results relative to optimal
boolean
noTiltScan
,
boolean
noTiltScan
,
FocusingField
ff
){
FocusingField
ff
,
double
[]
result
=
new
double
[
6
];
boolean
noMotors
){
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Calculating optimal focal/tilt, qualBOptimizeMode="
+
this
.
qualBOptimizeMode
);
testQualB
(
false
);
// optimize qualB, store results in this.qualBOptimizationResults
if
(
debugLevel
>
0
)
{
System
.
out
.
println
(
"Optimal absolute Zc="
+
this
.
qualBOptimizationResults
[
0
]);
System
.
out
.
println
(
"Optimal Tx="
+
this
.
qualBOptimizationResults
[
1
]);
System
.
out
.
println
(
"Optimal Ty="
+
this
.
qualBOptimizationResults
[
2
]);
}
double
[]
result
=
new
double
[
noMotors
?
3
:
6
];
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]=
0.0
;
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]=
0.0
;
int
num
=
0
;
int
num
=
0
;
for
(
FocusingFieldMeasurement
measurement:
ff
.
measurements
){
for
(
FocusingFieldMeasurement
measurement:
ff
.
measurements
){
double
[]
ZTM
=
adjustLMA
(
noTiltScan
,
measurement
,
false
);
double
[]
ZTM
=
adjustLMA
(
noTiltScan
,
measurement
,
false
,
// boolean parallelMove,
true
,
// boolean noQualB, // do not re-claculate testQualB
noMotors
);
// boolean noAdjust) // do not calculate correction
if
(
ZTM
!=
null
)
{
if
(
ZTM
!=
null
)
{
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]+=
ZTM
[
i
];
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
result
[
i
]+=
ZTM
[
i
];
num
++;
num
++;
...
@@ -5147,7 +5166,10 @@ public boolean LevenbergMarquardt(
...
@@ -5147,7 +5166,10 @@ public boolean LevenbergMarquardt(
public
double
[]
adjustLMA
(
// result relative to optimal
public
double
[]
adjustLMA
(
// result relative to optimal
boolean
noTiltScan
,
boolean
noTiltScan
,
FocusingFieldMeasurement
measurement
,
FocusingFieldMeasurement
measurement
,
boolean
parallelMove
){
boolean
parallelMove
,
boolean
noQualB
,
// do not re-claculate testQualB
boolean
noAdjust
){
// do not calculate correction
if
(!
noQualB
)
{
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Calculating optimal focal/tilt, qualBOptimizeMode="
+
this
.
qualBOptimizeMode
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Calculating optimal focal/tilt, qualBOptimizeMode="
+
this
.
qualBOptimizeMode
);
testQualB
(
false
);
// optimize qualB, store results in this.qualBOptimizationResults
testQualB
(
false
);
// optimize qualB, store results in this.qualBOptimizationResults
if
(
debugLevel
>
0
)
{
if
(
debugLevel
>
0
)
{
...
@@ -5155,6 +5177,7 @@ public boolean LevenbergMarquardt(
...
@@ -5155,6 +5177,7 @@ public boolean LevenbergMarquardt(
System
.
out
.
println
(
"Optimal Tx="
+
this
.
qualBOptimizationResults
[
1
]);
System
.
out
.
println
(
"Optimal Tx="
+
this
.
qualBOptimizationResults
[
1
]);
System
.
out
.
println
(
"Optimal Ty="
+
this
.
qualBOptimizationResults
[
2
]);
System
.
out
.
println
(
"Optimal Ty="
+
this
.
qualBOptimizationResults
[
2
]);
}
}
}
if
(!
testMeasurement
(
if
(!
testMeasurement
(
measurement
,
measurement
,
zMin
,
//+best_qb_corr[0],
zMin
,
//+best_qb_corr[0],
...
@@ -5166,23 +5189,16 @@ public boolean LevenbergMarquardt(
...
@@ -5166,23 +5189,16 @@ public boolean LevenbergMarquardt(
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"adjustLMA() failed"
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"adjustLMA() failed"
);
return
null
;
return
null
;
}
}
double
[]
result
=
new
double
[
6
];
double
[]
result
=
new
double
[
noAdjust
?
3
:
6
];
// double [] best_qb_corr= fieldFitting.getBestQualB(
// k_red,
// k_blue,
// true);
double
[]
zTilts
=
getCenterZTxTy
(
measurement
);
double
[]
zTilts
=
getCenterZTxTy
(
measurement
);
result
[
0
]=
zTilts
[
0
]-
this
.
qualBOptimizationResults
[
0
];
//best_qb_corr[0];
result
[
0
]=
zTilts
[
0
]-
this
.
qualBOptimizationResults
[
0
];
//best_qb_corr[0];
result
[
1
]=
zTilts
[
1
]-
this
.
qualBOptimizationResults
[
1
];
result
[
1
]=
zTilts
[
1
]-
this
.
qualBOptimizationResults
[
1
];
result
[
2
]=
zTilts
[
2
]-
this
.
qualBOptimizationResults
[
2
];
result
[
2
]=
zTilts
[
2
]-
this
.
qualBOptimizationResults
[
2
];
if
(!
noAdjust
)
{
double
[]
zm
=
null
;
double
[]
zm
=
null
;
// if (parallelMove){
zm
=
new
double
[
3
];
zm
=
new
double
[
3
];
for
(
int
i
=
0
;
i
<
zm
.
length
;
i
++)
zm
[
i
]=
fieldFitting
.
mechanicalFocusingModel
.
mToZm
(
measurement
.
motors
[
i
],
i
);
for
(
int
i
=
0
;
i
<
zm
.
length
;
i
++)
zm
[
i
]=
fieldFitting
.
mechanicalFocusingModel
.
mToZm
(
measurement
.
motors
[
i
],
i
);
// }
if
(
this
.
debugLevel
>
0
){
if
(
this
.
debugLevel
>
0
){
System
.
out
.
println
(
"Current linearized motor positions, center="
+(
0.25
*
zm
[
0
]+
0.25
*
zm
[
1
]+
0.5
*
zm
[
2
]));
System
.
out
.
println
(
"Current linearized motor positions, center="
+(
0.25
*
zm
[
0
]+
0.25
*
zm
[
1
]+
0.5
*
zm
[
2
]));
for
(
int
i
=
0
;
i
<
zm
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
zm
.
length
;
i
++)
{
...
@@ -5214,6 +5230,7 @@ public boolean LevenbergMarquardt(
...
@@ -5214,6 +5230,7 @@ public boolean LevenbergMarquardt(
result
[
4
]=
Double
.
NaN
;
result
[
4
]=
Double
.
NaN
;
result
[
5
]=
Double
.
NaN
;
result
[
5
]=
Double
.
NaN
;
}
}
}
return
result
;
return
result
;
}
}
...
@@ -5310,7 +5327,7 @@ public boolean LevenbergMarquardt(
...
@@ -5310,7 +5327,7 @@ public boolean LevenbergMarquardt(
zTxTy
[
0
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
z0
);
zTxTy
[
0
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
z0
);
zTxTy
[
1
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
tx
);
zTxTy
[
1
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
tx
);
zTxTy
[
2
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
ty
);
zTxTy
[
2
]=
fieldFitting
.
mechanicalFocusingModel
.
getValue
(
MECH_PAR
.
ty
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"testMeasurement(), run "
+
n
+
" (z="
+
zTxTy
[
0
]+
" tx="
+
zTxTy
[
1
]+
" ty="
+
zTxTy
[
2
]+
")"
);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"testMeasurement(), run "
+
n
+
" (z="
+
zTxTy
[
0
]+
" tx="
+
zTxTy
[
1
]+
" ty="
+
zTxTy
[
2
]+
")"
);
boolean
[]
was2PrevEnable
=(
wasPrevEnable
==
null
)?
null
:
wasPrevEnable
.
clone
();
boolean
[]
was2PrevEnable
=(
wasPrevEnable
==
null
)?
null
:
wasPrevEnable
.
clone
();
wasPrevEnable
=(
prevEnable
==
null
)?
null
:
prevEnable
.
clone
();
wasPrevEnable
=(
prevEnable
==
null
)?
null
:
prevEnable
.
clone
();
this
.
lambda
=
this
.
adjustmentInitialLambda
;
this
.
lambda
=
this
.
adjustmentInitialLambda
;
...
@@ -5340,8 +5357,8 @@ public boolean LevenbergMarquardt(
...
@@ -5340,8 +5357,8 @@ public boolean LevenbergMarquardt(
break
;
break
;
}
}
if
(!
changedEnable
)
{
if
(!
changedEnable
)
{
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"No filter cnange, finished in "
+(
n
+
1
)+
" step"
+((
n
==
0
)?
""
:
"s"
));
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"No filter cnange, finished in "
+(
n
+
1
)+
" step"
+((
n
==
0
)?
""
:
"s"
));
if
(
debugLevel
>
0
)
{
if
(
debugLevel
>
1
)
{
System
.
out
.
println
(
"=== Absolute shift/tilt from the measuremet ==="
);
System
.
out
.
println
(
"=== Absolute shift/tilt from the measuremet ==="
);
for
(
int
i
=
0
;
i
<
fieldFitting
.
mechanicalFocusingModel
.
paramValues
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
fieldFitting
.
mechanicalFocusingModel
.
paramValues
.
length
;
i
++){
if
((
fieldFitting
.
mechanicalSelect
==
null
)
||
fieldFitting
.
mechanicalSelect
[
i
]
)
{
if
((
fieldFitting
.
mechanicalSelect
==
null
)
||
fieldFitting
.
mechanicalSelect
[
i
]
)
{
...
@@ -9609,7 +9626,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
...
@@ -9609,7 +9626,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
String
msg
=
"QualB="
+
this
.
currentQualB
+
" ("
+
this
.
firstQualB
+
") "
+
String
msg
=
"QualB="
+
this
.
currentQualB
+
" ("
+
this
.
firstQualB
+
") "
+
" at "
+
IJ
.
d2s
(
0.000000001
*(
System
.
nanoTime
()-
this
.
qStartTime
),
3
);
" at "
+
IJ
.
d2s
(
0.000000001
*(
System
.
nanoTime
()-
this
.
qStartTime
),
3
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"qStepLevenbergMarquardtAction() "
+
msg
);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"qStepLevenbergMarquardtAction() "
+
msg
);
// if (this.updateStatus) IJ.showStatus(msg);
// if (this.updateStatus) IJ.showStatus(msg);
if
(
updateStatus
){
if
(
updateStatus
){
IJ
.
showStatus
(
"Done: Step #"
+
this
.
iterationStepNumber
+
IJ
.
showStatus
(
"Done: Step #"
+
this
.
iterationStepNumber
+
...
...
src/main/java/LensAdjustment.java
View file @
08b36456
...
@@ -195,6 +195,7 @@ public class LensAdjustment {
...
@@ -195,6 +195,7 @@ public class LensAdjustment {
public
String
gridGeometryFile
=
""
;
public
String
gridGeometryFile
=
""
;
public
String
initialCalibrationFile
=
""
;
public
String
initialCalibrationFile
=
""
;
public
String
focusingHistoryFile
=
""
;
public
String
focusingHistoryFile
=
""
;
public
boolean
useLMAMetrics
=
true
;
// measure/report focal distance and tilts using lens model/LMA (when available)
public
String
strategyFile
=
""
;
public
String
strategyFile
=
""
;
public
String
resultsSuperDirectory
=
""
;
// directory with subdirectories named as serial numbers to stro results
public
String
resultsSuperDirectory
=
""
;
// directory with subdirectories named as serial numbers to stro results
public
int
EEPROM_channel
=
1
;
// EEPROM channel to read serial number from
public
int
EEPROM_channel
=
1
;
// EEPROM channel to read serial number from
...
@@ -430,6 +431,7 @@ public class LensAdjustment {
...
@@ -430,6 +431,7 @@ public class LensAdjustment {
String
strategyFile
,
String
strategyFile
,
String
resultsSuperDirectory
,
// directory with subdirectories named as serial numbers to stro results
String
resultsSuperDirectory
,
// directory with subdirectories named as serial numbers to stro results
String
focusingHistoryFile
,
String
focusingHistoryFile
,
boolean
useLMAMetrics
,
// measure/report focal distance and tilts using lens model/LMA (when available)
int
EEPROM_channel
,
// EEPROM channel to read serial number from
int
EEPROM_channel
,
// EEPROM channel to read serial number from
boolean
saveResults
,
// save focusing results
boolean
saveResults
,
// save focusing results
boolean
showResults
,
// show focusing (includingh intermediate) results
boolean
showResults
,
// show focusing (includingh intermediate) results
...
@@ -577,6 +579,7 @@ public class LensAdjustment {
...
@@ -577,6 +579,7 @@ public class LensAdjustment {
this
.
strategyFile
=
strategyFile
;
this
.
strategyFile
=
strategyFile
;
this
.
resultsSuperDirectory
=
resultsSuperDirectory
;
// directory with subdirectories named as serial numbers to stro results
this
.
resultsSuperDirectory
=
resultsSuperDirectory
;
// directory with subdirectories named as serial numbers to stro results
this
.
focusingHistoryFile
=
focusingHistoryFile
;
this
.
focusingHistoryFile
=
focusingHistoryFile
;
this
.
useLMAMetrics
=
useLMAMetrics
;
// measure/report focal distance and tilts using lens model/LMA (when available)
this
.
EEPROM_channel
=
EEPROM_channel
;
// EEPROM channel to read serial number from
this
.
EEPROM_channel
=
EEPROM_channel
;
// EEPROM channel to read serial number from
this
.
saveResults
=
saveResults
;
// save focusing results
this
.
saveResults
=
saveResults
;
// save focusing results
this
.
showResults
=
showResults
;
// show focusing (includingh intermediate) results
this
.
showResults
=
showResults
;
// show focusing (includingh intermediate) results
...
@@ -725,6 +728,7 @@ public class LensAdjustment {
...
@@ -725,6 +728,7 @@ public class LensAdjustment {
this
.
strategyFile
,
this
.
strategyFile
,
this
.
resultsSuperDirectory
,
// directory with subdirectories named as serial numbers to stro results
this
.
resultsSuperDirectory
,
// directory with subdirectories named as serial numbers to stro results
this
.
focusingHistoryFile
,
this
.
focusingHistoryFile
,
this
.
useLMAMetrics
,
// measure/report focal distance and tilts using lens model/LMA (when available)
this
.
EEPROM_channel
,
// EEPROM channel to read serial number from
this
.
EEPROM_channel
,
// EEPROM channel to read serial number from
this
.
saveResults
,
// save focusing results
this
.
saveResults
,
// save focusing results
this
.
showResults
,
// show focusing (includingh intermediate) results
this
.
showResults
,
// show focusing (includingh intermediate) results
...
@@ -871,6 +875,7 @@ public class LensAdjustment {
...
@@ -871,6 +875,7 @@ public class LensAdjustment {
properties
.
setProperty
(
prefix
+
"strategyFile"
,
this
.
strategyFile
+
""
);
properties
.
setProperty
(
prefix
+
"strategyFile"
,
this
.
strategyFile
+
""
);
properties
.
setProperty
(
prefix
+
"resultsSuperDirectory"
,
this
.
resultsSuperDirectory
+
""
);
properties
.
setProperty
(
prefix
+
"resultsSuperDirectory"
,
this
.
resultsSuperDirectory
+
""
);
properties
.
setProperty
(
prefix
+
"focusingHistoryFile"
,
this
.
focusingHistoryFile
+
""
);
properties
.
setProperty
(
prefix
+
"focusingHistoryFile"
,
this
.
focusingHistoryFile
+
""
);
properties
.
setProperty
(
prefix
+
"useLMAMetrics"
,
this
.
useLMAMetrics
+
""
);
properties
.
setProperty
(
prefix
+
"serialNumber"
,
this
.
serialNumber
+
""
);
properties
.
setProperty
(
prefix
+
"serialNumber"
,
this
.
serialNumber
+
""
);
if
(!
Double
.
isNaN
(
this
.
sensorTemperature
))
properties
.
setProperty
(
prefix
+
"sensorTemperature"
,
this
.
sensorTemperature
+
""
);
if
(!
Double
.
isNaN
(
this
.
sensorTemperature
))
properties
.
setProperty
(
prefix
+
"sensorTemperature"
,
this
.
sensorTemperature
+
""
);
if
(!
Double
.
isNaN
(
this
.
result_lastKT
))
properties
.
setProperty
(
prefix
+
"result_lastKT"
,
this
.
result_lastKT
+
""
);
if
(!
Double
.
isNaN
(
this
.
result_lastKT
))
properties
.
setProperty
(
prefix
+
"result_lastKT"
,
this
.
result_lastKT
+
""
);
...
@@ -1030,6 +1035,9 @@ public class LensAdjustment {
...
@@ -1030,6 +1035,9 @@ public class LensAdjustment {
if
(
properties
.
getProperty
(
prefix
+
"focusingHistoryFile"
)!=
null
)
if
(
properties
.
getProperty
(
prefix
+
"focusingHistoryFile"
)!=
null
)
this
.
focusingHistoryFile
=
properties
.
getProperty
(
prefix
+
"focusingHistoryFile"
);
this
.
focusingHistoryFile
=
properties
.
getProperty
(
prefix
+
"focusingHistoryFile"
);
if
(
properties
.
getProperty
(
prefix
+
"useLMAMetrics"
)!=
null
)
this
.
useLMAMetrics
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"useLMAMetrics"
));
if
(
properties
.
getProperty
(
prefix
+
"serialNumber"
)!=
null
)
if
(
properties
.
getProperty
(
prefix
+
"serialNumber"
)!=
null
)
this
.
serialNumber
=
properties
.
getProperty
(
prefix
+
"serialNumber"
);
this
.
serialNumber
=
properties
.
getProperty
(
prefix
+
"serialNumber"
);
// this.serialNumber is only written, but never read from the configuration file (only from devivce)
// this.serialNumber is only written, but never read from the configuration file (only from devivce)
...
@@ -1441,7 +1449,8 @@ public class LensAdjustment {
...
@@ -1441,7 +1449,8 @@ public class LensAdjustment {
gd
.
addStringField
(
"Initial camera intrinsic/extrinsic parametres file"
,
this
.
initialCalibrationFile
,
40
);
gd
.
addStringField
(
"Initial camera intrinsic/extrinsic parametres file"
,
this
.
initialCalibrationFile
,
40
);
gd
.
addStringField
(
"Levenberg-Marquardt algorithm strategy file"
,
this
.
strategyFile
,
40
);
gd
.
addStringField
(
"Levenberg-Marquardt algorithm strategy file"
,
this
.
strategyFile
,
40
);
gd
.
addStringField
(
"Focusing results superdirectory (individual will be named by serial numbers)"
,
this
.
resultsSuperDirectory
,
40
);
gd
.
addStringField
(
"Focusing results superdirectory (individual will be named by serial numbers)"
,
this
.
resultsSuperDirectory
,
40
);
gd
.
addStringField
(
"Measurement history (acquired during \"Scan Calib LMA\" file"
,
this
.
focusingHistoryFile
,
80
);
gd
.
addStringField
(
"Measurement history (acquired during \"Scan Calib LMA\") file"
,
this
.
focusingHistoryFile
,
80
);
gd
.
addCheckbox
(
"Use lens aberration model (if available) for focal distance and tilts"
,
this
.
useLMAMetrics
);
gd
.
addNumericField
(
"EEPROM channel to read sensor serial number from"
,
this
.
EEPROM_channel
,
0
,
4
,
""
);
gd
.
addNumericField
(
"EEPROM channel to read sensor serial number from"
,
this
.
EEPROM_channel
,
0
,
4
,
""
);
gd
.
addCheckbox
(
"Save SFE focusing results (including intermediate) "
,
this
.
saveResults
);
gd
.
addCheckbox
(
"Save SFE focusing results (including intermediate) "
,
this
.
saveResults
);
gd
.
addCheckbox
(
"Show SFE focusing results (including intermediate) "
,
this
.
showResults
);
gd
.
addCheckbox
(
"Show SFE focusing results (including intermediate) "
,
this
.
showResults
);
...
@@ -1618,6 +1627,8 @@ public class LensAdjustment {
...
@@ -1618,6 +1627,8 @@ public class LensAdjustment {
this
.
strategyFile
=
gd
.
getNextString
();
this
.
strategyFile
=
gd
.
getNextString
();
this
.
resultsSuperDirectory
=
gd
.
getNextString
();
this
.
resultsSuperDirectory
=
gd
.
getNextString
();
this
.
focusingHistoryFile
=
gd
.
getNextString
();
this
.
focusingHistoryFile
=
gd
.
getNextString
();
this
.
useLMAMetrics
=
gd
.
getNextBoolean
();
this
.
EEPROM_channel
=
(
int
)
gd
.
getNextNumber
();
this
.
EEPROM_channel
=
(
int
)
gd
.
getNextNumber
();
this
.
saveResults
=
gd
.
getNextBoolean
();
this
.
saveResults
=
gd
.
getNextBoolean
();
this
.
showResults
=
gd
.
getNextBoolean
();
this
.
showResults
=
gd
.
getNextBoolean
();
...
...
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