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
ec11a1dd
Commit
ec11a1dd
authored
Dec 13, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs in hinted match
parent
2c684497
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
10 deletions
+54
-10
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+2
-2
MatchSimulatedPattern.java
src/main/java/MatchSimulatedPattern.java
+52
-8
No files found.
src/main/java/Aberration_Calibration.java
View file @
ec11a1dd
...
...
@@ -6193,7 +6193,7 @@ if (MORE_BUTTONS) {
return
;
}
GenericDialog
gd
=
new
GenericDialog
(
"Parameters of the filter by predicted grid"
);
gd
.
addNumericField
(
"Mismatch tolerance of match between the predicted and acquired grid"
,
5.0
,
1
,
4
,
"pix
"
);
gd
.
addNumericField
(
"Mismatch tolerance of match between the predicted and acquired grid"
,
0.5
,
1
,
4
,
"fraction of grid half-period
"
);
gd
.
addCheckbox
(
"Calibrate by translation (false - orientation only)"
,
true
);
gd
.
addCheckbox
(
"Process all images (false - only not yet enabled)"
,
false
);
gd
.
addCheckbox
(
"Ignore laser pointers"
,
false
);
...
...
@@ -6272,7 +6272,7 @@ if (MORE_BUTTONS) {
gd
=
new
GenericDialog
(
"Image set # "
+
imageSetNumber
+
" re-calibration without laser pointers"
);
gd
.
addMessage
(
"Strategy 0 should have all parameters but 2 goniometer axes disabled"
);
gd
.
addMessage
(
"Imgages belonging to the set will be selected, possible to check with \"Remove Outlayers\" for strategy 0"
);
gd
.
addNumericField
(
"Mismatch tolerance of match between the predicted and acquired grid"
,
hintGridTolerance
,
1
,
4
,
"
pix
"
);
gd
.
addNumericField
(
"Mismatch tolerance of match between the predicted and acquired grid"
,
hintGridTolerance
,
1
,
4
,
"
fraction of grid half-period
"
);
gd
.
addCheckbox
(
"Ignore laser pointers"
,
ignoreLaserPointers
);
gd
.
addNumericField
(
"Image set tilt"
,
tiltCenter
,
2
,
6
,
"degrees"
);
gd
.
addNumericField
(
"Image set axial"
,
axialCenter
,
2
,
6
,
"degrees"
);
...
...
src/main/java/MatchSimulatedPattern.java
View file @
ec11a1dd
...
...
@@ -6625,15 +6625,16 @@ public class MatchSimulatedPattern {
public
double
[][]
calcGridMatchMatrix
(
double
[][][]
hintGrid
,
double
searchAround
){
double
[][][]
measuredUV
=
mapEstimatedToMeasured
(
hintGrid
,
searchAround
);
if
(
this
.
debugLevel
>
2
){
double
[][]
pixels
=
new
double
[
7
][
measuredUV
.
length
*
measuredUV
[
0
].
length
];
double
[][]
pixels
=
new
double
[
9
][
measuredUV
.
length
*
measuredUV
[
0
].
length
];
int
index
=
0
;
String
[]
titles
={
"grid-U"
,
"grid-V"
,
"contrast"
,
"hint-X"
,
"hint-Y"
,
"hint-U"
,
"hint-V"
};
String
[]
titles
={
"grid-U"
,
"grid-V"
,
"contrast"
,
"hint-X"
,
"hint-Y"
,
"hint-U"
,
"hint-V"
,
"grid-hint-U"
,
"grid-hint-V"
};
// last 2 only valid for rotation==0
for
(
int
v
=
0
;
v
<
measuredUV
.
length
;
v
++)
for
(
int
u
=
0
;
u
<
measuredUV
[
v
].
length
;
u
++){
if
(
measuredUV
[
v
][
u
]!=
null
){
for
(
int
i
=
0
;
i
<
3
;
i
++)
pixels
[
i
][
index
]=
measuredUV
[
v
][
u
][
i
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
pixels
[
i
+
3
][
index
]=
hintGrid
[
v
][
u
][
i
];
for
(
int
i
=
0
;
i
<
2
;
i
++)
pixels
[
i
+
7
][
index
]=
measuredUV
[
v
][
u
][
i
]-
hintGrid
[
v
][
u
][
i
+
2
];
}
else
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
pixels
[
i
][
index
]=
Double
.
NaN
;
for
(
int
i
=
0
;
i
<
9
;
i
++)
pixels
[
i
][
index
]=
Double
.
NaN
;
}
index
++;
}
...
...
@@ -6656,14 +6657,56 @@ public class MatchSimulatedPattern {
data
[
index
][
2
][
0
]=
measuredUV
[
v
][
u
][
2
];
// contrast
index
++;
}
if
(
this
.
debugLevel
>
0
)
System
.
out
.
println
(
"calcGridMatchMatrix(), data.length="
+
data
.
length
+
" measuredUV.length="
+
measuredUV
.
length
+
if
(
this
.
debugLevel
>
0
)
{
System
.
out
.
println
(
"calcGridMatchMatrix(), data.length="
+
data
.
length
+
" measuredUV.length="
+
measuredUV
.
length
+
((
measuredUV
.
length
>
0
)?(
", measuredUV[0].length="
+
measuredUV
[
0
].
length
):
""
));
if
(
this
.
debugLevel
>
3
)
for
(
index
=
0
;
index
<
data
.
length
;
index
++){
System
.
out
.
println
(
data
[
index
][
0
][
0
]+
","
+
data
[
index
][
0
][
1
]+
","
+
data
[
index
][
1
][
0
]+
","
+
data
[
index
][
1
][
1
]+
","
+
data
[
index
][
2
][
0
]);
}
}
// int gridRotation=-1; //undefined
if
(
data
.
length
<
3
){
// if (this.debugLevel>0) System.out.println("calcGridMatchMatrix(), data.length="+data.length+" measuredUV.length="+measuredUV.length+
// ((measuredUV.length>0)?(", measuredUV[0].length="+measuredUV[0].length):""));
//
/
if (this.debugLevel>0) System.out.println("calcGridMatchMatrix(), data.length="+data.length+" measuredUV.length="+measuredUV.length+
//
/
((measuredUV.length>0)?(", measuredUV[0].length="+measuredUV[0].length):""));
return
null
;
}
double
[][]
coeff
=
new
PolynomialApproximation
(
this
.
debugLevel
).
quadraticApproximation
(
data
,
true
);
if
(
coeff
!=
null
)
{
// gridRotation=matrixToRot(coeff);
int
rot
=
matrixToRot
(
coeff
);
boolean
[]
flips
=
rotToFlips
(
rot
);
double
[][]
aI
={{
1
,
0
},{
0
,
1
}};
double
[][]
aSwap
=
{{
0
,
1
},{
1
,
0
}};
double
[][]
aFlipU
={{-
1
,
0
},{
0
,
1
}};
double
[][]
aFlipV
={{
1
,
0
},{
0
,-
1
}};
Matrix
M
=
new
Matrix
(
aI
);
if
(
flips
[
0
])
M
=
M
.
times
((
new
Matrix
(
aSwap
)));
if
(
flips
[
1
])
M
=
M
.
times
((
new
Matrix
(
aFlipU
)));
if
(
flips
[
2
])
M
=
M
.
times
((
new
Matrix
(
aFlipV
)));
// now M reconstructs coeff
double
[][]
aM
=
M
.
getArray
();
double
SMU
=
0.0
,
SMV
=
0.0
,
SW
=
0.0
;
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++){
SMU
+=
data
[
i
][
2
][
0
]*(
data
[
i
][
1
][
0
]-(
aM
[
0
][
0
]*
data
[
i
][
0
][
0
]+
aM
[
0
][
1
]*
data
[
i
][
0
][
1
]));
SMV
+=
data
[
i
][
2
][
0
]*(
data
[
i
][
1
][
1
]-(
aM
[
1
][
0
]*
data
[
i
][
0
][
0
]+
aM
[
1
][
1
]*
data
[
i
][
0
][
1
]));
SW
+=
data
[
i
][
2
][
0
];
}
SMU
/=
SW
;
SMV
/=
SW
;
if
(
this
.
debugLevel
>
0
)
{
System
.
out
.
println
(
"coeff[0][0]="
+
coeff
[
0
][
0
]+
" coeff[0][1]="
+
coeff
[
0
][
1
]+
" coeff[0][2]="
+
coeff
[
0
][
2
]);
System
.
out
.
println
(
"coeff[1][0]="
+
coeff
[
1
][
0
]+
" coeff[1][1]="
+
coeff
[
1
][
1
]+
" coeff[1][2]="
+
coeff
[
1
][
2
]);
System
.
out
.
println
(
"aM[0][0]="
+
aM
[
0
][
0
]+
" aM[0][1]="
+
aM
[
0
][
1
]+
" SMU="
+
SMU
);
System
.
out
.
println
(
"aM[1][0]="
+
aM
[
1
][
0
]+
" aM[1][1]="
+
aM
[
1
][
1
]+
" SMV="
+
SMV
);
}
coeff
[
0
][
0
]=
aM
[
0
][
0
];
coeff
[
0
][
1
]=
aM
[
0
][
1
];
coeff
[
1
][
0
]=
aM
[
1
][
0
];
coeff
[
1
][
1
]=
aM
[
1
][
1
];
coeff
[
0
][
2
]=
SMU
;
coeff
[
1
][
2
]=
SMV
;
}
return
coeff
;
}
public
int
matrixToRot
(
double
[][]
coeff
){
...
...
@@ -6744,7 +6787,7 @@ public class MatchSimulatedPattern {
}
return
worst
;
}
public
double
worstGridMatchTranslate
(
double
[][]
coeff
){
public
double
worstGridMatchTranslate
(
double
[][]
coeff
){
// in grids half-periods, not pixels!
int
[][]
iCoeff
=
gridMatrixApproximate
(
coeff
);
double
worst
=
0
;
for
(
int
i
=
0
;
i
<
2
;
i
++){
...
...
@@ -7117,6 +7160,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
int
[]
iGridTranslateUV
=
null
;
// translate UV grid by these integer numbers
if
(
hintGrid
!=
null
){
gridMatchCoeff
=
calcGridMatchMatrix
(
hintGrid
,
searchAround
);
// now already rounds rotate and re-replaces gridMatchCoeff with approximated, refines gridMatchCoeff[0][2] and gridMatchCoeff[1][2]
if
(
gridMatchCoeff
!=
null
)
{
gridRotation
=
matrixToRot
(
gridMatchCoeff
);
this
.
debugLevel
=
global_debug_level
;
...
...
@@ -7132,7 +7176,7 @@ y=xy0[1] + dU*deltaUV[0]*(xy1[1]-xy0[1])+dV*deltaUV[1]*(xy2[1]-xy0[1])
}
// hintGridTolerance==0 - do not try to determine shift from the hint (not reliable yet)
if
(
hintGridTolerance
>
0
)
{
if
(
worstGridMatchTranslate
(
gridMatchCoeff
)<=
hintGridTolerance
){
if
(
worstGridMatchTranslate
(
gridMatchCoeff
)<=
hintGridTolerance
){
// convert to pixels from halfperiods (or just chnage definition of hintGridTolerance)
if
(
global_debug_level
>
1
)
System
.
out
.
println
(
"worstGridMatchTranslate(gridMatchCoeff)= "
+
worstGridMatchTranslate
(
gridMatchCoeff
)+
", hintGridTolerance="
+
hintGridTolerance
);
iGridTranslateUV
=
new
int
[
2
];
iGridTranslateUV
[
0
]=
iGridMatchCoeff
[
0
][
2
];
...
...
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