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
73b9d03b
Commit
73b9d03b
authored
Apr 25, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redesigning shell extraction
parent
c5a866f4
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1180 additions
and
301 deletions
+1180
-301
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+38
-5
SuperTiles.java
src/main/java/SuperTiles.java
+823
-230
TilePlanes.java
src/main/java/TilePlanes.java
+98
-43
TileProcessor.java
src/main/java/TileProcessor.java
+104
-23
TileSurface.java
src/main/java/TileSurface.java
+117
-0
No files found.
src/main/java/EyesisCorrectionParameters.java
View file @
73b9d03b
...
...
@@ -2155,6 +2155,13 @@ public class EyesisCorrectionParameters {
public
boolean
plPreferDisparity
=
false
;
// Always start with disparity-most axis (false - lowest eigenvalue)
public
double
plDispNorm
=
3.0
;
// Normalize disparities to the average if above (now only for eigenvalue comparison)
public
double
plBlurBinVert
=
1.2
;
// Blur disparity histograms for constant disparity clusters by this sigma (in bins)
public
double
plBlurBinHor
=
0.8
;
// Blur disparity histograms for horizontal clusters by this sigma (in bins)
public
double
plMaxDiffVert
=
0.4
;
// Maximal normalized disparity difference when initially assigning to vertical plane
public
double
plMaxDiffHor
=
0.2
;
// Maximal normalized disparity difference when initially assigning to horizontal plane
public
int
plInitPasses
=
3
;
// Number of initial passes to assign tiles to vert (const disparity) and hor planes
public
int
plMinPoints
=
5
;
// Minimal number of points for plane detection
public
double
plTargetEigen
=
0.1
;
// Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below
public
double
plFractOutliers
=
0.3
;
// Maximal fraction of outliers to remove
...
...
@@ -2453,6 +2460,13 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"plPreferDisparity"
,
this
.
plPreferDisparity
+
""
);
properties
.
setProperty
(
prefix
+
"plDispNorm"
,
this
.
plDispNorm
+
""
);
properties
.
setProperty
(
prefix
+
"plBlurBinVert"
,
this
.
plBlurBinVert
+
""
);
properties
.
setProperty
(
prefix
+
"plBlurBinHor"
,
this
.
plBlurBinHor
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxDiffVert"
,
this
.
plMaxDiffVert
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxDiffHor"
,
this
.
plMaxDiffHor
+
""
);
properties
.
setProperty
(
prefix
+
"plInitPasses"
,
this
.
plInitPasses
+
""
);
properties
.
setProperty
(
prefix
+
"plMinPoints"
,
this
.
plMinPoints
+
""
);
properties
.
setProperty
(
prefix
+
"plTargetEigen"
,
this
.
plTargetEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plFractOutliers"
,
this
.
plFractOutliers
+
""
);
...
...
@@ -2463,10 +2477,8 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"plWorstWorsening"
,
this
.
plWorstWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakWorsening"
,
this
.
plWeakWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plMutualOnly"
,
this
.
plMutualOnly
+
""
);
properties
.
setProperty
(
prefix
+
"plFillSquares"
,
this
.
plFillSquares
+
""
);
properties
.
setProperty
(
prefix
+
"plCutCorners"
,
this
.
plCutCorners
+
""
);
properties
.
setProperty
(
prefix
+
"plPull"
,
this
.
plPull
+
""
);
properties
.
setProperty
(
prefix
+
"plNormPow"
,
this
.
plNormPow
+
""
);
properties
.
setProperty
(
prefix
+
"plIterations"
,
this
.
plIterations
+
""
);
...
...
@@ -2738,6 +2750,13 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"plPreferDisparity"
)!=
null
)
this
.
plPreferDisparity
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plPreferDisparity"
));
if
(
properties
.
getProperty
(
prefix
+
"plDispNorm"
)!=
null
)
this
.
plDispNorm
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plDispNorm"
));
if
(
properties
.
getProperty
(
prefix
+
"plBlurBinVert"
)!=
null
)
this
.
plBlurBinVert
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plBlurBinVert"
));
if
(
properties
.
getProperty
(
prefix
+
"plBlurBinHor"
)!=
null
)
this
.
plBlurBinHor
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plBlurBinHor"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxDiffVert"
)!=
null
)
this
.
plMaxDiffVert
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxDiffVert"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxDiffHor"
)!=
null
)
this
.
plMaxDiffHor
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxDiffHor"
));
if
(
properties
.
getProperty
(
prefix
+
"plInitPasses"
)!=
null
)
this
.
plInitPasses
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"plInitPasses"
));
if
(
properties
.
getProperty
(
prefix
+
"plMinPoints"
)!=
null
)
this
.
plMinPoints
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"plMinPoints"
));
if
(
properties
.
getProperty
(
prefix
+
"plTargetEigen"
)!=
null
)
this
.
plTargetEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plTargetEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plFractOutliers"
)!=
null
)
this
.
plFractOutliers
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plFractOutliers"
));
...
...
@@ -3047,6 +3066,13 @@ public class EyesisCorrectionParameters {
gd
.
addMessage
(
"--- Planes detection ---"
);
gd
.
addCheckbox
(
"Always start with disparity-most axis (false - lowest eigenvalue)"
,
this
.
plPreferDisparity
);
gd
.
addNumericField
(
"Normalize disparities to the average if above"
,
this
.
plDispNorm
,
6
);
gd
.
addNumericField
(
"Blur disparity histograms for constant disparity clusters by this sigma (in bins)"
,
this
.
plBlurBinVert
,
6
);
gd
.
addNumericField
(
"Blur disparity histograms for horizontal clusters by this sigma (in bins)"
,
this
.
plBlurBinHor
,
6
);
gd
.
addNumericField
(
"Maximal normalized disparity difference when initially assigning to vertical plane"
,
this
.
plMaxDiffVert
,
6
);
gd
.
addNumericField
(
"Maximal normalized disparity difference when initially assigning to horizontal plane"
,
this
.
plMaxDiffHor
,
6
);
gd
.
addNumericField
(
"Number of initial passes to assign tiles to vert (const disparity) and hor planes"
,
this
.
plInitPasses
,
0
);
gd
.
addNumericField
(
"Minimal number of points for plane detection"
,
this
.
plMinPoints
,
0
);
gd
.
addNumericField
(
"Remove outliers until main axis eigenvalue (possibly scaled by plDispNorm) gets below"
,
this
.
plTargetEigen
,
6
);
gd
.
addNumericField
(
"Maximal fraction of outliers to remove"
,
this
.
plFractOutliers
,
6
);
...
...
@@ -3340,6 +3366,13 @@ public class EyesisCorrectionParameters {
this
.
plPreferDisparity
=
gd
.
getNextBoolean
();
this
.
plDispNorm
=
gd
.
getNextNumber
();
this
.
plBlurBinVert
=
gd
.
getNextNumber
();
this
.
plBlurBinHor
=
gd
.
getNextNumber
();
this
.
plMaxDiffVert
=
gd
.
getNextNumber
();
this
.
plMaxDiffHor
=
gd
.
getNextNumber
();
this
.
plInitPasses
=
(
int
)
gd
.
getNextNumber
();
this
.
plMinPoints
=
(
int
)
gd
.
getNextNumber
();
this
.
plTargetEigen
=
gd
.
getNextNumber
();
this
.
plFractOutliers
=
gd
.
getNextNumber
();
...
...
src/main/java/SuperTiles.java
View file @
73b9d03b
This diff is collapsed.
Click to expand it.
src/main/java/TilePlanes.java
View file @
73b9d03b
...
...
@@ -166,6 +166,10 @@ public class TilePlanes {
return
this
.
measuredSelection
[
nl
];
}
public
boolean
[][]
getMeasSelection
(){
return
this
.
measuredSelection
;
}
public
MeasuredLayers
getMeasuredLayers
()
{
...
...
@@ -1006,10 +1010,8 @@ public class TilePlanes {
debugLevel
=
20
;
}
// if (eig.getD().get(0, 0) == 0.0){
// debugLevel = 10;
// }
if
(
debugLevel
>
0
){
if
(
debugLevel
>
3
){
// if (debugLevel > 0){
System
.
out
.
println
(
"getCovar(): sw = "
+
sw
+
", swz = "
+
swz
+
", swx = "
+
swx
+
", swy = "
+
swy
+
", covar.det() = "
+
covar
.
det
());
System
.
out
.
println
(
"getCovar(): covarianvce matrix, number of used points:"
+
num_tiles
);
covar
.
print
(
10
,
6
);
// w,d
...
...
@@ -1022,15 +1024,6 @@ public class TilePlanes {
return
null
;
// testing with zero eigenvalue
// Problem with zero eigenvalue is with derivatives and coordinate conversion
}
/*
double [][][] rslt = {
eig.getD().getArray(),
eig.getV().getArray(),
{
{sw,kz,numPoints},
{swz, swx, swy}}};
return rslt;
*/
double
[][]
eig_val
=
eig
.
getD
().
getArray
();
// rslt[0];
double
[][]
eig_vect
=
eig
.
getV
().
getArray
();
// rslt[1];
...
...
@@ -1390,10 +1383,76 @@ public class TilePlanes {
return
plane
;
}
/**
* Get disparity values for the tiles of this overlapping supertile as [2*superTileSize * 2*superTileSize] array
* and weights combined from provided window function, optional selection and using ellipsoid projection on the
* px, py plane (constant disparity
* @param window null or window function as [2*superTileSize * 2*superTileSize] array
* @param use_sel use plane selection (this.sel_mask) to select only some part of the plane
* @param scale_projection use plane ellipsoid projection for weight: 0 - do not use, > 0 linearly scale ellipsoid
* @return a pair of ar5rays {disparity, strength}, each [2*superTileSize * 2*superTileSize]
*/
public
double
[][]
getDoublePlaneDisparityStrength
(
double
[]
window
,
boolean
use_sel
,
double
scale_projection
,
int
debugLevel
)
{
double
[][]
disp_strength
=
new
double
[
2
][
4
*
superTileSize
*
superTileSize
];
int
indx
=
0
;
double
[]
normal
=
getVector
();
double
[]
zxy
=
getZxy
();
// {disparity, x center in pixels, y center in pixels (relative to a supertile center)
double
weight
=
getWeight
();
double
k_gauss
=
0
;
Matrix
val2d
=
null
,
vect2d
=
null
;
if
(
scale_projection
>
0.0
){
double
[]
vals3d
=
getValues
();
double
[][]
vectors3d
=
getVectors
();
double
[][]
acovar
=
new
double
[
2
][
2
];
for
(
int
i
=
0
;
i
<
2
;
i
++){
for
(
int
j
=
i
;
j
<
2
;
j
++){
acovar
[
i
][
j
]
=
0.0
;
for
(
int
k
=
0
;
k
<
3
;
k
++){
acovar
[
i
][
j
]
+=
vals3d
[
k
]
*
vectors3d
[
k
][
i
+
1
]
*
vectors3d
[
k
][
j
+
1
];
// 0 - z, disparity == 0
}
if
(
i
!=
j
)
{
acovar
[
j
][
i
]
=
acovar
[
i
][
j
];
}
}
}
Matrix
covar
=
new
Matrix
(
acovar
);
// 2d, x y only
EigenvalueDecomposition
eig
=
covar
.
eig
();
val2d
=
eig
.
getD
();
vect2d
=
eig
.
getV
().
transpose
();
k_gauss
=
0.5
/(
scale_projection
*
scale_projection
);
}
// double px = tileSize*(superTileSize * sTileXY[0] + superTileSize/2) + zxy[1]; // [3] - plane point {disparity, x, y), x=0, y=0 is a 4,4 point of an 8x8 supertile
// double py = tileSize*(superTileSize * sTileXY[1] + superTileSize/2) + zxy[2];
for
(
int
sy
=
-
superTileSize
;
sy
<
superTileSize
;
sy
++){
// adding half-tile and half-pixel to match the center of the pixel. Supertile center is between
// pixel 31 and pixel 32 (counting from 0) in both directions
double
y
=
tileSize
*
(
sy
+
0.5
)
+
0.5
-
zxy
[
2
];
for
(
int
sx
=
-
superTileSize
;
sx
<
superTileSize
;
sx
++){
double
x
=
tileSize
*
(
sx
+
0.5
)
+
0.5
-
zxy
[
1
];
disp_strength
[
0
][
indx
]
=
zxy
[
0
]
-
(
normal
[
1
]
*
x
+
normal
[
2
]
*
y
)/
normal
[
0
];
double
w
=
weight
;
if
(
window
!=
null
)
w
*=
window
[
indx
];
if
(
use_sel
&&
(
sel_mask
!=
null
)
&&
!(
sel_mask
[
indx
]))
w
=
0.0
;
if
((
w
>
0.0
)
&&
(
scale_projection
>
0.0
)){
double
[]
xy
=
{
x
,
y
};
Matrix
vxy
=
vect2d
.
times
(
new
Matrix
(
xy
,
2
));
// verify if it is correct
double
r2
=
0
;
for
(
int
i
=
0
;
i
<
2
;
i
++){
double
d
=
vxy
.
get
(
i
,
0
);
r2
+=
d
*
d
/
val2d
.
get
(
i
,
i
);
}
w
*=
Math
.
exp
(-
k_gauss
*
r2
);
// verify it is correct size - maybe it should be -0.5*r2 ?
}
disp_strength
[
1
][
indx
]
=
w
;
indx
++;
}
}
return
disp_strength
;
}
/**
...
...
@@ -1510,8 +1569,8 @@ public class TilePlanes {
}
// extract new eigenvalues, eigenvectors
EigenvalueDecomposition
eig
=
covar
.
eig
();
// verify NaN - it gets stuck
// eig.getD().getArray(),
// eig.getV().getArray(),
// eig.getD().getArray(),
// eig.getV().getArray(),
if
(
debugLevel
>
0
)
{
System
.
out
.
println
(
"eig.getV()"
);
eig
.
getV
().
print
(
8
,
6
);
...
...
@@ -1524,14 +1583,14 @@ public class TilePlanes {
double
[][]
eig_vect
=
eig
.
getV
().
getArray
();
double
[][]
eig_val
=
eig
.
getD
().
getArray
();
// make towards camera, left coordinate system
/*
/*
int oindx = 0;
for (int i = 1; i <3; i++){
if (Math.abs(eig_vect[0][i]) > Math.abs(eig_vect[0][oindx])){
oindx = i;
}
}
*/
*/
int
oindx
=
0
;
if
(
preferDisparity
)
{
for
(
int
i
=
1
;
i
<
3
;
i
++){
...
...
@@ -1956,11 +2015,7 @@ public class TilePlanes {
System
.
out
.
println
(
"getCovar(): Double.isNaN(eig.getV().get(0, 0))"
);
debugLevel
=
20
;
}
// if (eig.getD().get(0, 0) == 0.0){
// debugLevel = 10;
// }
if
(
debugLevel
>
0
){
if
(
debugLevel
>
3
){
System
.
out
.
println
(
"getCovar(): sw = "
+
sw
+
", swz = "
+
swz
+
", swx = "
+
swx
+
", swy = "
+
swy
+
", covar.det() = "
+
covar
.
det
());
System
.
out
.
println
(
"getCovar(): covarianvce matrix, number of used points:"
+
numPoints
);
covar
.
print
(
10
,
6
);
// w,d
...
...
src/main/java/TileProcessor.java
View file @
73b9d03b
This diff is collapsed.
Click to expand it.
src/main/java/TileSurface.java
0 → 100644
View file @
73b9d03b
/**
**
** TileSurface - hadle tile surfaces
**
** Copyright (C) 2017 Elphel, Inc.
**
** -----------------------------------------------------------------------------**
**
** TileSurface.java is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
** -----------------------------------------------------------------------------**
**
*/
public
class
TileSurface
{
// public
private
int
tileSize
;
private
int
stSize
;
private
int
tilesX
;
private
int
tilesY
;
private
int
[]
st_dirs8
;
// private int nsTilesstSize = 0; // 8;
GeometryCorrection
geometryCorrection
=
null
;
public
TileSurface
(
int
tileSize
,
int
stSize
,
int
tilesX
,
int
tilesY
,
GeometryCorrection
geometryCorrection
){
this
.
tileSize
=
tileSize
;
this
.
stSize
=
stSize
;
this
.
geometryCorrection
=
geometryCorrection
;
this
.
tilesX
=
tilesX
;
this
.
tilesY
=
tilesY
;
int
[]
dirs
=
{-
tilesX
,
-
tilesX
+
1
,
1
,
tilesX
+
1
,
tilesX
,
tilesX
-
1
,
-
1
,
-
tilesX
-
1
};
this
.
st_dirs8
=
dirs
;
}
public
class
TileData
{
double
disparity
;
double
strength
;
double
enable
;
int
[]
neighbors
=
null
;
}
/**
* Get tile surface number from supertile number, direction (-1 same) and the supertile plane index
* @param nsTile number of the supertile
* @param dir direction -1 - same supertile, 0 - N (up), 1 - NE, .. 7 - NW
* @param np number of the supertile plane
* @param planes array of the per-supertile, per plane plane data (each level can be null)
* @return unique tile plane index
*/
public
int
getTileSurfaceNumber
(
int
nsTile
,
int
dir
,
// direction, or -1 (same)
int
np
,
TilePlanes
.
PlaneData
[][]
planes
){
if
((
planes
[
nsTile
]
==
null
)
||
(
planes
[
nsTile
][
np
]
==
null
)){
return
-
1
;
// empty supertile or supertile plane
}
if
(
dir
<
0
)
{
return
np
;
}
int
tsn
=
planes
[
nsTile
].
length
;
for
(
int
d
=
0
;
d
<
dir
;
d
++){
int
nsTile1
=
nsTile
+
st_dirs8
[
d
];
if
(
planes
[
nsTile1
]
!=
null
){
tsn
+=
planes
[
nsTile1
].
length
;
}
}
return
tsn
+
np
;
}
/**
* Get supertile direction and the plane number that contributeted to a specific tile surface
* @param nsTile supertile index
* @param tp tile surface index (generated by getTileSurfaceNumber)
* @param planes array of the per-supertile, per plane plane data (each level can be null)
* @return a pair of {dir, plane index}. dir is -1 for the plane in the same supertile, 0..7 for neighbors
*/
public
int
[]
getSuperTileDirPlane
(
int
nsTile
,
int
tp
,
TilePlanes
.
PlaneData
[][]
planes
)
{
int
num_planes
=
(
planes
[
nsTile
]
==
null
)?
0
:
planes
[
nsTile
].
length
;
int
[]
rslt
=
{-
1
,
tp
};
if
(
tp
<
num_planes
)
return
rslt
;
tp
-=
num_planes
;
for
(
int
d
=
0
;
d
<
st_dirs8
.
length
;
d
++){
int
nsTile1
=
nsTile
+
st_dirs8
[
d
];
num_planes
=
(
planes
[
nsTile1
]
==
null
)?
0
:
planes
[
nsTile1
].
length
;
if
(
tp
<
num_planes
){
rslt
[
0
]
=
d
;
rslt
[
1
]
=
tp
;
return
rslt
;
}
tp
-=
num_planes
;
}
return
null
;
// error - invalid input
}
}
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