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
46292639
Commit
46292639
authored
Sep 17, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing old bug where sample coordinates did not match measured lens
center
parent
60e0334d
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
238 additions
and
38 deletions
+238
-38
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+187
-27
Distortions.java
src/main/java/Distortions.java
+28
-1
FocusingField.java
src/main/java/FocusingField.java
+19
-6
LensAdjustment.java
src/main/java/LensAdjustment.java
+4
-4
No files found.
src/main/java/Aberration_Calibration.java
View file @
46292639
This diff is collapsed.
Click to expand it.
src/main/java/Distortions.java
View file @
46292639
...
@@ -12398,7 +12398,7 @@ Which parameters affect which matrices
...
@@ -12398,7 +12398,7 @@ Which parameters affect which matrices
public int getGoniometerHorizontalIndex(){return 6;}
public int getGoniometerHorizontalIndex(){return 6;}
public int getGoniometerAxialIndex(){return 7;}
public int getGoniometerAxialIndex(){return 7;}
public int getSensorWidth() { return this.sensorWidth;}
public int getSensorWidth() { return this.sensorWidth;}
public int getSensorHeight() { return this.sensor
Width
;}
public int getSensorHeight() { return this.sensor
Height
;}
public int getSensorWidth(int subCam) { return this.sensorWidth;} // for the future? different sensors
public int getSensorWidth(int subCam) { return this.sensorWidth;} // for the future? different sensors
public int getSensorHeight(int subCam) { return this.sensorHeight;}// for the future? different sensors
public int getSensorHeight(int subCam) { return this.sensorHeight;}// for the future? different sensors
public double getPixelSize(int subCamNumber){return this.eyesisSubCameras[0][subCamNumber].pixelSize;} // use station 0's pixel size
public double getPixelSize(int subCamNumber){return this.eyesisSubCameras[0][subCamNumber].pixelSize;} // use station 0's pixel size
...
@@ -13952,6 +13952,33 @@ Which parameters affect which matrices
...
@@ -13952,6 +13952,33 @@ Which parameters affect which matrices
this.flipVertical=flipVertical;
this.flipVertical=flipVertical;
recalcCommons();
recalcCommons();
}
}
public void setIntrincicFromSubcamera(EyesisSubCameraParameters pars){
setLensDistortionParameters(
pars.focalLength,
pars.pixelSize, //um
pars.distortionRadius, // mm
pars.distortionA8, // r^7
pars.distortionA7, // r^6
pars.distortionA6, // r^5
pars.distortionA5, // r^4
pars.distortionA, // r^4
pars.distortionB, // r^3
pars.distortionC, // r^2
// orientation/position parameters
this.yaw, // (keep) angle in degrees from perpendicular to the pattern, 0 - towards wall, positive - clockwise from top
this.pitch, // (keep) angle in degrees from perpendicular to the pattern, 0 - towards wall, positive - up
this.roll, // (keep) angle in degrees rotation around camera optical axis (perpendicular to pattern if yaw==0, pitch==0), positive - clockwise
this.x0, // (keep) lens axis from pattern center, mm (to the right)
this.y0, // (keep) lens axis from pattern center, mm (down)
this.z0, // (keep) lens axis from pattern center, mm (away)
this.distance, // (keep) distance from the lens input pupil to the pattern plane along the camera axis, mm
pars.px0, // center of the lens on the sensor, pixels
pars.py0, // center of the lens on the sensor, pixels
this.flipVertical // (keep) acquired image is mirrored vertically (mirror used)
);
}
public void setLensDistortionParameters(LensDistortionParameters ldp
public void setLensDistortionParameters(LensDistortionParameters ldp
){
){
this.focalLength=ldp.focalLength;
this.focalLength=ldp.focalLength;
src/main/java/FocusingField.java
View file @
46292639
...
@@ -765,6 +765,9 @@ public double [][] flattenSampleCoord(){
...
@@ -765,6 +765,9 @@ public double [][] flattenSampleCoord(){
for
(
int
i
=
0
;
i
<
sampleCoord
.
length
;
i
++)
for
(
int
j
=
0
;
j
<
sampleCoord
[
0
].
length
;
j
++)
flatSampleCoord
[
index
++]=
sampleCoord
[
i
][
j
];
for
(
int
i
=
0
;
i
<
sampleCoord
.
length
;
i
++)
for
(
int
j
=
0
;
j
<
sampleCoord
[
0
].
length
;
j
++)
flatSampleCoord
[
index
++]=
sampleCoord
[
i
][
j
];
return
flatSampleCoord
;
// last dimension is not cloned
return
flatSampleCoord
;
// last dimension is not cloned
}
}
public
double
[][][]
getSampleCoord
(){
return
this
.
sampleCoord
;
}
public
class
MeasuredSample
{
public
class
MeasuredSample
{
public
int
[]
motors
=
new
int
[
3
];
public
int
[]
motors
=
new
int
[
3
];
public
String
timestamp
;
public
String
timestamp
;
...
@@ -2890,23 +2893,31 @@ public void stepLevenbergMarquardtAction(int debugLevel){//
...
@@ -2890,23 +2893,31 @@ public void stepLevenbergMarquardtAction(int debugLevel){//
/**
/**
* Dialog to select Levenberg-Marquardt algorithm and related parameters
* Dialog to select Levenberg-Marquardt algorithm and related parameters
* @param autoSel - disable default stop, suggest strategy 0
* @return true if OK, false if canceled
* @return true if OK, false if canceled
*
*/
*/
public
boolean
selectLMAParameters
(){
public
boolean
selectLMAParameters
(
boolean
autoSel
){
// int numSeries=fittingStrategy.getNumSeries();
// int numSeries=fittingStrategy.getNumSeries();
// boolean resetCorrections=false;
// boolean resetCorrections=false;
GenericDialog
gd
=
new
GenericDialog
(
"Levenberg-Marquardt algorithm parameters lens aberrations approxiamtion"
);
GenericDialog
gd
=
new
GenericDialog
(
"Levenberg-Marquardt algorithm parameters lens aberrations approxiamtion"
);
//TODO: change to selection using series comments
//TODO: change to selection using series comments
// gd.addNumericField("Fitting series number", this.currentStrategyStep, 0, 3," (-1 - current)");
// gd.addNumericField("Fitting series number", this.currentStrategyStep, 0, 3," (-1 - current)");
int
suggestStep
=
this
.
currentStrategyStep
;
boolean
suggestStopEachStep
=
this
.
stopEachStep
;
if
(
autoSel
){
suggestStep
=
0
;
suggestStopEachStep
=
false
;
}
FieldStrategies
fs
=
fieldFitting
.
fieldStrategies
;
FieldStrategies
fs
=
fieldFitting
.
fieldStrategies
;
String
[]
indices
=
new
String
[
fs
.
getNumStrategies
()+
1
];
String
[]
indices
=
new
String
[
fs
.
getNumStrategies
()+
1
];
indices
[
0
]=
"current strategy"
;
indices
[
0
]=
"current strategy"
;
for
(
int
i
=
0
;
i
<
fs
.
getNumStrategies
();
i
++)
{
for
(
int
i
=
0
;
i
<
fs
.
getNumStrategies
();
i
++)
{
indices
[
i
+
1
]=
i
+
": "
+
fs
.
getComment
(
i
)+
" ("
+(
fs
.
isStopAfterThis
(
i
)?
"STOP"
:
"CONTINUE"
)+
")"
;
indices
[
i
+
1
]=
i
+
": "
+
fs
.
getComment
(
i
)+
" ("
+(
fs
.
isStopAfterThis
(
i
)?
"STOP"
:
"CONTINUE"
)+
")"
;
}
}
if
(
this
.
currentStrategyStep
>=(
indices
.
length
-
1
))
this
.
currentStrategyStep
=
indices
.
length
-
2
;
if
(
suggestStep
>=(
indices
.
length
-
1
))
suggestStep
=
indices
.
length
-
2
;
// last one
gd
.
addChoice
(
"Fitting series"
,
indices
,
indices
[
this
.
currentStrategy
Step
+
1
]);
gd
.
addChoice
(
"Fitting series"
,
indices
,
indices
[
suggest
Step
+
1
]);
gd
.
addCheckbox
(
"Debug df/dX0, df/dY0"
,
false
);
gd
.
addCheckbox
(
"Debug df/dX0, df/dY0"
,
false
);
gd
.
addNumericField
(
"Debug Jacobian for point number"
,
this
.
debugPoint
,
0
,
5
,
"(-1 - none)"
);
gd
.
addNumericField
(
"Debug Jacobian for point number"
,
this
.
debugPoint
,
0
,
5
,
"(-1 - none)"
);
...
@@ -2920,7 +2931,7 @@ public boolean selectLMAParameters(){
...
@@ -2920,7 +2931,7 @@ public boolean selectLMAParameters(){
gd
.
addNumericField
(
"Threshold lambda to fail"
,
this
.
maxLambda
,
5
);
gd
.
addNumericField
(
"Threshold lambda to fail"
,
this
.
maxLambda
,
5
);
gd
.
addNumericField
(
"Maximal number of iterations"
,
this
.
numIterations
,
0
);
gd
.
addNumericField
(
"Maximal number of iterations"
,
this
.
numIterations
,
0
);
gd
.
addCheckbox
(
"Dialog after each iteration step"
,
this
.
stopEachStep
);
gd
.
addCheckbox
(
"Dialog after each iteration step"
,
suggestStopEachStep
);
//
this.stopEachStep);
gd
.
addCheckbox
(
"Dialog after each iteration series"
,
this
.
stopEachSeries
);
gd
.
addCheckbox
(
"Dialog after each iteration series"
,
this
.
stopEachSeries
);
gd
.
addCheckbox
(
"Dialog after each failure"
,
this
.
stopOnFailure
);
gd
.
addCheckbox
(
"Dialog after each failure"
,
this
.
stopOnFailure
);
gd
.
addCheckbox
(
"Show modified parameters"
,
this
.
showParams
);
gd
.
addCheckbox
(
"Show modified parameters"
,
this
.
showParams
);
...
@@ -3995,12 +4006,13 @@ public void calculateGoodSamples(){
...
@@ -3995,12 +4006,13 @@ public void calculateGoodSamples(){
public
boolean
LevenbergMarquardt
(
public
boolean
LevenbergMarquardt
(
FocusingFieldMeasurement
measurement
,
// null in calibrate mode
FocusingFieldMeasurement
measurement
,
// null in calibrate mode
boolean
openDialog
,
boolean
openDialog
,
boolean
autoSel
,
// boolean filterZ, // for adjust mode
// boolean filterZ, // for adjust mode
int
debugLevel
){
int
debugLevel
){
boolean
calibrate
=
measurement
==
null
;
boolean
calibrate
=
measurement
==
null
;
double
savedLambda
=
this
.
lambda
;
double
savedLambda
=
this
.
lambda
;
this
.
debugLevel
=
debugLevel
;
this
.
debugLevel
=
debugLevel
;
if
(
openDialog
&&
!
selectLMAParameters
())
return
false
;
if
(
openDialog
&&
!
selectLMAParameters
(
autoSel
))
return
false
;
this
.
startTime
=
System
.
nanoTime
();
this
.
startTime
=
System
.
nanoTime
();
// create savedVector (it depends on parameter masks), restore from it if aborted
// create savedVector (it depends on parameter masks), restore from it if aborted
// fieldFitting.initSampleCorrVector(
// fieldFitting.initSampleCorrVector(
...
@@ -5000,6 +5012,7 @@ public boolean LevenbergMarquardt(
...
@@ -5000,6 +5012,7 @@ public boolean LevenbergMarquardt(
boolean
OK
=
LevenbergMarquardt
(
boolean
OK
=
LevenbergMarquardt
(
measurement
,
measurement
,
false
,
// true, // open dialog
false
,
// true, // open dialog
true
,
// boolean autoSel,
debugLevel
);
debugLevel
);
if
(!
OK
){
if
(!
OK
){
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"testMeasurement() failed: LMA failed"
);
if
(
debugLevel
>
1
)
System
.
out
.
println
(
"testMeasurement() failed: LMA failed"
);
...
@@ -8675,7 +8688,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
...
@@ -8675,7 +8688,7 @@ f_corr: d_fcorr/d_zcorr=0, other: a, reff, kx -> ar[1], ar[2], ar[3], ar[4]
System
.
out
.
println
(
"qualBOptimize LMA failed"
);
System
.
out
.
println
(
"qualBOptimize LMA failed"
);
}
}
// zTxTy[0]-=best_qb_corr[0]; - absolute, no need to calculate best_qb_corr;
// zTxTy[0]-=best_qb_corr[0]; - absolute, no need to calculate best_qb_corr;
this
.
qualBOptimizationResults
=
zTxTy
;
this
.
qualBOptimizationResults
=
zTxTy
.
clone
()
;
return
zTxTy
;
return
zTxTy
;
}
}
...
...
src/main/java/LensAdjustment.java
View file @
46292639
...
@@ -297,13 +297,13 @@ public class LensAdjustment {
...
@@ -297,13 +297,13 @@ public class LensAdjustment {
public
double
motorsPreSigma
=
3584.0
;
// when fitting parabola for focusing sharpness in the center, far measurements decay with this sigma
public
double
motorsPreSigma
=
3584.0
;
// when fitting parabola for focusing sharpness in the center, far measurements decay with this sigma
public
double
maxLinearStep
=
3584.0
;
// If there are insufficient measurements to fit parabola - make this step
public
double
maxLinearStep
=
3584.0
;
// If there are insufficient measurements to fit parabola - make this step
public
int
scanStep
=
200
;
// motor step (all 3 motors) in scan focus mode (signed value)
public
int
scanStep
=
320
;
//
200; // motor step (all 3 motors) in scan focus mode (signed value)
public
int
scanNumber
=
50
;
// number of scanStep steps to run
public
int
scanNumber
=
50
;
// number of scanStep steps to run
public
int
scanNumberNegative
=
15
;
// number of scanStep steps negative from the start
public
int
scanNumberNegative
=
20
;
//
15; // number of scanStep steps negative from the start
public
boolean
scanHysteresis
=
true
;
// scan both ways
public
boolean
scanHysteresis
=
false
;
//
true; // scan both ways
public
int
scanHysteresisNumber
=
5
;
// number of test points for the Hysteresis measurement
public
int
scanHysteresisNumber
=
5
;
// number of test points for the Hysteresis measurement
public
boolean
scanTiltEnable
=
true
;
// enable scanning tilt
public
boolean
scanTiltEnable
=
false
;
//
true; // enable scanning tilt
public
boolean
scanTiltReverse
=
false
;
// enable scanning tilt in both directions
public
boolean
scanTiltReverse
=
false
;
// enable scanning tilt in both directions
public
boolean
scanMeasureLast
=
false
;
// Calculate PSF after last move (to original position)
public
boolean
scanMeasureLast
=
false
;
// Calculate PSF after last move (to original position)
public
int
scanTiltRangeX
=
14336
;
// 4 periods
public
int
scanTiltRangeX
=
14336
;
// 4 periods
...
...
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