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
8d62abba
Commit
8d62abba
authored
Jul 09, 2017
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on high disparity objects
parent
21cc4033
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1217 additions
and
468 deletions
+1217
-468
AlignmentCorrection.java
src/main/java/AlignmentCorrection.java
+197
-62
CLTPass3d.java
src/main/java/CLTPass3d.java
+173
-7
EyesisCorrectionParameters.java
src/main/java/EyesisCorrectionParameters.java
+143
-42
Eyesis_Correction.java
src/main/java/Eyesis_Correction.java
+6
-9
QuadCLT.java
src/main/java/QuadCLT.java
+320
-238
SuperTiles.java
src/main/java/SuperTiles.java
+73
-19
TileNeibs.java
src/main/java/TileNeibs.java
+47
-0
TilePlanes.java
src/main/java/TilePlanes.java
+5
-3
TileProcessor.java
src/main/java/TileProcessor.java
+253
-88
No files found.
src/main/java/AlignmentCorrection.java
View file @
8d62abba
This diff is collapsed.
Click to expand it.
src/main/java/CLTPass3d.java
View file @
8d62abba
...
...
@@ -51,7 +51,7 @@ public class CLTPass3d{
public
boolean
[]
border_tiles
=
null
;
// these are border tiles, zero out alpha
public
boolean
[]
selected
=
null
;
// which tiles are selected for this layer
public
double
[][][][]
texture_tiles
;
public
double
[][]
max_tried_disparity
=
null
;
//[ty][tx] used for combined passes, shows maximal disparity
w
or this tile, regardless of results
public
double
[][]
max_tried_disparity
=
null
;
//[ty][tx] used for combined passes, shows maximal disparity
f
or this tile, regardless of results
public
boolean
is_combo
=
false
;
public
boolean
is_measured
=
false
;
public
String
texture
=
null
;
// relative (to x3d) path
...
...
@@ -190,6 +190,7 @@ public class CLTPass3d{
*/
public
double
[][]
getDiffs
(){
if
(
disparity_map
==
null
)
return
null
;
double
[][]
these_diffs
=
new
double
[
ImageDtt
.
QUAD
][];
for
(
int
i
=
0
;
i
<
ImageDtt
.
QUAD
;
i
++)
these_diffs
[
i
]
=
disparity_map
[
ImageDtt
.
IMG_DIFF0_INDEX
+
i
];
return
these_diffs
;
...
...
@@ -208,6 +209,10 @@ public class CLTPass3d{
return
selected
;
}
public
boolean
[]
getBorderTiles
(){
return
this
.
border_tiles
;
}
public
void
setSelected
(
boolean
[]
selected
)
{
this
.
selected
=
selected
;
}
...
...
@@ -444,7 +449,7 @@ public class CLTPass3d{
* Replaces current combo disparity for tiles that are weak and do not have any neighbor within disparity range from this one
* @param selection optional boolean mask of tiles to use/update
* @param weakStrength maximal strength of the tile to be considered weak one
* @param maxDiff maximal difference from the most similar neighbor to be considered an outl
ay
er
* @param maxDiff maximal difference from the most similar neighbor to be considered an outl
i
er
* @param disparityFar minimal acceptable disparity for weak tiles
* @param disparityNear maximal acceptable disparity for weak tiles
* @return mask of weak (replaced) tiles
...
...
@@ -455,8 +460,8 @@ public class CLTPass3d{
final
boolean
[]
selection
,
final
double
weakStrength
,
// strength to be considered weak, subject to this replacement
final
double
maxDiff
,
final
double
maxDiffPos
,
// Replace weak outl
ay
er tiles that have higher disparity than weighted average
final
double
maxDiffNeg
,
// Replace weak outl
ay
er tiles that have lower disparity than weighted average
final
double
maxDiffPos
,
// Replace weak outl
i
er tiles that have higher disparity than weighted average
final
double
maxDiffNeg
,
// Replace weak outl
i
er tiles that have lower disparity than weighted average
final
double
disparityFar
,
final
double
disparityNear
,
final
int
debugLevel
)
...
...
@@ -474,7 +479,7 @@ public class CLTPass3d{
final
double
absMaxDisparity
=
1.5
*
disparityNear
;
// change?
final
int
dbg_nTile
=
(
debugLevel
>
0
)
?
43493
:
-
1
;
// x=77,y=134; // 42228; // x = 108, y = 130 46462; // 41545;
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
tileProcessor
.
threadsMax
);
// first pass = find outl
ay
ers
// first pass = find outl
i
ers
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
...
...
@@ -507,7 +512,7 @@ public class CLTPass3d{
sw
+=
w
;
sd
+=
w
*
disparity
[
nTile1
];
hasNeighbors
=
true
;
if
(
Math
.
abs
(
disparity
[
nTile
]-
disparity
[
nTile1
])
<=
maxDiff
){
// any outl
ay
er - will be false
if
(
Math
.
abs
(
disparity
[
nTile
]-
disparity
[
nTile1
])
<=
maxDiff
){
// any outl
i
er - will be false
weakOutlayers
[
nTile
]
=
false
;
// break;
}
...
...
@@ -531,7 +536,7 @@ public class CLTPass3d{
}
ImageDtt
.
startAndJoin
(
threads
);
// second pass - replace outl
ay
ers
// second pass - replace outl
i
ers
final
double
[]
src_disparity
=
disparity
.
clone
();
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
...
@@ -580,6 +585,167 @@ public class CLTPass3d{
return
weakOutlayers
;
}
public
boolean
[]
getUntestedBackgroundBorder
(
final
boolean
[]
known
,
final
double
[]
disparity
,
final
double
grow_disp_step
,
final
int
debugLevel
)
{
final
int
tilesX
=
tileProcessor
.
getTilesX
();
final
int
tilesY
=
tileProcessor
.
getTilesY
();
final
int
num_tiles
=
tilesX
*
tilesY
;
final
TileNeibs
tnImage
=
new
TileNeibs
(
tilesX
,
tilesY
);
// num_tiles/tilesX);
final
boolean
[]
untested_bgnd
=
new
boolean
[
num_tiles
];
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
num_tiles
;
nTile
=
ai
.
getAndIncrement
())
{
if
(
known
[
nTile
]){
int
tX
=
nTile
%
tilesX
;
int
tY
=
nTile
/
tilesX
;
double
max_disp
=
max_tried_disparity
[
tY
][
tX
]
+
grow_disp_step
;
for
(
int
dir
=
0
;
dir
<
8
;
dir
++){
int
nTile1
=
tnImage
.
getNeibIndex
(
nTile
,
dir
);
if
((
nTile1
>=
0
)
&&
known
[
nTile1
]
&&
(
disparity
[
nTile1
]
>
max_disp
))
{
untested_bgnd
[
nTile
]
=
true
;
break
;
}
}
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
untested_bgnd
;
}
public
boolean
[]
measuredTiles
()
{
final
int
tilesX
=
tileProcessor
.
getTilesX
();
final
int
tilesY
=
tileProcessor
.
getTilesY
();
final
int
num_tiles
=
tilesX
*
tilesY
;
final
boolean
[]
measured
=
new
boolean
[
num_tiles
];
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
num_tiles
;
nTile
=
ai
.
getAndIncrement
())
{
int
tX
=
nTile
%
tilesX
;
int
tY
=
nTile
/
tilesX
;
measured
[
nTile
]
=
tile_op
[
tY
][
tX
]
!=
0
;
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
measured
;
}
public
double
[]
getSecondMaxDiff
(
final
boolean
averaged
)
{
final
double
[][]
diffs
=
getDiffs
();
if
(
diffs
==
null
)
return
null
;
final
int
tilesX
=
tileProcessor
.
getTilesX
();
final
int
tilesY
=
tileProcessor
.
getTilesY
();
final
int
num_tiles
=
tilesX
*
tilesY
;
final
double
[]
second_max
=
new
double
[
num_tiles
];
final
boolean
[]
measured
=
measuredTiles
();
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
num_tiles
;
nTile
=
ai
.
getAndIncrement
())
{
int
imax1
=
0
;
for
(
int
ip
=
1
;
ip
<
diffs
.
length
;
ip
++){
if
(
diffs
[
ip
][
nTile
]
>
diffs
[
imax1
][
nTile
])
imax1
=
ip
;
}
int
imax2
=
(
imax1
==
0
)?
1
:
0
;
for
(
int
ip
=
0
;
ip
<
diffs
.
length
;
ip
++)
if
(
ip
!=
imax1
)
{
if
(
diffs
[
ip
][
nTile
]
>
diffs
[
imax2
][
nTile
])
imax2
=
ip
;
}
second_max
[
nTile
]
=
diffs
[
imax2
][
nTile
];
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
if
(!
averaged
)
return
second_max
;
final
TileNeibs
tnImage
=
new
TileNeibs
(
tilesX
,
tilesY
);
// num_tiles/tilesX);
final
double
[]
second_max_averaged
=
new
double
[
num_tiles
];
final
double
[]
dir_weights
=
{
1.0
/
16
,
1.0
/
8
,
1.0
/
16
,
1.0
/
8
,
1.0
/
16
,
1.0
/
8
,
1.0
/
16
,
1.0
/
8
,
1.0
/
4
};
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
num_tiles
;
nTile
=
ai
.
getAndIncrement
())
if
(
measured
[
nTile
])
{
double
sw
=
0.0
;
double
swd
=
0.0
;
for
(
int
dir
=
0
;
dir
<
9
;
dir
++){
// including 8 - center
int
nTile1
=
tnImage
.
getNeibIndex
(
nTile
,
dir
);
if
((
nTile1
>=
0
)
&&
measured
[
nTile1
])
{
sw
+=
dir_weights
[
dir
];
swd
+=
dir_weights
[
dir
]
*
second_max
[
nTile1
]
;
}
}
second_max_averaged
[
nTile
]
=
swd
/
sw
;
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
second_max_averaged
;
}
// same, but 2 steps around
public
boolean
[]
getUntestedBackgroundBorder2
(
final
boolean
[]
known
,
final
double
[]
disparity
,
final
double
grow_disp_step
,
final
int
debugLevel
)
{
final
int
tilesX
=
tileProcessor
.
getTilesX
();
final
int
tilesY
=
tileProcessor
.
getTilesY
();
final
int
num_tiles
=
tilesX
*
tilesY
;
final
TileNeibs
tnImage
=
new
TileNeibs
(
tilesX
,
tilesY
);
// num_tiles/tilesX);
final
boolean
[]
untested_bgnd
=
new
boolean
[
num_tiles
];
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
tileProcessor
.
threadsMax
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
nTile
=
ai
.
getAndIncrement
();
nTile
<
num_tiles
;
nTile
=
ai
.
getAndIncrement
())
{
if
(
known
[
nTile
]){
int
tX
=
nTile
%
tilesX
;
int
tY
=
nTile
/
tilesX
;
double
max_disp
=
max_tried_disparity
[
tY
][
tX
]
+
grow_disp_step
;
for
(
int
dir
=
0
;
dir
<
24
;
dir
++){
int
nTile1
=
tnImage
.
getNeibIndex2
(
nTile
,
dir
);
if
((
nTile1
>=
0
)
&&
known
[
nTile1
]
&&
(
disparity
[
nTile1
]
>
max_disp
))
{
untested_bgnd
[
nTile
]
=
true
;
break
;
}
}
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
untested_bgnd
;
}
public
SuperTiles
getSuperTiles
()
{
return
this
.
superTiles
;
...
...
src/main/java/EyesisCorrectionParameters.java
View file @
8d62abba
This diff is collapsed.
Click to expand it.
src/main/java/Eyesis_Correction.java
View file @
8d62abba
...
...
@@ -4548,7 +4548,9 @@ private Panel panel1,
}
///========================================
int
num_infinity_corr
=
infinity_corr
?
CLT_PARAMETERS
.
inf_repeat
:
1
;
if
(
num_infinity_corr
<
1
)
num_infinity_corr
=
1
;
for
(
int
i_infinity_corr
=
0
;
i_infinity_corr
<
num_infinity_corr
;
i_infinity_corr
++)
{
QUAD_CLT
.
processCLTQuadCorrs
(
CLT_PARAMETERS
,
// EyesisCorrectionParameters.DCTParameters dct_parameters,
DEBAYER_PARAMETERS
,
//EyesisCorrectionParameters.DebayerParameters debayerParameters,
...
...
@@ -4563,7 +4565,7 @@ private Panel panel1,
THREADS_MAX
,
//final int threadsMax, // maximal number of threads to launch
UPDATE_STATUS
,
//final boolean updateStatus,
DEBUG_LEVEL
);
//final int debugLevel);
}
if
(
configPath
!=
null
)
{
saveTimestampedProperties
(
// save config again
configPath
,
// full path or null
...
...
@@ -4609,20 +4611,15 @@ private Panel panel1,
System
.
out
.
println
(
"Created new QuadCLT instance, will need to read CLT kernels"
);
}
}
/*
QUAD_CLT.process_fine_corr(
dry_run, // boolean dry_run
CLT_PARAMETERS,
DEBUG_LEVEL);
*/
QUAD_CLT
.
processLazyEye
(
dry_run
,
// boolean dry_run
CLT_PARAMETERS
,
DEBUG_LEVEL
);
return
;
}
else
if
(
label
.
equals
(
"CLT ext infinity corr"
))
{
// boolean dry_run = label.equals("CLT test fine corr");
DEBUG_LEVEL
=
MASTER_DEBUG_LEVEL
;
if
(
QUAD_CLT
==
null
){
QUAD_CLT
=
new
QuadCLT
(
...
...
src/main/java/QuadCLT.java
View file @
8d62abba
This diff is collapsed.
Click to expand it.
src/main/java/SuperTiles.java
View file @
8d62abba
This diff is collapsed.
Click to expand it.
src/main/java/TileNeibs.java
View file @
8d62abba
...
...
@@ -104,6 +104,53 @@ public class TileNeibs{
default
:
return
indx
;
}
}
/**
* Get 2d element index after step N, NE, ... NW. Returns -1 if leaving array
* And 2 steps for dir = 8(N), 9(NNE),..23(NNW)
* @param indx start index
* @param dir step direction (CW from up)
* @return new index or -1 if leaving
*/
int
getNeibIndex2
(
int
indx
,
int
dir
)
{
int
y
=
indx
/
sizeX
;
int
x
=
indx
%
sizeX
;
if
(
dir
<
0
)
return
indx
;
if
(
dir
>
24
)
{
System
.
out
.
println
(
"getNeibIndex(): indx="
+
indx
+
", dir="
+
dir
);
}
// switch (dir % dirs){
switch
(
dir
){
case
0
:
return
(
y
==
0
)
?
-
1
:
(
indx
-
sizeX
);
case
1
:
return
((
y
==
0
)
||
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
-
sizeX
+
1
);
case
2
:
return
(
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
+
1
);
case
3
:
return
((
y
==
(
sizeY
-
1
))
||
(
x
==
(
sizeX
-
1
)))
?
-
1
:
(
indx
+
sizeX
+
1
);
case
4
:
return
((
y
==
(
sizeY
-
1
))
)
?
-
1
:
(
indx
+
sizeX
);
case
5
:
return
((
y
==
(
sizeY
-
1
))
||
(
x
==
0
))
?
-
1
:
(
indx
+
sizeX
-
1
);
case
6
:
return
(
(
x
==
0
))
?
-
1
:
(
indx
-
1
);
case
7
:
return
((
y
==
0
)
||
(
x
==
0
))
?
-
1
:
(
indx
-
sizeX
-
1
);
case
8
:
return
(
y
<
2
)
?
-
1
:
(
indx
-
2
*
sizeX
);
case
9
:
return
((
y
<
2
)
||
(
x
>
(
sizeX
-
2
)))
?
-
1
:
(
indx
-
2
*
sizeX
+
1
);
case
10
:
return
((
y
<
2
)
||
(
x
>
(
sizeX
-
3
)))
?
-
1
:
(
indx
-
2
*
sizeX
+
2
);
case
11
:
return
((
y
<
1
)
||
(
x
>
(
sizeX
-
3
)))
?
-
1
:
(
indx
-
1
*
sizeX
+
2
);
case
12
:
return
(
(
x
>
(
sizeX
-
3
)))
?
-
1
:
(
indx
+
2
);
case
13
:
return
((
y
>
(
sizeY
-
2
))
||
(
x
>
(
sizeX
-
3
)))
?
-
1
:
(
indx
+
1
*
sizeX
+
2
);
case
14
:
return
((
y
>
(
sizeY
-
3
))
||
(
x
>
(
sizeX
-
3
)))
?
-
1
:
(
indx
+
2
*
sizeX
+
2
);
case
15
:
return
((
y
>
(
sizeY
-
3
))
||
(
x
>
(
sizeX
-
2
)))
?
-
1
:
(
indx
+
2
*
sizeX
+
1
);
case
16
:
return
((
y
>
(
sizeY
-
3
))
)
?
-
1
:
(
indx
+
2
*
sizeX
);
case
17
:
return
((
y
>
(
sizeY
-
3
))
||
(
x
<
1
))
?
-
1
:
(
indx
+
2
*
sizeX
-
1
);
case
18
:
return
((
y
>
(
sizeY
-
3
))
||
(
x
<
2
))
?
-
1
:
(
indx
+
2
*
sizeX
-
2
);
case
19
:
return
((
y
>
(
sizeY
-
2
))
||
(
x
<
2
))
?
-
1
:
(
indx
+
1
*
sizeX
-
2
);
case
20
:
return
(
(
x
<
2
))
?
-
1
:
(
indx
-
2
);
case
21
:
return
((
y
<
1
)
||
(
x
<
2
))
?
-
1
:
(
indx
-
1
*
sizeX
-
2
);
case
22
:
return
((
y
<
2
)
||
(
x
<
2
))
?
-
1
:
(
indx
-
2
*
sizeX
-
2
);
case
23
:
return
((
y
<
2
)
||
(
x
<
1
))
?
-
1
:
(
indx
-
2
*
sizeX
-
1
);
default
:
return
indx
;
}
}
/**
* Return tile segment for 50% overlap. -1 - center, 0 N, 1 - NE,... 7 - NW
...
...
src/main/java/TilePlanes.java
View file @
8d62abba
...
...
@@ -1383,10 +1383,10 @@ public class TilePlanes {
swx
/=
sw
;
swy
/=
sw
;
double
kz
=
((
dispNorm
>
0.0
)
&&
(
swz
>
dispNorm
))
?
(
dispNorm
/
swz
)
:
1.0
;
//
double kz = ((dispNorm > 0.0) && (swz > dispNorm)) ? (dispNorm / swz) : 1.0;
if
(
debugLevel
>
0
){
System
.
out
.
println
(
"getPlaneFromMeas(): num_tiles="
+
num_tiles
+
", sw = "
+
sw
+
", swz = "
+
swz
+
", swx = "
+
swx
+
", swy = "
+
swy
+
", kz="
+
kz
);
System
.
out
.
println
(
"getPlaneFromMeas(): num_tiles="
+
num_tiles
+
", sw = "
+
sw
+
", swz = "
+
swz
+
", swx = "
+
swx
+
", swy = "
+
swy
);
//
+", kz="+kz);
}
// TODO: scale disparity to make same scale for 3 axes?
...
...
@@ -1397,7 +1397,8 @@ public class TilePlanes {
if
(
tile_sel
[
nl
][
indx
])
{
double
w
=
disp_str
[
nl
][
1
][
indx
]
/
sw
;
if
(
w
>
0.0
){
double
d
=
kz
*
(
disp_str
[
nl
][
0
][
indx
]
-
swz
);
// double d = kz * (disp_str[nl][0][indx] - swz); // Not here!
double
d
=
disp_str
[
nl
][
0
][
indx
]
-
swz
;
double
wd
=
w
*
d
;
double
x
=
((
indx
%
stSize2
)
-
stSize
+
0.5
)
*
tileSize
+
0.5
-
swx
;
double
y
=
((
indx
/
stSize2
)
-
stSize
+
0.5
)
*
tileSize
+
0.5
-
swy
;
...
...
@@ -3795,6 +3796,7 @@ public class TilePlanes {
double
smplRms
,
// = 0.1; // Maximal RMS of the remaining tiles in a sample
int
debugLevel
)
{
if
(
debugLevel
>
2
)
debugLevel
++;
// no show all eigen stuff (debugLevel > 3)
// first make a plane from all tiles
ArrayList
<
PlaneData
>
st_planes
=
new
ArrayList
<
PlaneData
>();
...
...
src/main/java/TileProcessor.java
View file @
8d62abba
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