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
38475568
Commit
38475568
authored
Jun 01, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filtering supertiles connections
parent
be191b98
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2417 additions
and
1038 deletions
+2417
-1038
ConnectionCosts.java
src/main/java/ConnectionCosts.java
+131
-14
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+67
-5
LinkPlanes.java
src/main/java/LinkPlanes.java
+1148
-96
SuperTiles.java
src/main/java/SuperTiles.java
+68
-763
TilePlanes.java
src/main/java/TilePlanes.java
+844
-63
TileProcessor.java
src/main/java/TileProcessor.java
+159
-97
No files found.
src/main/java/ConnectionCosts.java
View file @
38475568
...
...
@@ -72,7 +72,29 @@ public class ConnectionCosts {
this
.
steps
=
steps
;
}
public
int
[][][]
setStarValues
(
// also initConnectionCosts()
int
[]
nsTiles
,
int
debugLevel
)
{
return
initConnectionCosts
(
true
,
// boolean set_start_planes,
nsTiles
,
debugLevel
);
}
public
int
[][][]
initConnectionCosts
(
int
[]
nsTiles
,
int
debugLevel
)
{
return
initConnectionCosts
(
false
,
// boolean set_start_planes,
nsTiles
,
debugLevel
);
}
public
int
[][][]
initConnectionCosts
(
boolean
set_start_planes
,
int
[]
nsTiles
,
int
debugLevel
)
{
...
...
@@ -115,16 +137,19 @@ public class ConnectionCosts {
switch
(
steps
){
case
1
:
val_weights
=
getConnectionsCostSingleStep
(
set_start_planes
,
null
,
debugLevel
-
1
);
// int debugLevel)
break
;
case
2
:
val_weights
=
getConnectionsCostDualStep
(
set_start_planes
,
null
,
debugLevel
-
1
);
// int debugLevel)
break
;
default
:
val_weights
=
getConnectionsCostSingleStep
(
set_start_planes
,
null
,
debugLevel
-
1
);
// int debugLevel)
}
...
...
@@ -155,6 +180,9 @@ public class ConnectionCosts {
return
neibs_init
;
// neighbors to clone
}
public
double
[]
getValWeightLast
(
int
nsTile
,
int
nl
,
...
...
@@ -186,6 +214,7 @@ public class ConnectionCosts {
}
public
double
[][][]
getConnectionsCostSingleStep
(
boolean
set_start_planes
,
int
[][][]
neibs
,
int
debugLevel
)
{
...
...
@@ -211,6 +240,23 @@ public class ConnectionCosts {
}
}
if
(
neibs_changed
){
TilePlanes
.
PlaneData
star_plane
=
getStarPlane
(
nsTile
,
nl
,
neibs
[
isTile
][
nl
],
orthoWeight
,
diagonalWeight
,
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
starWeightPwr
,
tnSurface
,
preferDisparity
,
-
1
);
// debugLevel);
if
(
set_start_planes
){
planes
[
nsTile
][
nl
].
setStarPlane
(
star_plane
);
}
vw
[
isTile
][
nl
]
=
star_plane
.
getStarValueWeightDensity
();
/*
vw[isTile][nl] = getStarValueWeight(
nsTile,
nl,
...
...
@@ -222,6 +268,7 @@ public class ConnectionCosts {
tnSurface,
preferDisparity,
-1); // debugLevel);
*/
}
else
{
vw
[
isTile
][
nl
]
=
val_weights
[
isTile
][
nl
];
}
...
...
@@ -238,6 +285,7 @@ public class ConnectionCosts {
}
public
double
[][][]
getConnectionsCostDualStep
(
boolean
set_start_planes
,
int
[][][]
neibs
,
int
debugLevel
)
{
...
...
@@ -270,17 +318,6 @@ public class ConnectionCosts {
int
ineib1
=
(
tile_map
.
containsKey
(
nsTile1
))?
tile_map
.
get
(
nsTile1
)
:
-
1
;
neibs2
[
dir
]
=
(
ineib1
>=
0
)
?
neibs
[
tile_map
.
get
(
nsTile1
)][
nl1
]
:
planes
[
nsTile1
][
nl1
].
getNeibBest
();
if
(!
neibs_changed
&&
(
ineib1
>=
0
))
{
/*
if ((neibs_init[ineib1] == null) || (neibs_init[ineib1][nl1] == null)) {
neibs_changed = true;
} else {
for (int dir1 = 0; dir1 < 8; dir1++) if (neibs[ineib1][nl1][dir1] != neibs_init[ineib1][nl1][dir1]){
neibs_changed = true;
break;
}
}
*/
if
((
neibs_init
[
ineib1
]
==
null
)
||
(
neibs
[
ineib1
][
nl1
]
==
null
))
{
neibs_changed
=
true
;
}
else
{
...
...
@@ -294,6 +331,23 @@ public class ConnectionCosts {
}
if
(
neibs_changed
){
TilePlanes
.
PlaneData
star_plane
=
getStarPlane2
(
nsTile
,
nl
,
neibs0
,
neibs2
,
orthoWeight
,
diagonalWeight
,
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
starWeightPwr
,
//
tnSurface
,
preferDisparity
,
-
1
);
// debugLevel);
if
(
set_start_planes
){
planes
[
nsTile
][
nl
].
setStarPlane
(
star_plane
);
}
vw
[
isTile
][
nl
]
=
star_plane
.
getStarValueWeightDensity
();
/*
vw[isTile][nl] = getStarValueWeight2(
nsTile,
nl,
...
...
@@ -306,6 +360,7 @@ public class ConnectionCosts {
tnSurface,
preferDisparity,
-1); // debugLevel);
*/
}
else
{
vw
[
isTile
][
nl
]
=
val_weights
[
isTile
][
nl
];
}
...
...
@@ -360,16 +415,19 @@ public class ConnectionCosts {
switch
(
steps
){
case
1
:
vw
=
getConnectionsCostSingleStep
(
false
,
neibs
,
debugLevel
-
1
);
// int debugLevel)
break
;
case
2
:
vw
=
getConnectionsCostDualStep
(
false
,
neibs
,
debugLevel
-
1
);
// int debugLevel)
break
;
default
:
vw
=
getConnectionsCostSingleStep
(
false
,
neibs
,
debugLevel
-
1
);
// int debugLevel)
}
...
...
@@ -426,6 +484,31 @@ public class ConnectionCosts {
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
int
debugLevel
)
{
return
getStarPlane
(
nsTile
,
nl
,
neibs
,
orthoWeight
,
diagonalWeight
,
starPwr
,
// Divide cost by number of connections to this power
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
tnSurface
,
preferDisparity
,
debugLevel
).
getStarValueWeightDensity
();
}
TilePlanes
.
PlaneData
getStarPlane
(
int
nsTile
,
int
nl
,
int
[]
neibs
,
double
orthoWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
int
debugLevel
)
{
TilePlanes
.
PlaneData
merged_plane
=
planes
[
nsTile
][
nl
];
// add weight
double
conn_weight
=
1.0
;
// center weight
...
...
@@ -450,9 +533,11 @@ public class ConnectionCosts {
if
(
starPwr
!=
0
){
value_weight
[
0
]
/=
(
Math
.
pow
((
planes
[
nsTile
][
nl
].
getNumNeibBest
()
+
1.0
),
starPwr
));
}
return
value_weight
;
merged_plane
.
setStarValueWeight
(
value_weight
);
return
merged_plane
;
}
/**
* Calculate main eigenvalue of the current plane and all connected ones - used to estimate advantage of connection swap
* This version uses two steps - not only directly connected, but neighbors' neighbors also, multiple paths to the same
...
...
@@ -484,6 +569,34 @@ public class ConnectionCosts {
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
int
debugLevel
)
{
return
getStarPlane2
(
nsTile
,
nl
,
neibs
,
neibs2
,
// neighbors' neighbors
orthoWeight
,
diagonalWeight
,
starPwr
,
// Divide cost by number of connections to this power
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
tnSurface
,
preferDisparity
,
debugLevel
).
getStarValueWeightDensity
();
}
TilePlanes
.
PlaneData
getStarPlane2
(
int
nsTile
,
int
nl
,
int
[]
neibs
,
int
[][]
neibs2
,
// neighbors' neighbors
double
orthoWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starWeightPwr
,
// Use this power of tile weight when calculating connection cost
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
int
debugLevel
)
{
double
[]
dir_weight
=
{
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
};
HashMap
<
Point
,
Double
>
tile_weights
=
new
HashMap
<
Point
,
Double
>();
...
...
@@ -529,9 +642,13 @@ public class ConnectionCosts {
if
(
starPwr
!=
0
){
value_weight
[
0
]
/=
(
Math
.
pow
(
tile_weights
.
size
()
+
1.0
,
starPwr
));
}
return
value_weight
;
merged_plane
.
setStarValueWeight
(
value_weight
);
return
merged_plane
;
}
/**
* Calculate array of supertile indices that need to have connection cost recalculated when they are updated
* first entries of the result will be the same in input array
...
...
src/main/java/EyesisCorrectionParameters.java
View file @
38475568
...
...
@@ -2179,10 +2179,22 @@ public class EyesisCorrectionParameters {
public
double
plMaxWorldSin2
=
0.1
;
// Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable
public
double
plWeakWorsening
=
1.0
;
// Relax merge requirements for weaker planes
public
double
plMaxOverlap
=
0.1
;
// Maximal overlap between the same supertile planes to merge
// Merge same supetile planes if at least one is weak and they do not differ much
public
double
plWeakWeight
=
0.2
;
// Maximal weight of the weak plane to merge
public
double
plWeakEigen
=
0.1
;
// Maximal eigenvalue of the result of non-weighted merge
public
double
plWeakWeight2
=
10.0
;
// Maximal weight of the weak plane to merge (second variant)
public
double
plWeakEigen2
=
0.05
;
// Maximal eigenvalue of the result of non-weighted merge (second variant)
public
double
plMaxZRatio
=
2.0
;
// Maximal ratio of Z to allow plane merging
public
double
plMaxDisp
=
0.6
;
// Maximal disparity of one of the planes to apply maximal ratio
public
double
plCutTail
=
1.4
;
// When merging with neighbors cut the tail that is worse than scaled best
public
double
plMinTail
=
0.015
;
// Set cutoff value livel not less than
// comparing merge quality for plane pairs
public
double
plCostKrq
=
0.8
;
// cost of merge quality weighted
public
double
plCostKrqEq
=
0.2
;
// cost of merge quality equal weight
public
double
plCostKrq
=
0.8
;
// cost of merge quality weighted in disparity space
public
double
plCostKrqEq
=
0.2
;
// cost of merge quality equal weight in disparity space
public
double
plCostWrq
=
0.8
;
// cost of merge quality weighted in world space
public
double
plCostWrqEq
=
0.2
;
// cost of merge quality equal weight in world space
public
double
plCostSin2
=
10.0
;
// cost of sin squared between normals
public
double
plCostRdist2
=
1000.0
;
// cost of squared relative distances
...
...
@@ -2556,8 +2568,20 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"plWeakWorsening"
,
this
.
plWeakWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxOverlap"
,
this
.
plMaxOverlap
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakWeight"
,
this
.
plWeakWeight
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakEigen"
,
this
.
plWeakEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakWeight2"
,
this
.
plWeakWeight2
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakEigen2"
,
this
.
plWeakEigen2
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxZRatio"
,
this
.
plMaxZRatio
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxDisp"
,
this
.
plMaxDisp
+
""
);
properties
.
setProperty
(
prefix
+
"plCutTail"
,
this
.
plCutTail
+
""
);
properties
.
setProperty
(
prefix
+
"plMinTail"
,
this
.
plMinTail
+
""
);
properties
.
setProperty
(
prefix
+
"plCostKrq"
,
this
.
plCostKrq
+
""
);
properties
.
setProperty
(
prefix
+
"plCostKrqEq"
,
this
.
plCostKrqEq
+
""
);
properties
.
setProperty
(
prefix
+
"plCostWrq"
,
this
.
plCostWrq
+
""
);
properties
.
setProperty
(
prefix
+
"plCostWrqEq"
,
this
.
plCostWrqEq
+
""
);
properties
.
setProperty
(
prefix
+
"plCostSin2"
,
this
.
plCostSin2
+
""
);
properties
.
setProperty
(
prefix
+
"plCostRdist2"
,
this
.
plCostRdist2
+
""
);
...
...
@@ -2909,8 +2933,20 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
)!=
null
)
this
.
plWeakWorsening
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxOverlap"
)!=
null
)
this
.
plMaxOverlap
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxOverlap"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakWeight"
)!=
null
)
this
.
plWeakWeight
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakWeight"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakEigen"
)!=
null
)
this
.
plWeakEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakWeight2"
)!=
null
)
this
.
plWeakWeight2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakWeight2"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakEigen2"
)!=
null
)
this
.
plWeakEigen2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakEigen2"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxZRatio"
)!=
null
)
this
.
plMaxZRatio
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxZRatio"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxDisp"
)!=
null
)
this
.
plMaxDisp
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxDisp"
));
if
(
properties
.
getProperty
(
prefix
+
"plCutTail"
)!=
null
)
this
.
plCutTail
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCutTail"
));
if
(
properties
.
getProperty
(
prefix
+
"plMinTail"
)!=
null
)
this
.
plMinTail
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMinTail"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostKrq"
)!=
null
)
this
.
plCostKrq
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostKrq"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostKrqEq"
)!=
null
)
this
.
plCostKrqEq
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostKrqEq"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostWrq"
)!=
null
)
this
.
plCostWrq
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostWrq"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostWrqEq"
)!=
null
)
this
.
plCostWrqEq
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostWrqEq"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostSin2"
)!=
null
)
this
.
plCostSin2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostSin2"
));
if
(
properties
.
getProperty
(
prefix
+
"plCostRdist2"
)!=
null
)
this
.
plCostRdist2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plCostRdist2"
));
...
...
@@ -3290,9 +3326,23 @@ public class EyesisCorrectionParameters {
gd
.
addNumericField
(
"Relax merge requirements for weaker planes"
,
this
.
plWeakWorsening
,
6
);
gd
.
addNumericField
(
"Maximal overlap between the same supertile planes to merge"
,
this
.
plMaxOverlap
,
6
);
gd
.
addMessage
(
"--- Merge same supetile planes if at least one is weak and they do not differ much ---"
);
gd
.
addNumericField
(
"Maximal weight of the weak plane to merge (first variant)"
,
this
.
plWeakWeight
,
6
);
gd
.
addNumericField
(
"Maximal eigenvalue of the result of non-weighted merge (first variant)"
,
this
.
plWeakEigen
,
6
);
gd
.
addNumericField
(
"Maximal weight of the weak plane to merge (second variant)"
,
this
.
plWeakWeight2
,
6
);
gd
.
addNumericField
(
"Maximal eigenvalue of the result of non-weighted merge (second variant)"
,
this
.
plWeakEigen2
,
6
);
gd
.
addMessage
(
"--- ---"
);
gd
.
addNumericField
(
"Maximal ratio of Z to allow plane merging"
,
this
.
plMaxZRatio
,
6
);
gd
.
addNumericField
(
"Maximal disparity of one of the planes to apply maximal ratio"
,
this
.
plMaxDisp
,
6
);
gd
.
addNumericField
(
"When merging with neighbors cut the tail that is worse than scaled best"
,
this
.
plCutTail
,
6
);
gd
.
addNumericField
(
"Set cutoff value livel not less than this"
,
this
.
plMinTail
,
6
);
gd
.
addMessage
(
"--- Planes merge costs ---"
);
gd
.
addNumericField
(
"Cost of merge quality weighted"
,
this
.
plCostKrq
,
6
);
gd
.
addNumericField
(
"Cost of merge quality equal weight"
,
this
.
plCostKrqEq
,
6
);
gd
.
addNumericField
(
"Cost of merge quality weighted in disparity space"
,
this
.
plCostKrq
,
6
);
gd
.
addNumericField
(
"Cost of merge quality equal weight in disparity space"
,
this
.
plCostKrqEq
,
6
);
gd
.
addNumericField
(
"Cost of merge quality weighted in world space"
,
this
.
plCostWrq
,
6
);
gd
.
addNumericField
(
"Cost of merge quality equal weight in world space"
,
this
.
plCostWrqEq
,
6
);
gd
.
addNumericField
(
"Cost of sin squared between normals"
,
this
.
plCostSin2
,
6
);
gd
.
addNumericField
(
"Cost of squared relative plane-to-other-center distances"
,
this
.
plCostRdist2
,
6
);
...
...
@@ -3657,8 +3707,20 @@ public class EyesisCorrectionParameters {
this
.
plWeakWorsening
=
gd
.
getNextNumber
();
this
.
plMaxOverlap
=
gd
.
getNextNumber
();
this
.
plWeakWeight
=
gd
.
getNextNumber
();
this
.
plWeakEigen
=
gd
.
getNextNumber
();
this
.
plWeakWeight2
=
gd
.
getNextNumber
();
this
.
plWeakEigen2
=
gd
.
getNextNumber
();
this
.
plMaxZRatio
=
gd
.
getNextNumber
();
this
.
plMaxDisp
=
gd
.
getNextNumber
();
this
.
plCutTail
=
gd
.
getNextNumber
();
this
.
plMinTail
=
gd
.
getNextNumber
();
this
.
plCostKrq
=
gd
.
getNextNumber
();
this
.
plCostKrqEq
=
gd
.
getNextNumber
();
this
.
plCostWrq
=
gd
.
getNextNumber
();
this
.
plCostWrqEq
=
gd
.
getNextNumber
();
this
.
plCostSin2
=
gd
.
getNextNumber
();
this
.
plCostRdist2
=
gd
.
getNextNumber
();
...
...
src/main/java/LinkPlanes.java
View file @
38475568
This diff is collapsed.
Click to expand it.
src/main/java/SuperTiles.java
View file @
38475568
This diff is collapsed.
Click to expand it.
src/main/java/TilePlanes.java
View file @
38475568
This diff is collapsed.
Click to expand it.
src/main/java/TileProcessor.java
View file @
38475568
This diff is collapsed.
Click to expand it.
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