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
1183ecd4
Commit
1183ecd4
authored
May 24, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trying different plane match criteria
parent
960d054f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
728 additions
and
60 deletions
+728
-60
ConnectionCosts.java
src/main/java/ConnectionCosts.java
+29
-14
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+18
-3
SuperTiles.java
src/main/java/SuperTiles.java
+458
-22
TilePlanes.java
src/main/java/TilePlanes.java
+99
-1
TileProcessor.java
src/main/java/TileProcessor.java
+34
-3
TwoLayerNeighbors.java
src/main/java/TwoLayerNeighbors.java
+90
-17
No files found.
src/main/java/ConnectionCosts.java
View file @
1183ecd4
...
@@ -32,6 +32,7 @@ public class ConnectionCosts {
...
@@ -32,6 +32,7 @@ public class ConnectionCosts {
double
orthoWeight
;
double
orthoWeight
;
double
diagonalWeight
;
double
diagonalWeight
;
double
starPwr
;
// Divide cost by number of connections to this power
double
starPwr
;
// Divide cost by number of connections to this power
double
starValPwr
;
// Raise value of each tile before averaging
int
steps
;
int
steps
;
int
[][][]
neibs_init
;
int
[][][]
neibs_init
;
int
[]
mod_tiles
;
int
[]
mod_tiles
;
...
@@ -47,6 +48,7 @@ public class ConnectionCosts {
...
@@ -47,6 +48,7 @@ public class ConnectionCosts {
double
orthoWeight
,
double
orthoWeight
,
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
double
starValPwr
,
// Raise value of each tile before averaging
int
steps
,
int
steps
,
TilePlanes
.
PlaneData
[][]
planes
,
TilePlanes
.
PlaneData
[][]
planes
,
TileSurface
.
TileNeibs
tnSurface
,
TileSurface
.
TileNeibs
tnSurface
,
...
@@ -58,6 +60,7 @@ public class ConnectionCosts {
...
@@ -58,6 +60,7 @@ public class ConnectionCosts {
this
.
orthoWeight
=
orthoWeight
;
this
.
orthoWeight
=
orthoWeight
;
this
.
diagonalWeight
=
diagonalWeight
;
this
.
diagonalWeight
=
diagonalWeight
;
this
.
starPwr
=
starPwr
;
// Divide cost by number of connections to this power
this
.
starPwr
=
starPwr
;
// Divide cost by number of connections to this power
this
.
starValPwr
=
starValPwr
;
// Raise value of each tile before averaging
this
.
steps
=
steps
;
this
.
steps
=
steps
;
}
}
...
@@ -124,13 +127,16 @@ public class ConnectionCosts {
...
@@ -124,13 +127,16 @@ public class ConnectionCosts {
for
(
int
isTile
=
0
;
isTile
<
all_tiles
.
length
;
isTile
++){
for
(
int
isTile
=
0
;
isTile
<
all_tiles
.
length
;
isTile
++){
if
(
val_weights
[
isTile
]
!=
null
){
if
(
val_weights
[
isTile
]
!=
null
){
for
(
int
nl
=
0
;
nl
<
val_weights
[
isTile
].
length
;
nl
++)
if
(
val_weights
[
isTile
][
nl
]
!=
null
){
for
(
int
nl
=
0
;
nl
<
val_weights
[
isTile
].
length
;
nl
++)
if
(
val_weights
[
isTile
][
nl
]
!=
null
){
init_val
+=
val_weights
[
isTile
][
nl
][
0
]
*
val_weights
[
isTile
][
nl
][
1
];
double
val
=
val_weights
[
isTile
][
nl
][
0
];
if
(
starValPwr
!=
1.0
)
val
=
Math
.
pow
(
val
,
starValPwr
);
init_val
+=
val
*
val_weights
[
isTile
][
nl
][
1
];
init_weight
+=
val_weights
[
isTile
][
nl
][
1
];
init_weight
+=
val_weights
[
isTile
][
nl
][
1
];
}
}
}
}
}
}
// Likely weight will never change except first run, but we will still normalize by weight
// Likely weight will never change except first run, but we will still normalize by weight
if
(
init_weight
!=
0.0
)
init_val
/=
init_weight
;
// if (starValPwr != 1.0) init_val = Math.pow(init_val, 1.0/starValPwr);
// if (init_weight != 0.0) init_val /= init_weight;
return
neibs_init
;
// neighbors to clone
return
neibs_init
;
// neighbors to clone
}
}
...
@@ -197,6 +203,7 @@ public class ConnectionCosts {
...
@@ -197,6 +203,7 @@ public class ConnectionCosts {
orthoWeight
,
orthoWeight
,
diagonalWeight
,
diagonalWeight
,
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
// starValPwr, //double starValPwr, // Raise value of each tile before averaging
tnSurface
,
tnSurface
,
preferDisparity
,
preferDisparity
,
-
1
);
// debugLevel);
-
1
);
// debugLevel);
...
@@ -269,6 +276,7 @@ public class ConnectionCosts {
...
@@ -269,6 +276,7 @@ public class ConnectionCosts {
orthoWeight
,
orthoWeight
,
diagonalWeight
,
diagonalWeight
,
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
starPwr
,
// double starPwr, // Divide cost by number of connections to this power
// starValPwr, //double starValPwr, // Raise value of each tile before averaging
tnSurface
,
tnSurface
,
preferDisparity
,
preferDisparity
,
-
1
);
// debugLevel);
-
1
);
// debugLevel);
...
@@ -317,12 +325,16 @@ public class ConnectionCosts {
...
@@ -317,12 +325,16 @@ public class ConnectionCosts {
for
(
int
isTile
=
0
;
isTile
<
all_tiles
.
length
;
isTile
++){
for
(
int
isTile
=
0
;
isTile
<
all_tiles
.
length
;
isTile
++){
if
(
vw
[
isTile
]
!=
null
){
if
(
vw
[
isTile
]
!=
null
){
for
(
int
nl
=
0
;
nl
<
vw
[
isTile
].
length
;
nl
++)
if
(
vw
[
isTile
][
nl
]
!=
null
){
for
(
int
nl
=
0
;
nl
<
vw
[
isTile
].
length
;
nl
++)
if
(
vw
[
isTile
][
nl
]
!=
null
){
new_value
+=
vw
[
isTile
][
nl
][
0
]
*
vw
[
isTile
][
nl
][
1
];
new_weight
+=
vw
[
isTile
][
nl
][
1
];
double
val
=
vw
[
isTile
][
nl
][
0
];
if
(
starValPwr
!=
1.0
)
val
=
Math
.
pow
(
val
,
starValPwr
);
new_value
+=
val
*
vw
[
isTile
][
nl
][
1
];
new_weight
+=
vw
[
isTile
][
nl
][
1
];
}
}
}
}
}
}
if
(
new_weight
!=
0.0
)
new_value
/=
new_weight
;
// if (starValPwr != 1.0) new_value = Math.pow(new_value, 1.0/starValPwr);
// if (new_weight != 0.0) new_value /= new_weight;
return
new_value
-
init_val
;
// negative - improvement
return
new_value
-
init_val
;
// negative - improvement
}
}
...
@@ -350,11 +362,12 @@ public class ConnectionCosts {
...
@@ -350,11 +362,12 @@ public class ConnectionCosts {
double
orthoWeight
,
double
orthoWeight
,
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
// double starValPwr, // Raise value of each tile before averaging
TileSurface
.
TileNeibs
tnSurface
,
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
TilePlanes
.
PlaneData
merged_plane
=
planes
[
nsTile
][
nl
];
TilePlanes
.
PlaneData
merged_plane
=
planes
[
nsTile
][
nl
];
// add weight
for
(
int
dir
=
0
;
dir
<
8
;
dir
++){
for
(
int
dir
=
0
;
dir
<
8
;
dir
++){
if
(
neibs
[
dir
]
>=
0
){
if
(
neibs
[
dir
]
>=
0
){
double
other_weight
=
((
dir
&
1
)
!=
0
)
?
diagonalWeight
:
orthoWeight
;
double
other_weight
=
((
dir
&
1
)
!=
0
)
?
diagonalWeight
:
orthoWeight
;
...
@@ -397,16 +410,17 @@ public class ConnectionCosts {
...
@@ -397,16 +410,17 @@ public class ConnectionCosts {
public
double
[]
getStarValueWeight
(
public
double
[]
getStarValueWeight
(
int
nsTile
,
int
nsTile
,
int
nl
,
int
nl
,
int
[]
neibs
,
int
[]
neibs
,
int
[][]
neibs2
,
// neighbors' neighbors
int
[][]
neibs2
,
// neighbors' neighbors
double
orthoWeight
,
double
orthoWeight
,
double
diagonalWeight
,
double
diagonalWeight
,
double
starPwr
,
// Divide cost by number of connections to this power
double
starPwr
,
// Divide cost by number of connections to this power
// double starValPwr, // Raise value of each tile before averaging
TileSurface
.
TileNeibs
tnSurface
,
TileSurface
.
TileNeibs
tnSurface
,
boolean
preferDisparity
,
boolean
preferDisparity
,
int
debugLevel
)
int
debugLevel
)
{
{
double
[]
dir_weight
=
{
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
};
double
[]
dir_weight
=
{
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
,
orthoWeight
,
diagonalWeight
};
HashMap
<
Point
,
Double
>
tile_weights
=
new
HashMap
<
Point
,
Double
>();
HashMap
<
Point
,
Double
>
tile_weights
=
new
HashMap
<
Point
,
Double
>();
...
@@ -417,7 +431,8 @@ public class ConnectionCosts {
...
@@ -417,7 +431,8 @@ public class ConnectionCosts {
double
weight1
=
dir_weight
[
dir
];
double
weight1
=
dir_weight
[
dir
];
tile_weights
.
put
(
new
Point
(
nsTile1
,
nl1
),
new
Double
(
weight1
));
// no need to check for existence here
tile_weights
.
put
(
new
Point
(
nsTile1
,
nl1
),
new
Double
(
weight1
));
// no need to check for existence here
for
(
int
dir1
=
0
;
dir1
<
8
;
dir1
++){
for
(
int
dir1
=
0
;
dir1
<
8
;
dir1
++){
if
((
dir1
!=
dir
)
&&
(
neibs2
[
dir
]!=
null
)){
// if ((dir1 != dir) && (neibs2[dir]!= null)){
if
((
dir1
!=
((
dir
+
4
)
%
8
))
&&
(
neibs2
[
dir1
]!=
null
)){
// not backwards to the center and exists
int
nl2
=
neibs2
[
dir
][
dir1
];
int
nl2
=
neibs2
[
dir
][
dir1
];
if
(
nl2
>=
0
){
if
(
nl2
>=
0
){
Point
p
=
new
Point
(
tnSurface
.
getNeibIndex
(
nsTile1
,
dir1
),
nl2
);
Point
p
=
new
Point
(
tnSurface
.
getNeibIndex
(
nsTile1
,
dir1
),
nl2
);
...
...
src/main/java/EyesisCorrectionParameters.java
View file @
1183ecd4
...
@@ -2170,8 +2170,9 @@ public class EyesisCorrectionParameters {
...
@@ -2170,8 +2170,9 @@ public class EyesisCorrectionParameters {
public
double
plMinStrength
=
0.1
;
// Minimal total strength of a plane
public
double
plMinStrength
=
0.1
;
// Minimal total strength of a plane
public
double
plMaxEigen
=
0.3
;
// Maximal eigenvalue of a plane
public
double
plMaxEigen
=
0.3
;
// Maximal eigenvalue of a plane
public
boolean
plDbgMerge
=
true
;
// Combine 'other' plane with current
public
boolean
plDbgMerge
=
true
;
// Combine 'other' plane with current
public
double
plWorstWorsening
=
3.0
;
// Worst case worsening after merge
public
double
plWorstWorsening
=
2.0
;
// Worst case worsening after merge
public
double
plOKMergeEigen
=
0.03
;
// If result of the merged planes is below, OK to bypass worst worsening
public
double
plWorstWorsening2
=
5.0
;
// Worst case worsening for thin planes
public
double
plOKMergeEigen
=
0.03
;
// If result of the merged planes is below, OK to use thin planes (higher) threshold
public
double
plMaxWorldSin2
=
0.1
;
// Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable
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
plWeakWorsening
=
1.0
;
// Relax merge requirements for weaker planes
...
@@ -2184,8 +2185,10 @@ public class EyesisCorrectionParameters {
...
@@ -2184,8 +2185,10 @@ public class EyesisCorrectionParameters {
public
double
plStarOrtho
=
0.5
;
// When calculating cost for the connections scale 4 ortho neighbors
public
double
plStarOrtho
=
0.5
;
// When calculating cost for the connections scale 4 ortho neighbors
public
double
plStarDiag
=
0.25
;
// When calculating cost for the connections scale 4 diagonal neighbors
public
double
plStarDiag
=
0.25
;
// When calculating cost for the connections scale 4 diagonal neighbors
public
double
plStarPwr
=
0.5
;
// Divide cost by number of connections to this power
public
double
plStarPwr
=
0.5
;
// Divide cost by number of connections to this power
public
double
plStarValPwr
=
1.0
;
// Raise value of each tile before averaging
public
double
plDblTriLoss
=
0.0001
;
// When resolving double triangles allow minor degradation (0.0 - strict)
public
double
plDblTriLoss
=
0.0001
;
// When resolving double triangles allow minor degradation (0.0 - strict)
public
boolean
plNewConfl
=
false
;
// Allow more conflicts if overall cost is reduced
public
boolean
plNewConfl
=
false
;
// Allow more conflicts if overall cost is reduced
public
int
plMaxChanges
=
0
;
// Maximal number of simultaneous connection changes around one tile (0 - any)
public
boolean
plMutualOnly
=
true
;
// keep only mutual links, remove weakest if conflict
public
boolean
plMutualOnly
=
true
;
// keep only mutual links, remove weakest if conflict
public
boolean
plFillSquares
=
true
;
// Add diagonals to full squares
public
boolean
plFillSquares
=
true
;
// Add diagonals to full squares
...
@@ -2531,6 +2534,7 @@ public class EyesisCorrectionParameters {
...
@@ -2531,6 +2534,7 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"plMaxEigen"
,
this
.
plMaxEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxEigen"
,
this
.
plMaxEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plDbgMerge"
,
this
.
plDbgMerge
+
""
);
properties
.
setProperty
(
prefix
+
"plDbgMerge"
,
this
.
plDbgMerge
+
""
);
properties
.
setProperty
(
prefix
+
"plWorstWorsening"
,
this
.
plWorstWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plWorstWorsening"
,
this
.
plWorstWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plWorstWorsening2"
,
this
.
plWorstWorsening2
+
""
);
properties
.
setProperty
(
prefix
+
"plOKMergeEigen"
,
this
.
plOKMergeEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plOKMergeEigen"
,
this
.
plOKMergeEigen
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxWorldSin2"
,
this
.
plMaxWorldSin2
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxWorldSin2"
,
this
.
plMaxWorldSin2
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakWorsening"
,
this
.
plWeakWorsening
+
""
);
properties
.
setProperty
(
prefix
+
"plWeakWorsening"
,
this
.
plWeakWorsening
+
""
);
...
@@ -2543,8 +2547,10 @@ public class EyesisCorrectionParameters {
...
@@ -2543,8 +2547,10 @@ public class EyesisCorrectionParameters {
properties
.
setProperty
(
prefix
+
"plStarOrtho"
,
this
.
plStarOrtho
+
""
);
properties
.
setProperty
(
prefix
+
"plStarOrtho"
,
this
.
plStarOrtho
+
""
);
properties
.
setProperty
(
prefix
+
"plStarDiag"
,
this
.
plStarDiag
+
""
);
properties
.
setProperty
(
prefix
+
"plStarDiag"
,
this
.
plStarDiag
+
""
);
properties
.
setProperty
(
prefix
+
"plStarPwr"
,
this
.
plStarPwr
+
""
);
properties
.
setProperty
(
prefix
+
"plStarPwr"
,
this
.
plStarPwr
+
""
);
properties
.
setProperty
(
prefix
+
"plStarValPwr"
,
this
.
plStarValPwr
+
""
);
properties
.
setProperty
(
prefix
+
"plDblTriLoss"
,
this
.
plDblTriLoss
+
""
);
properties
.
setProperty
(
prefix
+
"plDblTriLoss"
,
this
.
plDblTriLoss
+
""
);
properties
.
setProperty
(
prefix
+
"plNewConfl"
,
this
.
plNewConfl
+
""
);
properties
.
setProperty
(
prefix
+
"plNewConfl"
,
this
.
plNewConfl
+
""
);
properties
.
setProperty
(
prefix
+
"plMaxChanges"
,
this
.
plMaxChanges
+
""
);
properties
.
setProperty
(
prefix
+
"plMutualOnly"
,
this
.
plMutualOnly
+
""
);
properties
.
setProperty
(
prefix
+
"plMutualOnly"
,
this
.
plMutualOnly
+
""
);
properties
.
setProperty
(
prefix
+
"plFillSquares"
,
this
.
plFillSquares
+
""
);
properties
.
setProperty
(
prefix
+
"plFillSquares"
,
this
.
plFillSquares
+
""
);
...
@@ -2870,6 +2876,7 @@ public class EyesisCorrectionParameters {
...
@@ -2870,6 +2876,7 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"plMaxEigen"
)!=
null
)
this
.
plMaxEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxEigen"
)!=
null
)
this
.
plMaxEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plDbgMerge"
)!=
null
)
this
.
plDbgMerge
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plDbgMerge"
));
if
(
properties
.
getProperty
(
prefix
+
"plDbgMerge"
)!=
null
)
this
.
plDbgMerge
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plDbgMerge"
));
if
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening"
)!=
null
)
this
.
plWorstWorsening
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening"
));
if
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening"
)!=
null
)
this
.
plWorstWorsening
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening"
));
if
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening2"
)!=
null
)
this
.
plWorstWorsening2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWorstWorsening2"
));
if
(
properties
.
getProperty
(
prefix
+
"plOKMergeEigen"
)!=
null
)
this
.
plOKMergeEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plOKMergeEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plOKMergeEigen"
)!=
null
)
this
.
plOKMergeEigen
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plOKMergeEigen"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxWorldSin2"
)!=
null
)
this
.
plMaxWorldSin2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxWorldSin2"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxWorldSin2"
)!=
null
)
this
.
plMaxWorldSin2
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plMaxWorldSin2"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
)!=
null
)
this
.
plWeakWorsening
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
));
if
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
)!=
null
)
this
.
plWeakWorsening
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plWeakWorsening"
));
...
@@ -2882,8 +2889,10 @@ public class EyesisCorrectionParameters {
...
@@ -2882,8 +2889,10 @@ public class EyesisCorrectionParameters {
if
(
properties
.
getProperty
(
prefix
+
"plStarOrtho"
)!=
null
)
this
.
plStarOrtho
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarOrtho"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarOrtho"
)!=
null
)
this
.
plStarOrtho
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarOrtho"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarDiag"
)!=
null
)
this
.
plStarDiag
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarDiag"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarDiag"
)!=
null
)
this
.
plStarDiag
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarDiag"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarPwr"
)!=
null
)
this
.
plStarPwr
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarPwr"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarPwr"
)!=
null
)
this
.
plStarPwr
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarPwr"
));
if
(
properties
.
getProperty
(
prefix
+
"plStarValPwr"
)!=
null
)
this
.
plStarValPwr
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plStarValPwr"
));
if
(
properties
.
getProperty
(
prefix
+
"plDblTriLoss"
)!=
null
)
this
.
plDblTriLoss
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plDblTriLoss"
));
if
(
properties
.
getProperty
(
prefix
+
"plDblTriLoss"
)!=
null
)
this
.
plDblTriLoss
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"plDblTriLoss"
));
if
(
properties
.
getProperty
(
prefix
+
"plNewConfl"
)!=
null
)
this
.
plNewConfl
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plNewConfl"
));
if
(
properties
.
getProperty
(
prefix
+
"plNewConfl"
)!=
null
)
this
.
plNewConfl
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plNewConfl"
));
if
(
properties
.
getProperty
(
prefix
+
"plMaxChanges"
)!=
null
)
this
.
plMaxChanges
=
Integer
.
parseInt
(
properties
.
getProperty
(
prefix
+
"plMaxChanges"
));
if
(
properties
.
getProperty
(
prefix
+
"plMutualOnly"
)!=
null
)
this
.
plMutualOnly
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plMutualOnly"
));
if
(
properties
.
getProperty
(
prefix
+
"plMutualOnly"
)!=
null
)
this
.
plMutualOnly
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plMutualOnly"
));
if
(
properties
.
getProperty
(
prefix
+
"plFillSquares"
)!=
null
)
this
.
plFillSquares
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plFillSquares"
));
if
(
properties
.
getProperty
(
prefix
+
"plFillSquares"
)!=
null
)
this
.
plFillSquares
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"plFillSquares"
));
...
@@ -3237,7 +3246,8 @@ public class EyesisCorrectionParameters {
...
@@ -3237,7 +3246,8 @@ public class EyesisCorrectionParameters {
gd
.
addNumericField
(
"Maximal eigenvalue of a plane"
,
this
.
plMaxEigen
,
6
);
gd
.
addNumericField
(
"Maximal eigenvalue of a plane"
,
this
.
plMaxEigen
,
6
);
gd
.
addCheckbox
(
"Combine 'other' plane with the current (unused)"
,
this
.
plDbgMerge
);
gd
.
addCheckbox
(
"Combine 'other' plane with the current (unused)"
,
this
.
plDbgMerge
);
gd
.
addNumericField
(
"Worst case worsening after merge"
,
this
.
plWorstWorsening
,
6
);
gd
.
addNumericField
(
"Worst case worsening after merge"
,
this
.
plWorstWorsening
,
6
);
gd
.
addNumericField
(
"If result of the merged planes is below, OK to bypass worst worsening"
,
this
.
plOKMergeEigen
,
6
);
gd
.
addNumericField
(
"Worst case worsening for thin planes"
,
this
.
plWorstWorsening2
,
6
);
gd
.
addNumericField
(
"If result of the merged planes is below, OK to use thin planes (higher) threshold "
,
this
.
plOKMergeEigen
,
6
);
gd
.
addNumericField
(
"Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable"
,
this
.
plMaxWorldSin2
,
6
);
gd
.
addNumericField
(
"Maximal sine squared of the world angle between planes to merge. Set to >= 1.0 to disable"
,
this
.
plMaxWorldSin2
,
6
);
gd
.
addNumericField
(
"Relax merge requirements for weaker planes"
,
this
.
plWeakWorsening
,
6
);
gd
.
addNumericField
(
"Relax merge requirements for weaker planes"
,
this
.
plWeakWorsening
,
6
);
...
@@ -3249,8 +3259,10 @@ public class EyesisCorrectionParameters {
...
@@ -3249,8 +3259,10 @@ public class EyesisCorrectionParameters {
gd
.
addNumericField
(
"When calculating cost for the connections scale 4 ortho neighbors"
,
this
.
plStarOrtho
,
6
);
gd
.
addNumericField
(
"When calculating cost for the connections scale 4 ortho neighbors"
,
this
.
plStarOrtho
,
6
);
gd
.
addNumericField
(
"When calculating cost for the connections scale 4 diagonal neighbors"
,
this
.
plStarDiag
,
6
);
gd
.
addNumericField
(
"When calculating cost for the connections scale 4 diagonal neighbors"
,
this
.
plStarDiag
,
6
);
gd
.
addNumericField
(
"Divide cost by number of connections to this power"
,
this
.
plStarPwr
,
6
);
gd
.
addNumericField
(
"Divide cost by number of connections to this power"
,
this
.
plStarPwr
,
6
);
gd
.
addNumericField
(
"Raise value of each tile before averaging"
,
this
.
plStarValPwr
,
6
);
gd
.
addNumericField
(
"When resolving double triangles allow minor degradation (0.0 - strict)"
,
this
.
plDblTriLoss
,
6
);
gd
.
addNumericField
(
"When resolving double triangles allow minor degradation (0.0 - strict)"
,
this
.
plDblTriLoss
,
6
);
gd
.
addCheckbox
(
"Allow more conflicts if overall cost is reduced"
,
this
.
plNewConfl
);
gd
.
addCheckbox
(
"Allow more conflicts if overall cost is reduced"
,
this
.
plNewConfl
);
gd
.
addNumericField
(
"aximal number of simultaneous connection changes around one tile (0 - any)"
,
this
.
plMaxChanges
,
0
);
gd
.
addCheckbox
(
"Keep only mutual links, remove weakest if conflict"
,
this
.
plMutualOnly
);
gd
.
addCheckbox
(
"Keep only mutual links, remove weakest if conflict"
,
this
.
plMutualOnly
);
...
@@ -3589,6 +3601,7 @@ public class EyesisCorrectionParameters {
...
@@ -3589,6 +3601,7 @@ public class EyesisCorrectionParameters {
this
.
plMaxEigen
=
gd
.
getNextNumber
();
this
.
plMaxEigen
=
gd
.
getNextNumber
();
this
.
plDbgMerge
=
gd
.
getNextBoolean
();
this
.
plDbgMerge
=
gd
.
getNextBoolean
();
this
.
plWorstWorsening
=
gd
.
getNextNumber
();
this
.
plWorstWorsening
=
gd
.
getNextNumber
();
this
.
plWorstWorsening2
=
gd
.
getNextNumber
();
this
.
plOKMergeEigen
=
gd
.
getNextNumber
();
this
.
plOKMergeEigen
=
gd
.
getNextNumber
();
this
.
plMaxWorldSin2
=
gd
.
getNextNumber
();
this
.
plMaxWorldSin2
=
gd
.
getNextNumber
();
this
.
plWeakWorsening
=
gd
.
getNextNumber
();
this
.
plWeakWorsening
=
gd
.
getNextNumber
();
...
@@ -3601,8 +3614,10 @@ public class EyesisCorrectionParameters {
...
@@ -3601,8 +3614,10 @@ public class EyesisCorrectionParameters {
this
.
plStarOrtho
=
gd
.
getNextNumber
();
this
.
plStarOrtho
=
gd
.
getNextNumber
();
this
.
plStarDiag
=
gd
.
getNextNumber
();
this
.
plStarDiag
=
gd
.
getNextNumber
();
this
.
plStarPwr
=
gd
.
getNextNumber
();
this
.
plStarPwr
=
gd
.
getNextNumber
();
this
.
plStarValPwr
=
gd
.
getNextNumber
();
this
.
plDblTriLoss
=
gd
.
getNextNumber
();
this
.
plDblTriLoss
=
gd
.
getNextNumber
();
this
.
plNewConfl
=
gd
.
getNextBoolean
();
this
.
plNewConfl
=
gd
.
getNextBoolean
();
this
.
plMaxChanges
=
(
int
)
gd
.
getNextNumber
();
this
.
plMutualOnly
=
gd
.
getNextBoolean
();
this
.
plMutualOnly
=
gd
.
getNextBoolean
();
...
...
src/main/java/SuperTiles.java
View file @
1183ecd4
This diff is collapsed.
Click to expand it.
src/main/java/TilePlanes.java
View file @
1183ecd4
...
@@ -58,7 +58,11 @@ public class TilePlanes {
...
@@ -58,7 +58,11 @@ public class TilePlanes {
double
[]
world_v1
=
null
;
// world in-plane vector, corresponding to vectors[1]
double
[]
world_v1
=
null
;
// world in-plane vector, corresponding to vectors[1]
double
[]
world_v2
=
null
;
// world in-plane vector, corresponding to vectors[1]
double
[]
world_v2
=
null
;
// world in-plane vector, corresponding to vectors[1]
// double [] daxy = null; // disparity and 2 relative angles (ax and ay) corresponding to fisheye view, near (0,0) scale is pixel size
// double [] daxy = null; // disparity and 2 relative angles (ax and ay) corresponding to fisheye view, near (0,0) scale is pixel size
// for now keeping both weighted and equal weight merged value - later remove less useful
double
[][]
merged_eig_val
=
null
;
// for each of the directions (N, NE, .. NW) quality match for each layer
double
[][]
merged_eig_val
=
null
;
// for each of the directions (N, NE, .. NW) quality match for each layer
double
[][]
merged_eig_eq
=
null
;
// for each of the directions (N, NE, .. NW) quality match for each layer - ignoring weights
boolean
[][]
merged_valid
=
null
;
// for each of the directions (N, NE, .. NW) if it is possible to connect with link swaps
int
[]
neib_best
=
null
;
// new int [8]; // for each of the directions (N, NE, .. NW) index of best match, -1 if none
int
[]
neib_best
=
null
;
// new int [8]; // for each of the directions (N, NE, .. NW) index of best match, -1 if none
// stores "worsening" of merging 2 planes. if L1,L2,L = values[0] of plane1, plane2 plane composite: w1, w2 - weights for plane1, plane2
// stores "worsening" of merging 2 planes. if L1,L2,L = values[0] of plane1, plane2 plane composite: w1, w2 - weights for plane1, plane2
// Lav = Math.sqrt((L1 * L1 * w1 + L2 * L2 * w2)/(w1 + w2))
// Lav = Math.sqrt((L1 * L1 * w1 + L2 * L2 * w2)/(w1 + w2))
...
@@ -209,6 +213,26 @@ public class TilePlanes {
...
@@ -209,6 +213,26 @@ public class TilePlanes {
}
}
}
}
}
}
if
(
src
.
merged_eig_eq
!=
null
){
dst
.
merged_eig_eq
=
src
.
merged_eig_eq
.
clone
();
for
(
int
i
=
0
;
i
<
src
.
merged_eig_eq
.
length
;
i
++){
if
(
src
.
merged_eig_eq
[
i
]
!=
null
){
dst
.
merged_eig_eq
[
i
]
=
src
.
merged_eig_eq
[
i
].
clone
();
}
}
}
if
(
src
.
merged_valid
!=
null
){
dst
.
merged_valid
=
src
.
merged_valid
.
clone
();
for
(
int
i
=
0
;
i
<
src
.
merged_valid
.
length
;
i
++){
if
(
src
.
merged_valid
[
i
]
!=
null
){
dst
.
merged_valid
[
i
]
=
src
.
merged_valid
[
i
].
clone
();
}
}
}
if
(
src
.
neib_best
!=
null
)
dst
.
neib_best
=
src
.
neib_best
.
clone
();
if
(
src
.
neib_best
!=
null
)
dst
.
neib_best
=
src
.
neib_best
.
clone
();
// also copy original plane parameters - tile selection and number of points
// also copy original plane parameters - tile selection and number of points
...
@@ -1130,16 +1154,29 @@ public class TilePlanes {
...
@@ -1130,16 +1154,29 @@ public class TilePlanes {
public
double
[][]
initMergedValue
()
public
double
[][]
initMergedValue
()
{
{
this
.
merged_eig_val
=
new
double
[
8
][];
this
.
merged_eig_val
=
new
double
[
8
][];
this
.
merged_eig_eq
=
new
double
[
8
][];
this
.
merged_valid
=
new
boolean
[
8
][];
return
this
.
merged_eig_val
;
return
this
.
merged_eig_val
;
}
}
public
double
[][]
getMergedValue
()
public
double
[][]
getMergedValue
()
{
{
return
this
.
merged_eig_val
;
return
this
.
merged_eig_val
;
}
}
public
double
[][]
getMergedValueEq
()
{
return
this
.
merged_eig_eq
;
}
public
double
[]
initMergedValue
(
int
dir
,
int
leng
)
public
double
[]
initMergedValue
(
int
dir
,
int
leng
)
{
{
this
.
merged_eig_val
[
dir
]
=
new
double
[
leng
];
this
.
merged_eig_val
[
dir
]
=
new
double
[
leng
];
for
(
int
i
=
0
;
i
<
leng
;
i
++)
this
.
merged_eig_val
[
dir
][
i
]
=
Double
.
NaN
;
this
.
merged_eig_eq
[
dir
]
=
new
double
[
leng
];
this
.
merged_valid
[
dir
]
=
new
boolean
[
leng
];
for
(
int
i
=
0
;
i
<
leng
;
i
++)
{
this
.
merged_eig_val
[
dir
][
i
]
=
Double
.
NaN
;
this
.
merged_eig_eq
[
dir
][
i
]
=
Double
.
NaN
;
}
return
getMergedValue
(
dir
);
return
getMergedValue
(
dir
);
}
}
...
@@ -1151,6 +1188,14 @@ public class TilePlanes {
...
@@ -1151,6 +1188,14 @@ public class TilePlanes {
return
this
.
merged_eig_val
[
dir
];
return
this
.
merged_eig_val
[
dir
];
}
}
public
double
[]
getMergedValueEq
(
int
dir
)
{
if
(
this
.
merged_eig_eq
==
null
)
{
return
null
;
}
return
this
.
merged_eig_eq
[
dir
];
}
public
double
getMergedValue
(
int
dir
,
int
plane
)
public
double
getMergedValue
(
int
dir
,
int
plane
)
{
{
if
((
this
.
merged_eig_val
==
null
)
||(
this
.
merged_eig_val
[
dir
]
==
null
)){
if
((
this
.
merged_eig_val
==
null
)
||(
this
.
merged_eig_val
[
dir
]
==
null
)){
...
@@ -1158,10 +1203,63 @@ public class TilePlanes {
...
@@ -1158,10 +1203,63 @@ public class TilePlanes {
}
}
return
this
.
merged_eig_val
[
dir
][
plane
];
return
this
.
merged_eig_val
[
dir
][
plane
];
}
}
public
double
getMergedValueEq
(
int
dir
,
int
plane
)
{
if
((
this
.
merged_eig_eq
==
null
)
||(
this
.
merged_eig_eq
[
dir
]
==
null
)){
return
Double
.
NaN
;
}
return
this
.
merged_eig_eq
[
dir
][
plane
];
}
public
void
setNeibMatch
(
int
dir
,
int
plane
,
double
value
)
public
void
setNeibMatch
(
int
dir
,
int
plane
,
double
value
)
{
{
this
.
merged_eig_val
[
dir
][
plane
]
=
value
;
this
.
merged_eig_val
[
dir
][
plane
]
=
value
;
}
}
public
void
setNeibMatchEq
(
int
dir
,
int
plane
,
double
value
)
{
this
.
merged_eig_eq
[
dir
][
plane
]
=
value
;
}
public
boolean
[][]
getMergedValid
()
{
return
this
.
merged_valid
;
}
public
boolean
[]
getMergedValid
(
int
dir
)
{
if
(
this
.
merged_valid
==
null
)
{
return
null
;
}
return
this
.
merged_valid
[
dir
];
}
public
boolean
isMergedValid
(
int
dir
,
int
plane
)
{
if
((
this
.
merged_valid
==
null
)
||
(
this
.
merged_valid
[
dir
]
==
null
)){
return
false
;
}
return
this
.
merged_valid
[
dir
][
plane
];
}
public
void
setMergedValid
(
int
dir
,
int
plane
,
boolean
valid
)
{
this
.
merged_valid
[
dir
][
plane
]
=
valid
;
}
public
void
setMergedValid
(
int
dir
,
int
plane
,
boolean
valid
,
int
leng
)
{
if
(
this
.
merged_valid
==
null
){
this
.
merged_valid
=
new
boolean
[
8
][];
}
if
(
this
.
merged_valid
[
dir
]
==
null
){
this
.
merged_valid
[
dir
]
=
new
boolean
[
leng
];
}
this
.
merged_valid
[
dir
][
plane
]
=
valid
;
}
public
int
[]
initNeibBest
()
public
int
[]
initNeibBest
()
{
{
...
...
src/main/java/TileProcessor.java
View file @
1183ecd4
...
@@ -3416,7 +3416,26 @@ public class TileProcessor {
...
@@ -3416,7 +3416,26 @@ public class TileProcessor {
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
clt_parameters
.
tileY
);
st
.
filterNeighborPlanes
(
clt_parameters
.
plWorstWorsening
,
// final double worst_worsening,
clt_parameters
.
plWorstWorsening2
,
// final double worst_worsening2 Worst case worsening for thin planes,
clt_parameters
.
plWeakWorsening
,
// final double worst_worsening,
clt_parameters
.
plOKMergeEigen
,
// final double okMergeEigen, f result of the merged planes is below, OK to use thin planes (higher) threshold
clt_parameters
.
plMaxWorldSin2
,
// final double maxWorldSin2,
clt_parameters
.
plDispNorm
,
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plMinStrength
,
0
,
// final int debugLevel)
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
/* */
st
.
selectNeighborPlanesMutual
(
st
.
selectNeighborPlanesMutual
(
0
,
// final int debugLevel)
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
/*
st.selectNeighborPlanesMutual_old(
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plWorstWorsening, // final double worst_worsening,
clt_parameters.plWeakWorsening, // final double worst_worsening,
clt_parameters.plWeakWorsening, // final double worst_worsening,
clt_parameters.plOKMergeEigen, // final double okMergeEigen,
clt_parameters.plOKMergeEigen, // final double okMergeEigen,
...
@@ -3428,7 +3447,7 @@ public class TileProcessor {
...
@@ -3428,7 +3447,7 @@ public class TileProcessor {
0, // final int debugLevel)
0, // final int debugLevel)
clt_parameters.tileX,
clt_parameters.tileX,
clt_parameters.tileY);
clt_parameters.tileY);
*/
st
.
resolveConflicts
(
st
.
resolveConflicts
(
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plConflDualTri
,
// boolean conflDualTri, // Resolve dual triangles conflict (odoodo)
clt_parameters
.
plConflDualTri
,
// boolean conflDualTri, // Resolve dual triangles conflict (odoodo)
...
@@ -3438,9 +3457,11 @@ public class TileProcessor {
...
@@ -3438,9 +3457,11 @@ public class TileProcessor {
clt_parameters
.
plStarSteps
,
// int starSteps, // How far to look around when calculationg connection cost
clt_parameters
.
plStarSteps
,
// int starSteps, // How far to look around when calculationg connection cost
clt_parameters
.
plStarOrtho
,
// double orthoWeight,
clt_parameters
.
plStarOrtho
,
// double orthoWeight,
clt_parameters
.
plStarDiag
,
// double diagonalWeight,
clt_parameters
.
plStarDiag
,
// double diagonalWeight,
clt_parameters
.
plStarPwr
,
// double starPwr, // Divide cost by number of connections to this power
clt_parameters
.
plStarPwr
,
// double starPwr, // Divide cost by number of connections to this power
clt_parameters
.
plStarValPwr
,
// double starValPwr, // Raise value of each tile before averaging
clt_parameters
.
plDblTriLoss
,
// double diagonalWeight,
clt_parameters
.
plDblTriLoss
,
// double diagonalWeight,
clt_parameters
.
plNewConfl
,
// boolean preferDisparity, // Allow more conflicts if overall cost is reduced
clt_parameters
.
plNewConfl
,
// boolean preferDisparity, // Allow more conflicts if overall cost is reduced
clt_parameters
.
plMaxChanges
,
// int maxChanges, // Maximal number of simultaneous connection changes around one tile (0 - any)
clt_parameters
.
plPreferDisparity
,
clt_parameters
.
plPreferDisparity
,
1
,
// final int debugLevel)
1
,
// final int debugLevel)
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
...
@@ -3456,6 +3477,7 @@ public class TileProcessor {
...
@@ -3456,6 +3477,7 @@ public class TileProcessor {
clt_parameters.plStarOrtho, // double orthoWeight,
clt_parameters.plStarOrtho, // double orthoWeight,
clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plStarDiag, // double diagonalWeight,
clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power
clt_parameters.plStarPwr, // double starPwr, // Divide cost by number of connections to this power
clt_parameters.plStarValPwr, // double starValPwr, // Raise value of each tile before averaging
clt_parameters.plDblTriLoss, // double diagonalWeight,
clt_parameters.plDblTriLoss, // double diagonalWeight,
true, // clt_parameters.plNewConfl, // Allow more conflicts if overall cost is reduced
true, // clt_parameters.plNewConfl, // Allow more conflicts if overall cost is reduced
clt_parameters.plPreferDisparity,
clt_parameters.plPreferDisparity,
...
@@ -3543,11 +3565,13 @@ public class TileProcessor {
...
@@ -3543,11 +3565,13 @@ public class TileProcessor {
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
clt_parameters
.
tileY
);
st
.
selectNeighborPlanesMutual
(
st
.
filterNeighborPlanes
(
clt_parameters
.
plWorstWorsening
,
// final double worst_worsening,
clt_parameters
.
plWorstWorsening
,
// final double worst_worsening,
clt_parameters
.
plWorstWorsening2
,
// final double worst_worsening2 Worst case worsening for thin planes,
clt_parameters
.
plWeakWorsening
,
// final double worst_worsening,
clt_parameters
.
plWeakWorsening
,
// final double worst_worsening,
clt_parameters
.
plOKMergeEigen
,
// final double okMergeEigen,
clt_parameters
.
plOKMergeEigen
,
// final double okMergeEigen,
clt_parameters
.
plMaxWorldSin2
,
// final double maxWorldSin2,
clt_parameters
.
plMaxWorldSin2
,
// final double maxWorldSin2,
clt_parameters
.
plDispNorm
,
clt_parameters
.
plDispNorm
,
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plMinStrength
,
clt_parameters
.
plMinStrength
,
...
@@ -3555,6 +3579,11 @@ public class TileProcessor {
...
@@ -3555,6 +3579,11 @@ public class TileProcessor {
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
clt_parameters
.
tileY
);
st
.
selectNeighborPlanesMutual
(
0
,
// final int debugLevel)
clt_parameters
.
tileX
,
clt_parameters
.
tileY
);
st
.
resolveConflicts
(
st
.
resolveConflicts
(
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plMaxEigen
,
clt_parameters
.
plConflDualTri
,
// boolean conflDualTri, // Resolve dual triangles conflict (odoodo)
clt_parameters
.
plConflDualTri
,
// boolean conflDualTri, // Resolve dual triangles conflict (odoodo)
...
@@ -3565,8 +3594,10 @@ public class TileProcessor {
...
@@ -3565,8 +3594,10 @@ public class TileProcessor {
clt_parameters
.
plStarOrtho
,
// double orthoWeight,
clt_parameters
.
plStarOrtho
,
// double orthoWeight,
clt_parameters
.
plStarDiag
,
// double diagonalWeight,
clt_parameters
.
plStarDiag
,
// double diagonalWeight,
clt_parameters
.
plStarPwr
,
// double starPwr, // Divide cost by number of connections to this power
clt_parameters
.
plStarPwr
,
// double starPwr, // Divide cost by number of connections to this power
clt_parameters
.
plStarValPwr
,
// double starValPwr, // Raise value of each tile before averaging
clt_parameters
.
plDblTriLoss
,
// double diagonalWeight,
clt_parameters
.
plDblTriLoss
,
// double diagonalWeight,
clt_parameters
.
plNewConfl
,
// boolean preferDisparity, // Allow more conflicts if overall cost is reduced
clt_parameters
.
plNewConfl
,
// boolean preferDisparity, // Allow more conflicts if overall cost is reduced
clt_parameters
.
plMaxChanges
,
// int maxChanges, // Maximal number of simultaneous connection changes around one tile (0 - any)
clt_parameters
.
plPreferDisparity
,
clt_parameters
.
plPreferDisparity
,
1
,
// final int debugLevel)
1
,
// final int debugLevel)
clt_parameters
.
tileX
,
clt_parameters
.
tileX
,
...
...
src/main/java/TwoLayerNeighbors.java
View file @
1183ecd4
...
@@ -68,6 +68,7 @@ public class TwoLayerNeighbors {
...
@@ -68,6 +68,7 @@ public class TwoLayerNeighbors {
int
[][][]
conns
=
new
int
[
PAIRS
.
length
][][];
int
[][][]
conns
=
new
int
[
PAIRS
.
length
][][];
int
[]
selection_star
=
null
;
int
[]
selection_star
=
null
;
int
[]
selection_conns
=
null
;
int
[]
selection_conns
=
null
;
boolean
[][][][]
merge_valid
=
new
boolean
[
9
][][][];
class
NeibVariant
{
class
NeibVariant
{
...
@@ -119,15 +120,16 @@ public class TwoLayerNeighbors {
...
@@ -119,15 +120,16 @@ public class TwoLayerNeighbors {
* @param nl1 start layer to connect (-1 - just disconnect the end)
* @param nl1 start layer to connect (-1 - just disconnect the end)
* @param dir2 direction from the center to the end of the connection (-1 - center)
* @param dir2 direction from the center to the end of the connection (-1 - center)
* @param nl2 end layer to connect (-1 - just disconnect the start)
* @param nl2 end layer to connect (-1 - just disconnect the start)
* @return true if connection is possible (looking at merge_valid)
*/
*/
public
void
connect
(
public
boolean
connect
(
int
dir1
,
int
dir1
,
int
nl1
,
int
nl1
,
int
dir2
,
int
dir2
,
int
nl2
,
int
nl2
,
int
debugLevel
){
int
debugLevel
){
int
dir12
=
getDir2From1
(
dir1
,
dir2
);
int
dir12
=
getDir2From1
(
dir1
,
dir2
);
if
(
dir12
<
0
){
if
(
dir12
<
0
){
throw
new
IllegalArgumentException
(
"Invalid connection from "
+
dir1
+
" to "
+
dir2
+
": resulted in direction 1->2 = "
+
dir12
);
throw
new
IllegalArgumentException
(
"Invalid connection from "
+
dir1
+
" to "
+
dir2
+
": resulted in direction 1->2 = "
+
dir12
);
}
}
if
(
debugLevel
>
1
){
if
(
debugLevel
>
1
){
...
@@ -140,20 +142,55 @@ public class TwoLayerNeighbors {
...
@@ -140,20 +142,55 @@ public class TwoLayerNeighbors {
if
(
nl1
>=
0
){
if
(
nl1
>=
0
){
old_nl2
=
neibs_start
[
nl1
][
dir12
];
// where it was connected before, may be -1
old_nl2
=
neibs_start
[
nl1
][
dir12
];
// where it was connected before, may be -1
if
(
old_nl2
!=
nl2
)
{
if
(
old_nl2
!=
nl2
)
{
if
(!
isValidConn
(
dir1
,
dir12
,
nl1
,
nl2
,
debugLevel
))
{
return
false
;
}
neibs_start
[
nl1
][
dir12
]
=
nl2
;
neibs_start
[
nl1
][
dir12
]
=
nl2
;
}
}
}
}
if
(
nl2
>=
0
){
if
(
nl2
>=
0
){
if
(!
isValidConn
(
dir2
,
dir21
,
nl2
,
nl1
,
debugLevel
))
{
return
false
;
}
old_nl1
=
neibs_end
[
nl2
][
dir21
];
old_nl1
=
neibs_end
[
nl2
][
dir21
];
neibs_end
[
nl2
][
dir21
]
=
nl1
;
neibs_end
[
nl2
][
dir21
]
=
nl1
;
}
}
// reconnect or plug broken links
// reconnect or plug broken links
if
(
old_nl2
>=
0
){
if
(
old_nl2
>=
0
){
if
(!
isValidConn
(
dir2
,
dir21
,
old_nl2
,
old_nl1
,
debugLevel
))
{
return
false
;
}
neibs_end
[
old_nl2
][
dir21
]
=
old_nl1
;
// (old_nl1 may be -1 here)
neibs_end
[
old_nl2
][
dir21
]
=
old_nl1
;
// (old_nl1 may be -1 here)
}
}
if
(
old_nl1
>=
0
){
if
(
old_nl1
>=
0
){
if
(!
isValidConn
(
dir1
,
dir12
,
old_nl1
,
old_nl2
,
debugLevel
))
{
return
false
;
}
neibs_start
[
old_nl1
][
dir12
]
=
old_nl2
;
// (old_nl2 may be -1 here)
neibs_start
[
old_nl1
][
dir12
]
=
old_nl2
;
// (old_nl2 may be -1 here)
}
}
return
true
;
}
boolean
isValidConn
(
int
dir1
,
int
dir12
,
int
nl1
,
int
nl2
,
int
debugLevel
)
{
if
(
nl2
<
0
)
return
true
;
// connection nowhere is always valid;
int
dir8
=
(
dir1
<
0
)
?
8
:
dir1
;
if
((
dir8
>=
merge_valid
.
length
)
||
(
nl1
>=
merge_valid
[
dir8
].
length
)
||
(
dir12
>=
merge_valid
[
dir8
][
nl1
].
length
)
||
(
nl2
>=
merge_valid
[
dir8
][
nl1
][
dir12
].
length
))
{
System
.
out
.
println
(
"BUG in isValidConn("
+
dir1
+
","
+
dir12
+
","
+
nl1
+
","
+
nl2
+
")"
);
return
true
;
}
if
(
merge_valid
[
dir8
][
nl1
][
dir12
][
nl2
])
return
true
;
if
(
debugLevel
>
0
){
System
.
out
.
println
(
" -- Fileterd out connection "
+
dir1
+
":"
+
nl1
+
" in direction "
+
dir12
+
" to layer "
+
nl2
);
}
return
false
;
}
}
public
int
getConnection
(
public
int
getConnection
(
...
@@ -177,8 +214,11 @@ public class TwoLayerNeighbors {
...
@@ -177,8 +214,11 @@ public class TwoLayerNeighbors {
public
void
diffToOther
(
NeibVariant
other_variant
)
public
int
diffToOther
(
NeibVariant
other_variant
,
int
debugLevel
)
{
{
int
numChanges
=
0
;
for
(
int
dir0
=
0
;
dir0
<
neighbors
.
length
;
dir0
++){
for
(
int
dir0
=
0
;
dir0
<
neighbors
.
length
;
dir0
++){
if
((
neighbors
[
dir0
]
!=
null
)
||
(
other_variant
.
neighbors
[
dir0
]
!=
null
)){
if
((
neighbors
[
dir0
]
!=
null
)
||
(
other_variant
.
neighbors
[
dir0
]
!=
null
)){
if
((
neighbors
[
dir0
]
==
null
)
||
(
other_variant
.
neighbors
[
dir0
]
==
null
)){
if
((
neighbors
[
dir0
]
==
null
)
||
(
other_variant
.
neighbors
[
dir0
]
==
null
)){
...
@@ -191,8 +231,11 @@ public class TwoLayerNeighbors {
...
@@ -191,8 +231,11 @@ public class TwoLayerNeighbors {
}
else
{
}
else
{
for
(
int
dir
=
0
;
dir
<
8
;
dir
++){
for
(
int
dir
=
0
;
dir
<
8
;
dir
++){
if
(
neighbors
[
dir0
][
nl
][
dir
]
!=
other_variant
.
neighbors
[
dir0
][
nl
][
dir
]){
if
(
neighbors
[
dir0
][
nl
][
dir
]
!=
other_variant
.
neighbors
[
dir0
][
nl
][
dir
]){
numChanges
++;
if
(
debugLevel
>
0
)
{
System
.
out
.
print
(
" "
+
dir0
+
":"
+
nl
+
":"
+
dir
+
":("
+
neighbors
[
dir0
][
nl
][
dir
]+
"/"
+
System
.
out
.
print
(
" "
+
dir0
+
":"
+
nl
+
":"
+
dir
+
":("
+
neighbors
[
dir0
][
nl
][
dir
]+
"/"
+
other_variant
.
neighbors
[
dir0
][
nl
][
dir
]+
")"
);
other_variant
.
neighbors
[
dir0
][
nl
][
dir
]+
")"
);
}
}
}
}
}
...
@@ -202,9 +245,11 @@ public class TwoLayerNeighbors {
...
@@ -202,9 +245,11 @@ public class TwoLayerNeighbors {
}
}
}
}
}
}
System
.
out
.
println
();
if
(
debugLevel
>
0
)
{
System
.
out
.
println
();
}
return
numChanges
;
}
}
}
}
/**
/**
...
@@ -273,12 +318,15 @@ public class TwoLayerNeighbors {
...
@@ -273,12 +318,15 @@ public class TwoLayerNeighbors {
}
}
for
(
int
dir
=
0
;
dir
<
8
;
dir
++)
if
(
options_around
[
dir
]
>
0
){
for
(
int
dir
=
0
;
dir
<
8
;
dir
++)
if
(
options_around
[
dir
]
>
0
){
// make a first connection, if there are two - other will be created simultaneously
// make a first connection, if there are two - other will be created simultaneously
variant
.
connect
(
if
(!
variant
.
connect
(
// will println when return false
-
1
,
// int dir1,
-
1
,
// int dir1,
((
selection_star
[
dir
]
>
0
)
?
nl2
:
nl1
),
// int nl1,
((
selection_star
[
dir
]
>
0
)
?
nl2
:
nl1
),
// int nl1,
dir
,
// int dir2,
dir
,
// int dir2,
layers_around
[
dir
][
0
],
// int nl2);
layers_around
[
dir
][
0
],
// int nl2);
debugLevel
);
debugLevel
))
{
return
null
;
// such connection was filtered out by filterNeighborPlanes()
}
}
}
if
(
debugLevel
>
1
){
if
(
debugLevel
>
1
){
System
.
out
.
println
();
System
.
out
.
println
();
...
@@ -306,12 +354,14 @@ public class TwoLayerNeighbors {
...
@@ -306,12 +354,14 @@ public class TwoLayerNeighbors {
opts
[
1
]
=
1
;
// assuming there are two variants for the connection end as it should be
opts
[
1
]
=
1
;
// assuming there are two variants for the connection end as it should be
}
}
}
}
variant
.
connect
(
if
(!
variant
.
connect
(
// will println when return false
start_dir
,
// int dir1,
start_dir
,
// int dir1,
layers_around
[
start_dir
][
opts
[
0
]],
// int nl1,
layers_around
[
start_dir
][
opts
[
0
]],
// int nl1,
end_dir
,
// int dir2,
end_dir
,
// int dir2,
layers_around
[
end_dir
][
opts
[
1
]],
// int nl2);
layers_around
[
end_dir
][
opts
[
1
]],
// int nl2);
debugLevel
);
debugLevel
))
{
return
null
;
};
if
(
selection_conns
[
np
]
>
1
){
if
(
selection_conns
[
np
]
>
1
){
// add 3-rd variant if possible, if not - return null
// add 3-rd variant if possible, if not - return null
// if at least one of the unused ends has a pair - connect other ends
// if at least one of the unused ends has a pair - connect other ends
...
@@ -319,12 +369,14 @@ public class TwoLayerNeighbors {
...
@@ -319,12 +369,14 @@ public class TwoLayerNeighbors {
int
nl_end_other
=
layers_around
[
end_dir
][
1
-
opts
[
1
]];
int
nl_end_other
=
layers_around
[
end_dir
][
1
-
opts
[
1
]];
if
(
(
variant
.
getConnection
(
start_dir
,
nl_start_other
,
end_dir
)
>=
0
)
||
if
(
(
variant
.
getConnection
(
start_dir
,
nl_start_other
,
end_dir
)
>=
0
)
||
(
variant
.
getConnection
(
end_dir
,
nl_end_other
,
start_dir
)
>=
0
))
{
(
variant
.
getConnection
(
end_dir
,
nl_end_other
,
start_dir
)
>=
0
))
{
variant
.
connect
(
if
(!
variant
.
connect
(
start_dir
,
// int dir1,
start_dir
,
// int dir1,
nl_start_other
,
// int nl1,
nl_start_other
,
// int nl1,
end_dir
,
// int dir2,
end_dir
,
// int dir2,
nl_end_other
,
// int nl2);
nl_end_other
,
// int nl2);
debugLevel
);
debugLevel
))
{
return
null
;
}
}
else
{
}
else
{
return
null
;
// failed to swap connection - other ends are both not connected
return
null
;
// failed to swap connection - other ends are both not connected
}
}
...
@@ -335,20 +387,30 @@ public class TwoLayerNeighbors {
...
@@ -335,20 +387,30 @@ public class TwoLayerNeighbors {
}
}
return
variant
;
return
variant
;
}
}
public
int
[][][][]
getNeighborVariants
()
public
int
[][][][]
getNeighborVariants
(
int
max_changes
)
{
{
return
getNeighborVariants
(
0
);
return
getNeighborVariants
(
max_changes
,
0
);
}
}
public
int
[][][][]
getNeighborVariants
(
int
debugLevel
)
public
int
[][][][]
getNeighborVariants
(
int
max_changes
,
int
debugLevel
)
{
{
ArrayList
<
NeibVariant
>
variant_list
=
new
ArrayList
<
NeibVariant
>();
ArrayList
<
NeibVariant
>
variant_list
=
new
ArrayList
<
NeibVariant
>();
while
(
nextSelection
()){
while
(
nextSelection
()){
NeibVariant
variant
=
generateVariant
(
debugLevel
);
NeibVariant
variant
=
generateVariant
(
debugLevel
);
if
(
variant
!=
null
){
if
(
variant
!=
null
){
variant_list
.
add
(
variant
);
int
num_changes
=
variant
.
diffToOther
(
neibs_init
,
0
);
if
((
max_changes
==
0
)
||
(
num_changes
<=
max_changes
))
{
variant_list
.
add
(
variant
);
}
if
(
debugLevel
>
0
){
if
(
debugLevel
>
0
){
System
.
out
.
print
(
"getNeighborVariants() "
+(
variant_list
.
size
()-
1
)+
": ["
);
System
.
out
.
print
(
"getNeighborVariants() "
+(
variant_list
.
size
()-
1
));
if
((
max_changes
!=
0
)
&&
(
num_changes
>
max_changes
)){
System
.
out
.
print
(
" -IGNORED (as changes = "
+
num_changes
+
" > "
+
max_changes
+
")"
);
}
System
.
out
.
print
(
": ["
);
for
(
int
i
=
0
;
i
<
selection_star
.
length
;
i
++){
for
(
int
i
=
0
;
i
<
selection_star
.
length
;
i
++){
System
.
out
.
print
(
selection_star
[
i
]);
System
.
out
.
print
(
selection_star
[
i
]);
}
}
...
@@ -357,7 +419,8 @@ public class TwoLayerNeighbors {
...
@@ -357,7 +419,8 @@ public class TwoLayerNeighbors {
System
.
out
.
print
(
selection_conns
[
i
]);
System
.
out
.
print
(
selection_conns
[
i
]);
}
}
System
.
out
.
print
(
"]: "
);
System
.
out
.
print
(
"]: "
);
variant
.
diffToOther
(
neibs_init
);
System
.
out
.
print
(
"CHANGES: "
+
num_changes
+
" "
);
variant
.
diffToOther
(
neibs_init
,
debugLevel
);
}
}
}
}
}
}
...
@@ -374,7 +437,17 @@ public class TwoLayerNeighbors {
...
@@ -374,7 +437,17 @@ public class TwoLayerNeighbors {
{
{
neibs_init
.
setNeighbors
(
neibs
,
dir
);
neibs_init
.
setNeighbors
(
neibs
,
dir
);
}
}
public
void
setMergeValid
(
boolean
[][][]
valid
,
int
dir
)
{
if
(
dir
<
0
){
merge_valid
[
8
]
=
valid
;
}
else
{
merge_valid
[
dir
]
=
valid
;
}
}
public
int
[][]
getInitNeighbors
(
int
dir
)
public
int
[][]
getInitNeighbors
(
int
dir
)
{
{
return
neibs_init
.
getNeighbors
(
dir
);
return
neibs_init
.
getNeighbors
(
dir
);
...
...
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