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
5fdebd94
Commit
5fdebd94
authored
Nov 11, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing projected grid used for aberrations kernels generation
parent
9e7ad476
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
27 deletions
+69
-27
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+22
-0
Distortions.java
src/main/java/Distortions.java
+8
-4
EyesisAberrations.java
src/main/java/EyesisAberrations.java
+13
-10
MatchSimulatedPattern.java
src/main/java/MatchSimulatedPattern.java
+26
-13
No files found.
src/main/java/Aberration_Calibration.java
View file @
5fdebd94
...
...
@@ -1094,6 +1094,7 @@ if (MORE_BUTTONS) {
boolean
noAuto
=
label
.
equals
(
"Restore no autoload"
);
ABERRATIONS_PARAMETERS
.
autoRestore
=
false
;
loadProperties
(
null
,
PROCESS_PARAMETERS
.
kernelsDirectory
,
PROCESS_PARAMETERS
.
useXML
,
PROPERTIES
);
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
if
(
ABERRATIONS_PARAMETERS
.
autoRestore
&&
!
noAuto
){
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"Auto-loading configuration files"
);
if
(
LENS_DISTORTIONS
==
null
)
{
...
...
@@ -1141,6 +1142,27 @@ if (MORE_BUTTONS) {
}
if
(
LENS_DISTORTIONS
.
fittingStrategy
!=
null
)
{
// trying to fix restore
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"LENS_DISTORTIONS.fittingStrategy != null -> Extra after loading"
);
int
minGridsNoPointer
=
1000
;
int
[]
numImages
=
DISTORTION_CALIBRATION_DATA
.
filterImages
(
false
,
// resetHinted,
2
,
// minPointers,
0.4
,
// minGridPeriod,
true
,
// disableNoVignetting,
minGridsNoPointer
);
//minGridsNoPointer);
System
.
out
.
println
(
"Number of enabled grid images: "
+
numImages
[
0
]+
", of them new: "
+
numImages
[
1
]+
", disabled without vignetting info: "
+
numImages
[
2
]+
", disabled having less than "
+
minGridsNoPointer
+
" nodes and no matched pointers: "
+
numImages
[
3
]);
if
(
DISTORTION_CALIBRATION_DATA
.
gIS
==
null
)
{
int
numImageSets
=
DISTORTION_CALIBRATION_DATA
.
buildImageSets
(
false
);
// from scratch
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"Image set was empty, built a new one with "
+
numImageSets
+
" image sets (\"panoramas\"): "
);
DISTORTION_CALIBRATION_DATA
.
updateSetOrientation
(
null
);
// restore orientation from (enabled) image files
if
(
DEBUG_LEVEL
>
0
)
System
.
out
.
println
(
"Setting sets orientation from per-grid image data"
);
}
}
restoreFocusingHistory
(
false
);
}
return
;
...
...
src/main/java/Distortions.java
View file @
5fdebd94
...
...
@@ -3073,12 +3073,16 @@ For each point in the image
(this.fittingStrategy.distortionCalibrationData.gIS[imageSet]!=null)){
this.fittingStrategy.distortionCalibrationData.gIS[imageSet].updateParameterVectorFromSet(parVector);
}
int goniometerHorizontalIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerHorizontalIndex();
int goniometerAxialIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerAxialIndex();
if (!Double.isNaN(goniometerHorizontal)) {
int goniometerHorizontalIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerHorizontalIndex();
parVector[goniometerHorizontalIndex]=goniometerHorizontal;
}
if (!Double.isNaN(goniometerAxial)) {
int goniometerAxialIndex=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getGoniometerAxialIndex();
parVector[goniometerAxialIndex]= goniometerAxial;
}
int sensorWidth=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorWidth(subCamera);
int sensorHeight=fittingStrategy.distortionCalibrationData.eyesisCameraParameters.getSensorHeight(subCamera);
parVector[goniometerHorizontalIndex]=goniometerHorizontal;
parVector[goniometerAxialIndex]= goniometerAxial;
System.out.println("estimateGridOnSensor(): subCamera="+subCamera+", goniometerHorizontal="+goniometerHorizontal+", goniometerAxial="+goniometerAxial);
calcInterParamers(
this.lensDistortionParameters, // 22-long parameter vector for the image
src/main/java/EyesisAberrations.java
View file @
5fdebd94
...
...
@@ -1116,7 +1116,7 @@ public class EyesisAberrations {
}
else
if
(
debugLevel
>
2
){
System
.
out
.
println
(
"Skipping disabled image "
+
imgNum
);
}
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Enabled "
+
numSelected
+
" source files ("
+
numDeselected
+
") were removed by channel selection
"
);
if
(
debugLevel
>
0
)
System
.
out
.
println
(
"Enabled "
+
numSelected
+
" source files ("
+
numDeselected
+
") were removed by channel selection
. partialToReprojected="
+
partialToReprojected
);
String
[]
sourcePaths
=
new
String
[
selectedImages
.
length
];
// Set/verify source paths
...
...
@@ -1254,7 +1254,7 @@ public class EyesisAberrations {
Double
.
NaN
,
// goniometerAxial, - not used
distortions
.
fittingStrategy
.
distortionCalibrationData
.
gIP
[
numGridImage
].
getSetNumber
(),
//imageSet,
true
);
//filterBorder)
hintTolerance
=
5.0
;
// TODO:set from configurable parameter
hintTolerance
=
5.0
;
// TO
DO:set from configurable parameter
}
int
rslt
=
matchSimulatedPattern
.
calculateDistortions
(
...
...
@@ -2095,14 +2095,17 @@ public class EyesisAberrations {
PSFParameters
psfParameters
,
boolean
[]
correlationSizesUsed
){
int
numDifferentFFT
=
0
;
for
(
int
i
=
0
;
i
<
correlationSizesUsed
.
length
;
i
++)
if
(
correlationSizesUsed
[
i
])
{
numDifferentFFT
++;
}
int
[]
corrSizes
=
new
int
[
numDifferentFFT
];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
correlationSizesUsed
.
length
;
i
++)
if
(
correlationSizesUsed
[
i
])
{
corrSizes
[
index
++]=
1
<<
i
;
int
[]
corrSizes
={};
if
(
correlationSizesUsed
!=
null
)
{
int
numDifferentFFT
=
0
;
for
(
int
i
=
0
;
i
<
correlationSizesUsed
.
length
;
i
++)
if
(
correlationSizesUsed
[
i
])
{
numDifferentFFT
++;
}
corrSizes
=
new
int
[
numDifferentFFT
];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
correlationSizesUsed
.
length
;
i
++)
if
(
correlationSizesUsed
[
i
])
{
corrSizes
[
index
++]=
1
<<
i
;
}
}
ImagePlus
impPsf
=
new
ImagePlus
(
path
,
stack
);
...
...
src/main/java/MatchSimulatedPattern.java
View file @
5fdebd94
...
...
@@ -7013,15 +7013,25 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
grid
[
v
-
minV
][
u
-
minU
]=
xy
;
}
int
numNewDefined
=
0
;
// System.out.println("this.PATTERN_GRID.length="+this.PATTERN_GRID.length+"this.PATTERN_GRID[0.length="+this.PATTERN_GRID[0].length);
// System.out.println("this.targetUV.length="+this.targetUV.length+"this.targetUV[0.length="+this.targetUV[0].length);
for
(
int
v
=
0
;
v
<
this
.
PATTERN_GRID
.
length
;
v
++)
for
(
int
u
=
0
;
u
<
this
.
PATTERN_GRID
[
v
].
length
;
u
++)
{
double
[][]
cell
=
this
.
PATTERN_GRID
[
v
][
u
];
if
((
cell
!=
null
)
&&
(
cell
.
length
>
0
)
&&(
cell
[
0
]
!=
null
)
&&
(
cell
[
0
].
length
>
1
)){
cell
[
0
][
0
]=
grid
[
this
.
targetUV
[
v
][
u
][
1
]+
minV
][
this
.
targetUV
[
v
][
u
][
0
]+
minU
][
0
];
cell
[
0
][
1
]=
grid
[
this
.
targetUV
[
v
][
u
][
1
]+
minV
][
this
.
targetUV
[
v
][
u
][
0
]+
minU
][
1
];
if
(
Double
.
isNaN
(
cell
[
0
][
0
])
||
Double
.
isNaN
(
cell
[
0
][
1
])){
this
.
PATTERN_GRID
[
v
][
u
]=
null
;
// make it undefined
// System.out.print("v="+v+" u="+u);
int
tu
=
this
.
targetUV
[
v
][
u
][
0
]-
minU
;
int
tv
=
this
.
targetUV
[
v
][
u
][
1
]-
minV
;
// System.out.println(" tv="+tv+" tu="+tu);
if
((
tu
>=
0
)
&&
(
tv
>=
0
)
&&
(
tv
<
grid
.
length
)
&&
(
tu
<
grid
[
tv
].
length
)
&&
(
grid
[
tv
][
tu
]!=
null
))
{
cell
[
0
][
0
]=
grid
[
tv
][
tu
][
0
];
// -81 -.-1
cell
[
0
][
1
]=
grid
[
tv
][
tu
][
1
];
if
(
Double
.
isNaN
(
cell
[
0
][
0
])
||
Double
.
isNaN
(
cell
[
0
][
1
])){
this
.
PATTERN_GRID
[
v
][
u
]=
null
;
// make it undefined
}
else
{
numNewDefined
++;
}
}
else
{
numNewDefined
++;
this
.
PATTERN_GRID
[
v
][
u
]=
null
;
// make it undefined
}
}
}
...
...
@@ -7294,7 +7304,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
}
// Now remove pointers that are not on white cells
if
(
laserPointer
.
whiteOnly
){
if
(
(
laserPointer
!=
null
)
&&
laserPointer
.
whiteOnly
){
int
numBad
=
0
;
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
{
// Verify that laser spots are on the white cells (sum of uv is even)
...
...
@@ -7364,7 +7374,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
for
(
int
j
=
i
+
1
;
j
<
uv
.
length
;
j
++)
if
(
uv
[
j
]!=
null
)
{
pairMatch
=
false
;
allMatch
=
false
;
diffUVTable
[
0
]=(
int
)
Math
.
round
(
laserPointer
.
laserUVMap
[
j
][
0
]-
laserPointer
.
laserUVMap
[
i
][
0
]);
diffUVTable
[
0
]=(
int
)
Math
.
round
(
laserPointer
.
laserUVMap
[
j
][
0
]-
laserPointer
.
laserUVMap
[
i
][
0
]);
// should not get here if uv is {}
diffUVTable
[
1
]=(
int
)
Math
.
round
(
laserPointer
.
laserUVMap
[
j
][
1
]-
laserPointer
.
laserUVMap
[
i
][
1
]);
diffUVMeas
[
0
]=
(
int
)
Math
.
round
(
uv
[
j
][
0
]-
uv
[
i
][
0
]);
diffUVMeas
[
1
]=
(
int
)
Math
.
round
(
uv
[
j
][
1
]-
uv
[
i
][
1
]);
...
...
@@ -7450,7 +7460,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
}
}
//TODO: here at least some rotations match all points. If there ere more than two - try to use closest to the default/previous
int
rotation
=
flipsToRot
(
laserPointer
.
swapUV
,
laserPointer
.
flipU
,
laserPointer
.
flipV
)
;
int
rotation
=
(
laserPointer
!=
null
)?(
flipsToRot
(
laserPointer
.
swapUV
,
laserPointer
.
flipU
,
laserPointer
.
flipV
)):
0
;
if
(!
possibleRotations
[
rotation
])
{
// current rotation value defined by laserPointer.{swapUV,flipU,flipV} does not match
// find a new one (first - without mirroring)
for
(
int
i
=
0
;
i
<
8
;
i
++)
if
(
possibleRotations
[(((
rotation
^
i
)
&
4
))
|
((
rotation
+
i
)
&
3
)])
{
...
...
@@ -7466,12 +7476,14 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
}
}
// now rotation is the correct one, update laserPointer.{swapUV,flipU,flipV};
laserPointer
.
swapUV
=
rotToFlips
(
rotation
)[
0
];
laserPointer
.
flipU
=
rotToFlips
(
rotation
)[
1
];
laserPointer
.
flipV
=
rotToFlips
(
rotation
)[
2
];
if
(
laserPointer
!=
null
){
laserPointer
.
swapUV
=
rotToFlips
(
rotation
)[
0
];
laserPointer
.
flipU
=
rotToFlips
(
rotation
)[
1
];
laserPointer
.
flipV
=
rotToFlips
(
rotation
)[
2
];
}
//calculate shift
int
[]
uvShift
=
dfltShifts
[
rotation
].
clone
();
//{0,0};
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
{
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
{
// laserPointer -> uv=={}
uvShift
[
0
]=(
int
)
Math
.
round
(
uv
[
i
][
0
]-
(
rotations
[
rotation
][
0
][
0
]*
laserPointer
.
laserUVMap
[
i
][
0
]+
rotations
[
rotation
][
0
][
1
]*
laserPointer
.
laserUVMap
[
i
][
1
]));
...
...
@@ -7480,6 +7492,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
rotations
[
rotation
][
1
][
1
]*
laserPointer
.
laserUVMap
[
i
][
1
]));
break
;
}
// Hinted shift will only be used if no laser pointers are available, otherwise - only verify/warn
if
(
hintTranslateUV
!=
null
)
{
// if ((uv.length==0) || (numPointesLeft==0)){
...
...
@@ -7549,7 +7562,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
int
numBad
=
0
;
double
[]
distUV
=
new
double
[
2
];
double
dist
;
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
{
for
(
int
i
=
0
;
i
<
uv
.
length
;
i
++)
if
(
uv
[
i
]!=
null
)
{
//laserPointer == null > uv={}
// Verify that laser spots are inside specified distance from the cell centers
distUV
[
0
]=
reReMap
[
0
][
0
]*
uv
[
i
][
0
]+
reReMap
[
0
][
1
]*
uv
[
i
][
1
]+
reReMap
[
0
][
2
]-
laserPointer
.
laserUVMap
[
i
][
0
];
distUV
[
1
]=
reReMap
[
1
][
0
]*
uv
[
i
][
0
]+
reReMap
[
1
][
1
]*
uv
[
i
][
1
]+
reReMap
[
1
][
2
]-
laserPointer
.
laserUVMap
[
i
][
1
];
...
...
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