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
0ef14ecf
Commit
0ef14ecf
authored
Dec 09, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disabled (optionally) alpha in textures, starting subdividing triangular
mesh instead
parent
8c67ed14
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
88 deletions
+144
-88
ExtrinsicAdjustment.java
.../com/elphel/imagej/tileprocessor/ExtrinsicAdjustment.java
+1
-0
OpticalFlow.java
...ain/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
+4
-2
TexturedModel.java
...n/java/com/elphel/imagej/tileprocessor/TexturedModel.java
+126
-80
TileNeibs.java
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
+7
-2
TilePlanes.java
...main/java/com/elphel/imagej/tileprocessor/TilePlanes.java
+6
-4
No files found.
src/main/java/com/elphel/imagej/tileprocessor/ExtrinsicAdjustment.java
View file @
0ef14ecf
...
...
@@ -1996,6 +1996,7 @@ public class ExtrinsicAdjustment {
// find largest terrain area
int
[]
iterrains
=
tn
.
enumerateClusters
(
terrain
,
// boolean [] tiles,
null
,
// int [] num_clusters,
true
);
//boolean ordered)
boolean
[]
terrain_main
=
new
boolean
[
clusters
];
for
(
int
i
=
0
;
i
<
clusters
;
i
++)
{
...
...
src/main/java/com/elphel/imagej/tileprocessor/OpticalFlow.java
View file @
0ef14ecf
...
...
@@ -11761,6 +11761,7 @@ public class OpticalFlow {
int
[]
clusters
=
tn
.
enumerateClusters
(
over_thresh
,
// boolean [] tiles,
null
,
// int [] num_clusters,
false
);
// boolean ordered)
// check clusters contain super-threshold tile
double
max_cluster
=
mov_thresh
*
mov_clust_max
;
// each cluster should have larger tile value to survive
...
...
@@ -11829,6 +11830,7 @@ public class OpticalFlow {
clusters
=
tn
.
enumerateClusters
(
move_mask
,
// boolean [] tiles,
null
,
// int [] num_clusters,
false
);
// boolean ordered)
if
(
show_debug_images
)
{
for
(
int
nTile
=
0
;
nTile
<
motion
.
length
;
nTile
++)
if
(
clusters
[
nTile
]
>
0
){
...
...
src/main/java/com/elphel/imagej/tileprocessor/TexturedModel.java
View file @
0ef14ecf
...
...
@@ -1021,7 +1021,7 @@ public class TexturedModel {
* @param debugLevel debug level - controls generation of images
* @return TileCluster instance generated from the initial source_disparity[] array.
*/
public
static
TileCluster
buildTileCluster
(
public
static
TileCluster
[]
buildTileCluster
(
// used disparity_layers will be set to Double.NaN
// make it in a separate method?
final
ArrayList
<
TileCluster
>
cluster_list
,
...
...
@@ -1371,6 +1371,78 @@ public class TexturedModel {
if
(
num_removed
.
get
()
==
0
)
{
System
.
out
.
println
(
"buildTileCluster() BUG - no tiles removed from disparity_layers[]"
);
}
if
(
debugLevel
>
0
)
{
String
[]
dbg_titles
=
{
"Source"
,
"Intermediate"
,
"Final"
,
"neib_lev0"
,
"neib_lev1"
,
"neib_lev2"
,
"seams"
,
"seams_layers_0"
,
"seams_layers_1"
,
"disparity_layers_0"
,
"disparity_layers_0"
};
double
[][]
dbg_neib_lev
=
new
double
[
6
][
tiles
];
for
(
int
i
=
0
;
i
<
tiles
;
i
++)
{
if
(
dbg_neib_lev_preorph
!=
null
)
{
dbg_neib_lev
[
0
][
i
]
=
10
*
dbg_neib_lev_preorph
[
i
];
}
if
(
dbg_neib_lev_predefined
!=
null
)
{
dbg_neib_lev
[
1
][
i
]
=
10
*
dbg_neib_lev_predefined
[
i
];
}
dbg_neib_lev
[
2
][
i
]
=
10
*
neib_lev
[
i
];
dbg_neib_lev
[
3
][
i
]
=
10
*
seams
[
i
];
dbg_neib_lev
[
4
][
i
]
=
10
*
seams_layers
[
0
][
i
];
dbg_neib_lev
[
5
][
i
]
=
10
*
seams_layers
[
1
][
i
];
}
double
[][]
dbg_img
=
{
source_disparity
,
dbg_disparity1
,
disparity
,
dbg_neib_lev
[
0
],
dbg_neib_lev
[
1
],
dbg_neib_lev
[
2
],
dbg_neib_lev
[
3
],
dbg_neib_lev
[
4
],
dbg_neib_lev
[
5
],
disparity_layers
[
0
],
disparity_layers
[
1
]};
ShowDoubleFloatArrays
.
showArrays
(
dbg_img
,
tilesX
,
tilesY
,
true
,
"source_final_disparity-"
+
String
.
format
(
"%02d"
,
cluster_list
.
size
()-
1
),
dbg_titles
);
}
// Split result into connected clusters
int
[]
pnum_clust
=
new
int
[
1
];
boolean
[]
sel_tiles
=
new
boolean
[
tiles
];
for
(
int
tile
=
0
;
tile
<
tiles
;
tile
++)
{
sel_tiles
[
tile
]
=
neib_lev
[
tile
]
>=
0
;
}
int
[]
enum_clusters
=
tn
.
enumerateClusters
(
sel_tiles
,
pnum_clust
,
false
);
int
num_sub
=
pnum_clust
[
0
];
if
((
debugLevel
>
-
2
)
&&
(
num_sub
>
1
))
{
System
.
out
.
println
(
"buildTileCluster(): splitting textureCluster into "
+
num_sub
+
" connected ones"
);
}
// neib_lev[tile]
// disparity
// border_int
TileCluster
[]
tileClusters
=
new
TileCluster
[
pnum_clust
[
0
]];
for
(
int
nsub
=
0
;
nsub
<
num_sub
;
nsub
++)
{
int
[]
neib_lev_sub
=
(
num_sub
>
1
)
?
(
new
int
[
tiles
]):
neib_lev
;
double
[]
disparity_sub
=
(
num_sub
>
1
)
?
(
new
double
[
tiles
]):
disparity
;
if
(
num_sub
>
1
)
{
Arrays
.
fill
(
neib_lev_sub
,
-
1
);
Arrays
.
fill
(
disparity_sub
,
Double
.
NaN
);
int
indx
=
nsub
+
1
;
for
(
int
tile
=
0
;
tile
<
tiles
;
tile
++)
if
(
enum_clusters
[
tile
]
==
indx
){
neib_lev_sub
[
tile
]
=
neib_lev
[
tile
];
disparity_sub
[
tile
]
=
disparity
[
tile
];
}
}
// find bounds
AtomicInteger
min_y
=
new
AtomicInteger
(
tilesY
);
AtomicInteger
max_y
=
new
AtomicInteger
(
0
);
...
...
@@ -1380,7 +1452,7 @@ public class TexturedModel {
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
tile
=
ai
.
getAndIncrement
();
tile
<
tiles
;
tile
=
ai
.
getAndIncrement
())
if
(
neib_lev
[
tile
]
>=
0
)
{
for
(
int
tile
=
ai
.
getAndIncrement
();
tile
<
tiles
;
tile
=
ai
.
getAndIncrement
())
if
(
neib_lev_sub
[
tile
]
>=
0
)
{
int
tileY
=
tile
/
tilesX
;
int
tileX
=
tile
%
tilesX
;
min_y
.
getAndAccumulate
(
tileY
,
Math:
:
min
);
...
...
@@ -1392,7 +1464,7 @@ public class TexturedModel {
};
}
ImageDtt
.
startAndJoin
(
threads
);
// final boolean sky_cluster = blue_sky_below >=0;
// final boolean sky_cluster = blue_sky_below >=0;
if
(
is_sky_cluster
&&
(
blue_sky_below
>=
0
))
{
// increase bounding box for sky cluster
min_y
.
set
(
0
);
max_y
.
addAndGet
(
blue_sky_below
);
...
...
@@ -1406,7 +1478,7 @@ public class TexturedModel {
final
int
height
=
max_y
.
get
()
-
min_y
.
get
()
+
1
;
final
Rectangle
bounds
=
new
Rectangle
(
min_x
.
get
(),
min_y
.
get
(),
width
,
height
);
final
double
[]
disparity_crop
=
new
double
[
width
*
height
];
// final boolean [] border_crop = new boolean [disparity_crop.length];
// final boolean [] border_crop = new boolean [disparity_crop.length];
final
int
[]
border_int_crop
=
new
int
[
disparity_crop
.
length
];
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
...
...
@@ -1416,8 +1488,8 @@ public class TexturedModel {
int
tileY
=
tile_crop
/
width
+
bounds
.
y
;
int
tileX
=
tile_crop
%
width
+
bounds
.
x
;
int
tile
=
tileX
+
tileY
*
tilesX
;
disparity_crop
[
tile_crop
]
=
disparity
[
tile
];
border_int_crop
[
tile_crop
]
=
neib_lev
[
tile
];
disparity_crop
[
tile_crop
]
=
disparity_sub
[
tile
];
border_int_crop
[
tile_crop
]
=
neib_lev_sub
[
tile
];
}
}
};
...
...
@@ -1425,7 +1497,7 @@ public class TexturedModel {
ImageDtt
.
startAndJoin
(
threads
);
// Create new TileCluster
TileCluster
tileCluster
=
(
new
TileCluster
(
tileClusters
[
nsub
]
=
(
new
TileCluster
(
bounds
,
cluster_list
.
size
(),
// (debug_index? cluster_list.size(): -1),
null
,
// border_crop, // will create from border_int_crop
...
...
@@ -1433,46 +1505,9 @@ public class TexturedModel {
max_neib_lev
,
// int border_int_max, // outer border value
disparity_crop
,
is_sky_cluster
));
// boolean is_sky));
cluster_list
.
add
(
tileCluster
);
if
(
debugLevel
>
0
)
{
String
[]
dbg_titles
=
{
"Source"
,
"Intermediate"
,
"Final"
,
"neib_lev0"
,
"neib_lev1"
,
"neib_lev2"
,
"seams"
,
"seams_layers_0"
,
"seams_layers_1"
,
"disparity_layers_0"
,
"disparity_layers_0"
};
double
[][]
dbg_neib_lev
=
new
double
[
6
][
tiles
];
for
(
int
i
=
0
;
i
<
tiles
;
i
++)
{
if
(
dbg_neib_lev_preorph
!=
null
)
{
dbg_neib_lev
[
0
][
i
]
=
10
*
dbg_neib_lev_preorph
[
i
];
}
if
(
dbg_neib_lev_predefined
!=
null
)
{
dbg_neib_lev
[
1
][
i
]
=
10
*
dbg_neib_lev_predefined
[
i
];
cluster_list
.
add
(
tileClusters
[
nsub
]);
}
dbg_neib_lev
[
2
][
i
]
=
10
*
neib_lev
[
i
];
dbg_neib_lev
[
3
][
i
]
=
10
*
seams
[
i
];
dbg_neib_lev
[
4
][
i
]
=
10
*
seams_layers
[
0
][
i
];
dbg_neib_lev
[
5
][
i
]
=
10
*
seams_layers
[
1
][
i
];
}
double
[][]
dbg_img
=
{
source_disparity
,
dbg_disparity1
,
disparity
,
dbg_neib_lev
[
0
],
dbg_neib_lev
[
1
],
dbg_neib_lev
[
2
],
dbg_neib_lev
[
3
],
dbg_neib_lev
[
4
],
dbg_neib_lev
[
5
],
disparity_layers
[
0
],
disparity_layers
[
1
]};
ShowDoubleFloatArrays
.
showArrays
(
dbg_img
,
tilesX
,
tilesY
,
true
,
"source_final_disparity-"
+
String
.
format
(
"%02d"
,
cluster_list
.
size
()-
1
),
dbg_titles
);
}
return
tileCluster
;
return
tileClusters
;
}
/**
...
...
@@ -1616,7 +1651,7 @@ public class TexturedModel {
final
double
disp_adiff
=
disp_fof
*
disp_adiffd
;
// should already include disp_fof,
final
double
disp_rdiff
=
disp_fof
*
disp_rdiffd
;
// should already include disp_fof,
TileCluster
tileCluster
=
buildTileCluster
(
TileCluster
[]
tileClusters
=
buildTileCluster
(
// used disparity_layers will be set to Double.NaN
// make it in a separate method?
cluster_list
,
// final ArrayList <TileCluster> cluster_list,
...
...
@@ -1634,10 +1669,10 @@ public class TexturedModel {
// if (debugLevel > -1000) {
// return null;
// }
for
(
int
nsub
=
0
;
nsub
<
tileClusters
.
length
;
nsub
++)
{
updateSeeds
(
// and update num_neibs_dir
num_neibs_dir
,
// final int [][] num_neibs_dir, // [tile][layer]
tileCluster
.
getBounds
(),
// final Rectangle bounds, // null - all
tileClusters
[
nsub
]
.
getBounds
(),
// final Rectangle bounds, // null - all
disparity_layers
,
// final double [][] disparity_layers, // [layer][tile]should not have same tile disparity on multiple layers
blue_sky
,
// final boolean [] blue_sky, // use to expand background by blurring available data?
blue_sky_layer
,
// final int blue_sky_layer,
...
...
@@ -1648,6 +1683,7 @@ public class TexturedModel {
disp_fof
,
// final double disp_fof, // enable higher difference (scale) for fried of a friend
tilesX
,
// final int tilesX,
debugLevel
);
// final int debugLevel)
}
if
(
debugLevel
>
1
)
{
String
[]
dbg_titles
=
{
"FG"
,
"BG"
};
double
[][]
dbg_img
=
new
double
[
layers
][
tiles
];
...
...
@@ -1919,10 +1955,12 @@ public class TexturedModel {
}
boolean
renormalize
=
true
;
// false - use normalizations from previous scenes to keep consistent colors
final
boolean
no_alpha
=
true
;
ImagePlus
[]
combined_textures
=
getInterCombinedTextures
(
// return ImagePlus[] matching tileClusters[], with alpha
clt_parameters
,
// final CLTParameters clt_parameters,
colorProcParameters
,
// ColorProcParameters colorProcParameters,
rgbParameters
,
// EyesisCorrectionParameters.RGBParameters rgbParameters,
no_alpha
,
// final boolean no_alpha,
parameter_scene
,
// final QuadCLT parameter_scene, // to use for rendering parameters in multi-series sequences
// if null - use reference scene
ref_index
,
// final int ref_index,
...
...
@@ -4077,6 +4115,7 @@ public class TexturedModel {
final
CLTParameters
clt_parameters
,
ColorProcParameters
colorProcParameters
,
EyesisCorrectionParameters
.
RGBParameters
rgbParameters
,
final
boolean
no_alpha
,
QuadCLT
parameter_scene
,
final
int
ref_index
,
final
QuadCLT
[]
scenes
,
...
...
@@ -4584,6 +4623,13 @@ public class TexturedModel {
ImagePlus
[]
imp_tex
=
new
ImagePlus
[
num_slices
];
for
(
int
nslice
=
0
;
nslice
<
num_slices
;
nslice
++)
{
String
title
=
String
.
format
(
"%s-combo%03d-texture"
,
ref_scene
.
getImageName
(),
nslice
);
double
[][]
rendered_texture
=
faded_textures
[
nslice
];
if
(
no_alpha
)
{
rendered_texture
[
1
]
=
new
double
[
rendered_texture
[
0
].
length
];
for
(
int
i
=
0
;
i
<
rendered_texture
[
0
].
length
;
i
++)
{
rendered_texture
[
1
][
i
]
=
Double
.
isNaN
(
rendered_texture
[
0
][
i
])?
0.0
:
1.0
;
}
}
imp_tex
[
nslice
]
=
QuadCLTCPU
.
linearStackToColorLWIR
(
clt_parameters
,
// CLTParameters clt_parameters,
tex_palette
,
// int lwir_palette, // <0 - do not convert
...
...
@@ -4591,7 +4637,7 @@ public class TexturedModel {
title
,
// String name,
""
,
// String suffix, // such as disparity=...
tex_color
,
// boolean toRGB,
faded_textures
[
nslice
],
// double [][] texture_data,
rendered_texture
,
//
faded_textures[nslice], // double [][] texture_data,
tilesX
*
transform_size
,
// int width, // int tilesX,
tilesY
*
transform_size
,
// int height, // int tilesY,
debugLevel
);
// int debugLevel )
...
...
src/main/java/com/elphel/imagej/tileprocessor/TileNeibs.java
View file @
0ef14ecf
...
...
@@ -616,11 +616,13 @@ public class TileNeibs{
/**
* Enumerate clusters on rectangular area
* @param tiles selected tiles, size should be sizeX * sizeY
* @param num_clusters if non null, will return number of clusters
* @param ordered if true, order tiles from largest to smallest5
* @return integer array, where 0 is unused, 1+ cluster it belongs to
*/
public
int
[]
enumerateClusters
(
boolean
[]
tiles
,
int
[]
num_clusters
,
boolean
ordered
)
{
int
[]
waves
=
new
int
[
tiles
.
length
];
...
...
@@ -652,6 +654,9 @@ public class TileNeibs{
}
}
}
if
(
num_clusters
!=
null
)
{
num_clusters
[
0
]
=
numClust
;
}
if
(!
ordered
)
{
return
enum_clust
;
}
...
...
src/main/java/com/elphel/imagej/tileprocessor/TilePlanes.java
View file @
0ef14ecf
...
...
@@ -5660,6 +5660,7 @@ public class TilePlanes {
null
);
// boolean [] prohibit,
int
[]
clusters
=
tileNeibs
.
enumerateClusters
(
grown_sel
,
// boolean [] tiles,
null
,
// int [] num_clusters,
false
);
// boolean ordered)
int
num_clusters
=
TileNeibs
.
getMax
(
...
...
@@ -5698,6 +5699,7 @@ public class TilePlanes {
int
[]
dbg_clusters
=
clusters
.
clone
();
clusters
=
tileNeibs
.
enumerateClusters
(
grown_sel
,
// boolean [] tiles,
null
,
// int [] num_clusters,
false
);
// boolean ordered)
num_clusters
=
TileNeibs
.
getMax
(
clusters
);
...
...
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