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
c561f2e0
Commit
c561f2e0
authored
Nov 20, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug - simulatePatternFullPattern and extractSimulationPattern were
not thread safe
parent
a2023862
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
240 additions
and
118 deletions
+240
-118
EyesisAberrations.java
src/main/java/EyesisAberrations.java
+8
-2
MatchSimulatedPattern.java
src/main/java/MatchSimulatedPattern.java
+174
-93
SimulationPattern.java
src/main/java/SimulationPattern.java
+58
-23
No files found.
src/main/java/EyesisAberrations.java
View file @
c561f2e0
...
@@ -2594,6 +2594,8 @@ public class EyesisAberrations {
...
@@ -2594,6 +2594,8 @@ public class EyesisAberrations {
double
[][]
dbgSimPix
=
null
;
double
[][]
dbgSimPix
=
null
;
double
[]
localBarray
;
if
((
simArray
==
null
)
||
(
psfParameters
.
approximateGrid
)){
// just for testing
if
((
simArray
==
null
)
||
(
psfParameters
.
approximateGrid
)){
// just for testing
/* Calculate pattern parameters, including distortion */
/* Calculate pattern parameters, including distortion */
if
(
matchSimulatedPattern
.
PATTERN_GRID
==
null
)
{
if
(
matchSimulatedPattern
.
PATTERN_GRID
==
null
)
{
...
@@ -2613,7 +2615,8 @@ public class EyesisAberrations {
...
@@ -2613,7 +2615,8 @@ public class EyesisAberrations {
" W1_phase="
+
IJ
.
d2s
(
distortedPattern
[
1
][
2
],
2
));
" W1_phase="
+
IJ
.
d2s
(
distortedPattern
[
1
][
2
],
2
));
}
}
simulationPattern
.
simulatePatternFullPattern
(
// simulationPattern.simulatePatternFullPattern( // Not thread safe!
localBarray
=
simulationPattern
.
simulatePatternFullPatternSafe
(
distortedPattern
[
0
][
0
],
distortedPattern
[
0
][
0
],
distortedPattern
[
0
][
1
],
distortedPattern
[
0
][
1
],
distortedPattern
[
0
][
2
],
distortedPattern
[
0
][
2
],
...
@@ -2655,7 +2658,8 @@ public class EyesisAberrations {
...
@@ -2655,7 +2658,8 @@ public class EyesisAberrations {
wVectors
[
0
][
1
]=
distPatPars
[
0
][
1
];
wVectors
[
0
][
1
]=
distPatPars
[
0
][
1
];
wVectors
[
1
][
0
]=
distPatPars
[
1
][
0
];
wVectors
[
1
][
0
]=
distPatPars
[
1
][
0
];
wVectors
[
1
][
1
]=
distPatPars
[
1
][
1
];
wVectors
[
1
][
1
]=
distPatPars
[
1
][
1
];
simulationPattern
.
simulatePatternFullPattern
(
// simulationPattern.simulatePatternFullPattern( // Not thread safe!
localBarray
=
simulationPattern
.
simulatePatternFullPatternSafe
(
wVectors
[
0
][
0
],
wVectors
[
0
][
0
],
wVectors
[
0
][
1
],
wVectors
[
0
][
1
],
phases
[
0
],
phases
[
0
],
...
@@ -2667,7 +2671,9 @@ public class EyesisAberrations {
...
@@ -2667,7 +2671,9 @@ public class EyesisAberrations {
fft_size
,
fft_size
,
simulParameters
.
center_for_g2
);
simulParameters
.
center_for_g2
);
}
}
// simul_pixels= simulationPattern.extractSimulPatterns (
simul_pixels
=
simulationPattern
.
extractSimulPatterns
(
simul_pixels
=
simulationPattern
.
extractSimulPatterns
(
localBarray
,
// this version is thread safe
simulParameters
,
simulParameters
,
subpixel
,
// subdivide pixels
subpixel
,
// subdivide pixels
fft_size
*
subpixel
,
// number of Bayer cells in width of the square selection (half number of pixels)
fft_size
*
subpixel
,
// number of Bayer cells in width of the square selection (half number of pixels)
...
...
src/main/java/MatchSimulatedPattern.java
View file @
c561f2e0
This diff is collapsed.
Click to expand it.
src/main/java/SimulationPattern.java
View file @
c561f2e0
...
@@ -154,12 +154,36 @@ public class SimulationPattern {
...
@@ -154,12 +154,36 @@ public class SimulationPattern {
int
subdiv
,
int
subdiv
,
int
size
,
int
size
,
boolean
center_for_g2
)
{
boolean
center_for_g2
)
{
this
.
barray
=
simulatePatternFullPatternSafe
(
freqX1
,
freqY1
,
phase1
,
freqX2
,
freqY2
,
phase2
,
corr
,
subdiv
,
size
,
center_for_g2
);
}
public
double
[]
simulatePatternFullPatternSafe
(
double
freqX1
,
double
freqY1
,
double
phase1
,
double
freqX2
,
double
freqY2
,
double
phase2
,
double
[]
corr
,
int
subdiv
,
int
size
,
boolean
center_for_g2
)
{
int
patternSize
=
(
this
.
bPattern
!=
null
)?((
int
)
Math
.
sqrt
(
this
.
bPattern
.
length
)):
0
;
int
patternSize
=
(
this
.
bPattern
!=
null
)?((
int
)
Math
.
sqrt
(
this
.
bPattern
.
length
)):
0
;
double
twicePatternSize
=
2
*
patternSize
;
double
twicePatternSize
=
2
*
patternSize
;
int
i
,
j
;
int
i
,
j
;
int
fullSize
=
subdiv
*(
size
+
4
)*
2
;
int
fullSize
=
subdiv
*(
size
+
4
)*
2
;
// this.barray=new double [fullSize][fullSize];
double
[]
localBarray
=
new
double
[
fullSize
*
fullSize
];
this
.
barray
=
new
double
[
fullSize
*
fullSize
];
double
xl
,
yl
;
//,x,y;//,p1,p2;
double
xl
,
yl
;
//,x,y;//,p1,p2;
...
@@ -212,8 +236,7 @@ public class SimulationPattern {
...
@@ -212,8 +236,7 @@ public class SimulationPattern {
uv
[
1
]-=
0.5
;
uv
[
1
]-=
0.5
;
}
}
if
(
this
.
bPattern
==
null
)
{
if
(
this
.
bPattern
==
null
)
{
/// this.barray[i][j]=invert?0.0:1.0; //!invert;
localBarray
[
i
*
fullSize
+
j
]=
invert
?
0.0
:
1.0
;
//!invert;
this
.
barray
[
i
*
fullSize
+
j
]=
invert
?
0.0
:
1.0
;
//!invert;
}
else
{
}
else
{
iu
=
(
int
)
Math
.
round
(
uv
[
0
]*
twicePatternSize
);
iu
=
(
int
)
Math
.
round
(
uv
[
0
]*
twicePatternSize
);
iv
=
(
int
)
Math
.
round
(
uv
[
1
]*
twicePatternSize
);
iv
=
(
int
)
Math
.
round
(
uv
[
1
]*
twicePatternSize
);
...
@@ -225,19 +248,18 @@ public class SimulationPattern {
...
@@ -225,19 +248,18 @@ public class SimulationPattern {
invert
=!
invert
;
invert
=!
invert
;
iv
=(
iv
+
patternSize
)%
patternSize
;
iv
=(
iv
+
patternSize
)%
patternSize
;
}
}
// this.barray[i][j]=invert ^ this.bPattern[iv*patternSize + iu];
localBarray
[
i
*
fullSize
+
j
]=
invert
?(
1.0
-
this
.
bPattern
[
iv
*
patternSize
+
iu
]):
this
.
bPattern
[
iv
*
patternSize
+
iu
];
/// this.barray[i][j]=invert?(1.0-this.bPattern[iv*patternSize + iu]): this.bPattern[iv*patternSize + iu];
this
.
barray
[
i
*
fullSize
+
j
]=
invert
?(
1.0
-
this
.
bPattern
[
iv
*
patternSize
+
iu
]):
this
.
bPattern
[
iv
*
patternSize
+
iu
];
}
}
}
}
}
}
// Blur barray pattern if sigma >0
// Blur barray pattern if sigma >0
if
(
this
.
barraySigma
>
0
)
{
if
(
this
.
barraySigma
>
0
)
{
double
sigma
=
this
.
barraySigma
*
subdiv
;
//*/ 2?
double
sigma
=
this
.
barraySigma
*
subdiv
;
//*/ 2?
if
(
this
.
debugLevel
>
3
)
SDFA_INSTANCE
.
showArrays
(
this
.
barray
,
"b
array"
);
if
(
this
.
debugLevel
>
3
)
SDFA_INSTANCE
.
showArrays
(
localBarray
,
"localB
array"
);
this
.
gb
.
blurDouble
(
this
.
b
array
,
fullSize
,
fullSize
,
sigma
,
sigma
,
0.01
);
this
.
gb
.
blurDouble
(
localB
array
,
fullSize
,
fullSize
,
sigma
,
sigma
,
0.01
);
if
(
this
.
debugLevel
>
3
)
SDFA_INSTANCE
.
showArrays
(
this
.
barray
,
"b
array-blured"
);
if
(
this
.
debugLevel
>
3
)
SDFA_INSTANCE
.
showArrays
(
localBarray
,
"localB
array-blured"
);
}
}
return
localBarray
;
}
}
/* ======================================================================== */
/* ======================================================================== */
public
double
[]
recursiveFillPixels
(
// invert pattern in the caller, return signed value (-1..1 - pattern is 0..1)
public
double
[]
recursiveFillPixels
(
// invert pattern in the caller, return signed value (-1..1 - pattern is 0..1)
...
@@ -851,6 +873,22 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
...
@@ -851,6 +873,22 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
int
size
,
// number of Bayer cells in width of the square selection (half number of pixels)
int
size
,
// number of Bayer cells in width of the square selection (half number of pixels)
double
x0
,
// selection center, X (in pixels)
double
x0
,
// selection center, X (in pixels)
double
y0
)
{
double
y0
)
{
return
extractSimulPatterns
(
this
.
barray
,
simulParameters
,
outSubdiv
,
// subdivide output pixels
size
,
// number of Bayer cells in width of the square selection (half number of pixels)
x0
,
// selection center, X (in pixels)
y0
);
}
public
double
[][]
extractSimulPatterns
(
double
[]
localbArray
,
SimulParameters
simulParameters
,
int
outSubdiv
,
// subdivide output pixels
int
size
,
// number of Bayer cells in width of the square selection (half number of pixels)
double
x0
,
// selection center, X (in pixels)
double
y0
)
{
int
sampleWidth
=(
int
)
(
Math
.
sqrt
(
simulParameters
.
fill
)*
simulParameters
.
subdiv
);
int
sampleWidth
=(
int
)
(
Math
.
sqrt
(
simulParameters
.
fill
)*
simulParameters
.
subdiv
);
int
sampleN
=
sampleWidth
*
sampleWidth
;
int
sampleN
=
sampleWidth
*
sampleWidth
;
if
(
sampleWidth
<
1
)
sampleWidth
=
1
;
if
(
sampleWidth
<
1
)
sampleWidth
=
1
;
...
@@ -858,8 +896,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
...
@@ -858,8 +896,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
double
sampleAverage
=
0.5
*
sampleN
;
double
sampleAverage
=
0.5
*
sampleN
;
int
n
,
i
,
j
;
int
n
,
i
,
j
;
// int fullSize=this.barray.length;
int
fullSize
=(
int
)
Math
.
sqrt
(
localbArray
.
length
);
int
fullSize
=(
int
)
Math
.
sqrt
(
this
.
barray
.
length
);
double
[][]
simul_pixels
=
new
double
[
5
][
size
*
size
];
double
[][]
simul_pixels
=
new
double
[
5
][
size
*
size
];
int
ix
,
iy
,
iy0
,
ix0
,
px
,
py
;
int
ix
,
iy
,
iy0
,
ix0
,
px
,
py
;
double
bx
,
by
;
double
bx
,
by
;
...
@@ -876,9 +913,8 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
...
@@ -876,9 +913,8 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
ix0
=(
fullSize
/
2
)
+
(
int
)
((-
span
+
x0
+
bx
+
0.5
+
2.0
*
ix
/
outSubdiv
)*
simulParameters
.
subdiv
);
ix0
=(
fullSize
/
2
)
+
(
int
)
((-
span
+
x0
+
bx
+
0.5
+
2.0
*
ix
/
outSubdiv
)*
simulParameters
.
subdiv
);
s
=
0.0
;
s
=
0.0
;
for
(
py
=
iy0
+
sampLow
;
py
<
iy0
+
sampHigh
;
py
++)
for
(
px
=
ix0
+
sampLow
;
px
<
ix0
+
sampHigh
;
px
++)
{
for
(
py
=
iy0
+
sampLow
;
py
<
iy0
+
sampHigh
;
py
++)
for
(
px
=
ix0
+
sampLow
;
px
<
ix0
+
sampHigh
;
px
++)
{
/// s+=this.barray[py][px];
try
{
try
{
s
+=
this
.
ba
rray
[
py
*
fullSize
+
px
];
s
+=
localbA
rray
[
py
*
fullSize
+
px
];
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
System
.
out
.
println
(
"Bug in extractSimulPatterns(): px="
+
px
+
" py="
+
py
+
" fullSize="
+
fullSize
+
" size="
+
size
+
" x0="
+
x0
+
" y0="
+
y0
);
System
.
out
.
println
(
"Bug in extractSimulPatterns(): px="
+
px
+
" py="
+
py
+
" fullSize="
+
fullSize
+
" size="
+
size
+
" x0="
+
x0
+
" y0="
+
y0
);
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -901,8 +937,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
...
@@ -901,8 +937,7 @@ Cv=(Cy*x-Cx*y)+(-Cy*Dx+Cx*Dy)
ix0
=(
fullSize
/
2
)
+
(
int
)
((-
span
+
x0
+
bx
+
0.5
+
1.0
*(
iy
+
ix
)/
outSubdiv
)*
simulParameters
.
subdiv
);
ix0
=(
fullSize
/
2
)
+
(
int
)
((-
span
+
x0
+
bx
+
0.5
+
1.0
*(
iy
+
ix
)/
outSubdiv
)*
simulParameters
.
subdiv
);
s
=
0.0
;
s
=
0.0
;
for
(
py
=
iy0
+
sampLow
;
py
<
iy0
+
sampHigh
;
py
++)
for
(
px
=
ix0
+
sampLow
;
px
<
ix0
+
sampHigh
;
px
++)
{
for
(
py
=
iy0
+
sampLow
;
py
<
iy0
+
sampHigh
;
py
++)
for
(
px
=
ix0
+
sampLow
;
px
<
ix0
+
sampHigh
;
px
++)
{
/// s+=this.barray[py][px];
s
+=
localbArray
[
py
*
fullSize
+
px
];
s
+=
this
.
barray
[
py
*
fullSize
+
px
];
}
}
simul_pixels
[
n
][
iy
*
size
+
ix
]=
(
s
-
sampleAverage
)/
sampleAverage
;
simul_pixels
[
n
][
iy
*
size
+
ix
]=
(
s
-
sampleAverage
)/
sampleAverage
;
}
}
...
...
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