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
2408288a
Commit
2408288a
authored
Dec 22, 2022
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added debug for alpha->mesh
parent
5893bc5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
171 additions
and
19 deletions
+171
-19
TexturedModel.java
...n/java/com/elphel/imagej/tileprocessor/TexturedModel.java
+20
-6
TriMesh.java
src/main/java/com/elphel/imagej/x3d/export/TriMesh.java
+151
-13
No files found.
src/main/java/com/elphel/imagej/tileprocessor/TexturedModel.java
View file @
2408288a
...
@@ -2020,7 +2020,7 @@ public class TexturedModel {
...
@@ -2020,7 +2020,7 @@ public class TexturedModel {
}
}
double
alpha_threshold
=
0.5
;
double
alpha_threshold
=
0.5
;
boolean
[][]
combined_alphas
=
null
;
boolean
[][]
combined_alphas
=
null
;
if
(
subdiv_tiles
>
0
)
{
if
(
subdiv_tiles
>
0
)
{
// Use subdiv_tiles==1 to keep alpha
combined_alphas
=
new
boolean
[
faded_textures
.
length
][
faded_textures
[
0
][
0
].
length
];
combined_alphas
=
new
boolean
[
faded_textures
.
length
][
faded_textures
[
0
][
0
].
length
];
for
(
int
i
=
0
;
i
<
faded_textures
.
length
;
i
++)
{
// TODO: accelerate with multi
for
(
int
i
=
0
;
i
<
faded_textures
.
length
;
i
++)
{
// TODO: accelerate with multi
for
(
int
j
=
0
;
j
<
faded_textures
[
i
][
1
].
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
faded_textures
[
i
][
1
].
length
;
j
++)
{
...
@@ -2086,16 +2086,16 @@ public class TexturedModel {
...
@@ -2086,16 +2086,16 @@ public class TexturedModel {
}
}
}
}
num_clusters
++;
// was cluster with largest index, became number of clusters
num_clusters
++;
// was cluster with largest index, became number of clusters
final
double
[][]
dbg_tri_disp
=
debug_disp_tri
?
(
new
double
[
tileClusters
.
length
][
width
*
height
]):
null
;
final
double
[][]
dbg_tri_disp
=
debug_disp_tri
?
(
new
double
[
tileClusters
.
length
][
width
*
height
]):
null
;
final
double
[][]
dbg_tri_tri
=
debug_disp_tri
?
(
new
double
[
tileClusters
.
length
][
width
*
height
]):
null
;
final
double
[][]
dbg_tri_tri
=
debug_disp_tri
?
(
new
double
[
tileClusters
.
length
][
width
*
height
]):
null
;
boolean
showTri
=
!
batch_mode
&&
(
debugLevel
>
-
1
)
&&
(
clt_parameters
.
show_triangles
);
boolean
showTri
=
!
batch_mode
&&
(
debugLevel
>
-
1
)
&&
(
clt_parameters
.
show_triangles
);
int
dbg_scale_mesh
=
4
;
// <=0 - do not show
int
dbg_scale_mesh
=
4
;
// <=0 - do not show
int
dbg_scaled_width
=
tp
.
getTilesX
()
*
transform_size
*
dbg_scale_mesh
;
int
dbg_scaled_width
=
tp
.
getTilesX
()
*
transform_size
*
dbg_scale_mesh
;
int
dbg_scaled_height
=
tp
.
getTilesY
()
*
transform_size
*
dbg_scale_mesh
;
int
dbg_scaled_height
=
tp
.
getTilesY
()
*
transform_size
*
dbg_scale_mesh
;
boolean
debug_alpha
=
false
;
double
[][]
dbg_mesh_imgs
=
null
;
double
[][]
dbg_mesh_imgs
=
null
;
if
(
dbg_scale_mesh
>
0
)
{
if
(
dbg_scale_mesh
>
0
)
{
debug_alpha
=
true
;
dbg_mesh_imgs
=
new
double
[
tileClusters
.
length
][
dbg_scaled_width
*
dbg_scaled_height
];
dbg_mesh_imgs
=
new
double
[
tileClusters
.
length
][
dbg_scaled_width
*
dbg_scaled_height
];
// maybe fill with NaN?
// maybe fill with NaN?
}
}
...
@@ -2120,6 +2120,7 @@ public class TexturedModel {
...
@@ -2120,6 +2120,7 @@ public class TexturedModel {
int
cluster_index
=
indices
[
sub_i
];
int
cluster_index
=
indices
[
sub_i
];
ImagePlus
imp_texture_cluster
=
combined_textures
[
nslice
];
ImagePlus
imp_texture_cluster
=
combined_textures
[
nslice
];
boolean
[]
alpha
=
(
combined_alphas
!=
null
)
?
combined_alphas
[
nslice
]
:
null
;
boolean
[]
alpha
=
(
combined_alphas
!=
null
)
?
combined_alphas
[
nslice
]
:
null
;
double
[]
dbg_alpha
=
debug_alpha
?
faded_textures
[
nslice
][
1
]
:
null
;
if
(
imp_textures
!=
null
)
{
// wrong? roi is in tiles or pixels?
if
(
imp_textures
!=
null
)
{
// wrong? roi is in tiles or pixels?
//transform_size
//transform_size
imp_texture_cluster
=
imp_textures
[
cluster_index
];
imp_texture_cluster
=
imp_textures
[
cluster_index
];
...
@@ -2137,6 +2138,18 @@ public class TexturedModel {
...
@@ -2137,6 +2138,18 @@ public class TexturedModel {
row
*
alpha_width
,
row
*
alpha_width
,
alpha_width
);
alpha_width
);
}
}
if
(
dbg_alpha
!=
null
)
{
dbg_alpha
=
new
double
[
alpha_width
*
alpha_height
];
for
(
int
row
=
0
;
row
<
alpha_height
;
row
++)
{
System
.
arraycopy
(
faded_textures
[
nslice
][
1
],
(
alpha_y0
+
row
)
*
width
+
alpha_x0
,
dbg_alpha
,
row
*
alpha_width
,
alpha_width
);
}
}
}
}
}
}
if
(
imp_texture_cluster
==
null
)
{
if
(
imp_texture_cluster
==
null
)
{
...
@@ -2186,6 +2199,7 @@ public class TexturedModel {
...
@@ -2186,6 +2199,7 @@ public class TexturedModel {
(
imp_textures
==
null
),
// boolean full_texture, // true - full size image, false - bounds only
(
imp_textures
==
null
),
// boolean full_texture, // true - full size image, false - bounds only
subdiv_tiles
,
// int subdivide_mesh, // 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels
subdiv_tiles
,
// int subdivide_mesh, // 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels
alpha
,
// boolean [] alpha, // boolean alpha - true - opaque, false - transparent. Full/bounds
alpha
,
// boolean [] alpha, // boolean alpha - true - opaque, false - transparent. Full/bounds
dbg_alpha
,
// double [] dalpha, // before boolean
x3dOutput
,
x3dOutput
,
wfOutput
,
// output WSavefront if not null
wfOutput
,
// output WSavefront if not null
tri_meshes
,
// ArrayList<TriMesh> tri_meshes,
tri_meshes
,
// ArrayList<TriMesh> tri_meshes,
...
...
src/main/java/com/elphel/imagej/x3d/export/TriMesh.java
View file @
2408288a
...
@@ -297,13 +297,6 @@ public class TriMesh {
...
@@ -297,13 +297,6 @@ public class TriMesh {
}
}
}
}
nodes
[
btiley
][
btilex
][
ny
][
nx
]
=
has_any
;
nodes
[
btiley
][
btilex
][
ny
][
nx
]
=
has_any
;
/*
if (has_any) {
indices[btiley][btilex][ny][nx] = aindx.getAndIncrement();
} else {
indices[btiley][btilex][ny][nx] = -1;
}
*/
}
}
}
}
}
}
...
@@ -1581,6 +1574,107 @@ public class TriMesh {
...
@@ -1581,6 +1574,107 @@ public class TriMesh {
ImageDtt
.
startAndJoin
(
threads
);
ImageDtt
.
startAndJoin
(
threads
);
}
}
final
static
double
[][]
plotForMesh
(
final
boolean
full_selection
,
// false
final
boolean
full_alpha
,
// true
final
Rectangle
bounds
,
final
int
out_width
,
final
int
tilesX
,
final
int
tilesY
,
final
int
tile_size
,
final
int
subdiv
,
final
double
[]
disparity
,
final
boolean
[]
selection
,
final
int
[]
border_int
,
final
boolean
[]
alpha
,
final
double
[]
dalpha
){
// scale pixels to match mesh triangles
final
double
scale_disparity
=
0.05
;
final
double
scale_selection
=
1.0
;
final
double
scale_border
=
0.3
;
final
double
scale_alpha
=
1.0
;
final
double
scale_dalpha
=
1.0
;
final
int
out_height
=
out_width
*
tilesY
/
tilesX
;
final
int
out_scale
=
out_width
/
(
tilesX
*
tile_size
);
final
int
out_tile
=
out_scale
*
tile_size
;
final
double
[][]
rslt_img
=
new
double
[
5
][];
if
(
disparity
!=
null
)
rslt_img
[
0
]
=
new
double
[
out_height
*
out_width
];
if
(
selection
!=
null
)
rslt_img
[
1
]
=
new
double
[
out_height
*
out_width
];
if
(
border_int
!=
null
)
rslt_img
[
2
]
=
new
double
[
out_height
*
out_width
];
if
(
alpha
!=
null
)
rslt_img
[
3
]
=
new
double
[
out_height
*
out_width
];
if
(
dalpha
!=
null
)
rslt_img
[
4
]
=
new
double
[
out_height
*
out_width
];
final
int
source_tile_width
=
full_selection
?
tilesX
:
bounds
.
width
;
final
int
source_tile_offsx
=
full_selection
?
bounds
.
x
:
0
;
final
int
source_tile_offsy
=
full_selection
?
bounds
.
y
:
0
;
final
int
source_pix_offsx
=
(
full_alpha
?
bounds
.
x
:
0
)
*
tile_size
;
final
int
source_pix_offsy
=
(
full_alpha
?
bounds
.
y
:
0
)
*
tile_size
;
final
int
source_pix_width
=
(
full_alpha
?
tilesX
:
bounds
.
width
)
*
tile_size
;
final
int
btiles
=
bounds
.
width
*
bounds
.
height
;
final
Thread
[]
threads
=
ImageDtt
.
newThreadArray
(
TexturedModel
.
THREADS_MAX
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
// mark disparity, selection, borders
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
btile
=
ai
.
getAndIncrement
();
btile
<
btiles
;
btile
=
ai
.
getAndIncrement
())
{
int
btilex
=
btile
%
bounds
.
width
;
int
btiley
=
btile
/
bounds
.
width
;
int
stile
=
(
btilex
+
source_tile_offsx
)
+
(
btiley
+
source_tile_offsy
)
*
source_tile_width
;
int
ftilex
=
bounds
.
x
+
btilex
;
// relative to full tile frame tilesX*tilesY
int
ftiley
=
bounds
.
y
+
btiley
;
// mark disparity, selection, borders
// out_scale * tile_size
int
out_indx0
=
(
ftilex
*
out_tile
)
+
(
ftiley
*
out_tile
)
*
out_width
;
double
d_disp
=
(
disparity
!=
null
)
?
scale_disparity
*
disparity
[
stile
]
:
Double
.
NaN
;
double
d_sel
=
((
selection
!=
null
)
&&
selection
[
stile
])?
scale_selection
:
Double
.
NaN
;
double
d_bord
=
((
border_int
!=
null
)
&&
(
border_int
[
stile
]
>=
0
))?
scale_border
*
border_int
[
stile
]
:
Double
.
NaN
;
for
(
int
oy
=
0
;
oy
<
out_tile
;
oy
++)
{
int
out_indx1
=
out_indx0
+
oy
*
out_width
;
if
(
disparity
!=
null
)
Arrays
.
fill
(
rslt_img
[
0
],
out_indx1
,
out_indx1
+
out_tile
,
d_disp
);
if
(
selection
!=
null
)
Arrays
.
fill
(
rslt_img
[
1
],
out_indx1
,
out_indx1
+
out_tile
,
d_sel
);
if
(
border_int
!=
null
)
Arrays
.
fill
(
rslt_img
[
2
],
out_indx1
,
out_indx1
+
out_tile
,
d_bord
);
}
// index for alpha - top left of as tile
if
(
alpha
!=
null
)
{
int
aindx0
=
(
source_pix_offsx
+
btilex
*
tile_size
)
+
(
source_pix_offsy
+
btiley
*
tile_size
)
*
source_pix_width
;
for
(
int
ay
=
0
;
ay
<
tile_size
;
ay
++)
{
int
aindx1
=
aindx0
+
ay
*
source_pix_width
;
int
out_indx1
=
out_indx0
+
ay
*
out_scale
*
out_width
;
for
(
int
ax
=
0
;
ax
<
tile_size
;
ax
++)
{
int
aindx
=
aindx1
+
ax
;
int
out_indx2
=
out_indx1
+
ax
*
out_scale
;
double
d_alpha
=
alpha
[
aindx
]?
scale_alpha
:
0.0
;
for
(
int
row
=
0
;
row
<
out_scale
;
row
++)
{
int
out_indx
=
out_indx2
+
row
*
out_width
;
Arrays
.
fill
(
rslt_img
[
3
],
out_indx
,
out_indx
+
out_scale
,
d_alpha
);
}
}
}
}
// index for dalpha - top left of as tile
if
(
dalpha
!=
null
)
{
int
aindx0
=
(
source_pix_offsx
+
btilex
*
tile_size
)
+
(
source_pix_offsy
+
btiley
*
tile_size
)
*
source_pix_width
;
for
(
int
ay
=
0
;
ay
<
tile_size
;
ay
++)
{
int
aindx1
=
aindx0
+
ay
*
source_pix_width
;
int
out_indx1
=
out_indx0
+
ay
*
out_scale
*
out_width
;
for
(
int
ax
=
0
;
ax
<
tile_size
;
ax
++)
{
int
aindx
=
aindx1
+
ax
;
int
out_indx2
=
out_indx1
+
ax
*
out_scale
;
double
d_alpha
=
dalpha
[
aindx
]
*
scale_dalpha
;
for
(
int
row
=
0
;
row
<
out_scale
;
row
++)
{
int
out_indx
=
out_indx2
+
row
*
out_width
;
Arrays
.
fill
(
rslt_img
[
4
],
out_indx
,
out_indx
+
out_scale
,
d_alpha
);
}
}
}
}
}
}
};
}
ImageDtt
.
startAndJoin
(
threads
);
return
rslt_img
;
}
...
@@ -2182,6 +2276,7 @@ public class TriMesh {
...
@@ -2182,6 +2276,7 @@ public class TriMesh {
int
subdivide_mesh
,
// 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels
int
subdivide_mesh
,
// 0,1 - full tiles only, 2 - 2x2 pixels, 4 - 2x2 pixels
boolean
[]
alpha
,
// boolean alpha - true - opaque, false - transparent. Full/bounds
boolean
[]
alpha
,
// boolean alpha - true - opaque, false - transparent. Full/bounds
// matching selection
// matching selection
double
[]
dalpha
,
// before boolean
X3dOutput
x3dOutput
,
// output x3d if not null
X3dOutput
x3dOutput
,
// output x3d if not null
WavefrontExport
wfOutput
,
// output WSavefront if not null
WavefrontExport
wfOutput
,
// output WSavefront if not null
ArrayList
<
TriMesh
>
tri_meshes
,
ArrayList
<
TriMesh
>
tri_meshes
,
...
@@ -2218,6 +2313,9 @@ public class TriMesh {
...
@@ -2218,6 +2313,9 @@ public class TriMesh {
}
}
boolean
display_triangles
=
debug_level
>
0
;
boolean
display_triangles
=
debug_level
>
0
;
boolean
display_src
=
debug_level
>
1
;
boolean
display_src
=
debug_level
>
1
;
boolean
display_for_mesh
=
debug_level
>
1
;
if
(
display_src
)
{
if
(
display_src
)
{
double
[][]
dbg_img
=
new
double
[
3
][
selected
.
length
];
double
[][]
dbg_img
=
new
double
[
3
][
selected
.
length
];
...
@@ -2235,7 +2333,36 @@ public class TriMesh {
...
@@ -2235,7 +2333,36 @@ public class TriMesh {
new
String
[]
{
"disparity"
,
"selected"
,
"borders"
});
new
String
[]
{
"disparity"
,
"selected"
,
"borders"
});
}
}
double
[][]
d_for_mesh
=
null
;
if
(
display_for_mesh
)
{
final
boolean
full_selection
=
selected
.
length
>
(
bounds
.
height
*
bounds
.
width
);
// applies to selected_tiles
final
boolean
full_alpha
=
alpha
.
length
>
(
bounds
.
height
*
bounds
.
width
*
tile_size
*
tile_size
);
d_for_mesh
=
plotForMesh
(
full_selection
,
// final boolean full_selection, // false
full_alpha
,
// final boolean full_alpha, // true
bounds
,
// final Rectangle bounds,
tri_img_width
,
// final int out_width,
tilesX
,
// final int tilesX,
tilesY
,
// final int tilesY,
tile_size
,
// final int tile_size,
subdivide_mesh
,
// final int subdiv,
disparity
,
// final double [] disparity,
selected
,
// final boolean [] selection,
border_int
,
// final int [] border_int,
alpha
,
// final boolean [] alpha)
dalpha
);
// final double [] dalpha){
if
(
display_src
)
{
ShowDoubleFloatArrays
.
showArrays
(
d_for_mesh
,
tri_img_width
,
d_for_mesh
[
0
].
length
/
tri_img_width
,
true
,
"fullsize_src_for_triangles"
,
new
String
[]
{
"disparity"
,
"selected"
,
"borders"
,
"alpha"
,
"dalpha"
});
}
}
/*
/*
int [][] indices = getCoordIndices( // starting with 0, -1 - not selected // updated 09.18.2022
int [][] indices = getCoordIndices( // starting with 0, -1 - not selected // updated 09.18.2022
...
@@ -2328,6 +2455,16 @@ public class TriMesh {
...
@@ -2328,6 +2455,16 @@ public class TriMesh {
line_color
,
// final double line_color,
line_color
,
// final double line_color,
center_color
);
// final double center_color)
center_color
);
// final double center_color)
if
(
display_triangles
)
{
if
(
display_triangles
)
{
if
(
d_for_mesh
!=
null
)
{
ShowDoubleFloatArrays
.
showArrays
(
new
double
[][]
{
d_for_mesh
[
0
],
d_for_mesh
[
1
],
d_for_mesh
[
2
],
d_for_mesh
[
3
],
d_for_mesh
[
4
],
tri_img
},
tri_img_width
,
tri_img
.
length
/
tri_img_width
,
true
,
"full-src-triangles"
,
new
String
[]
{
"disparity"
,
"selected"
,
"borders"
,
"alpha"
,
"dalpha"
,
"mesh"
});
}
else
{
ShowDoubleFloatArrays
.
showArrays
(
ShowDoubleFloatArrays
.
showArrays
(
tri_img
,
tri_img
,
tri_img_width
,
tri_img_width
,
...
@@ -2335,6 +2472,7 @@ public class TriMesh {
...
@@ -2335,6 +2472,7 @@ public class TriMesh {
"this-triangles"
);
"this-triangles"
);
}
}
}
}
}
if
(
x3dOutput
!=
null
)
{
if
(
x3dOutput
!=
null
)
{
x3dOutput
.
addCluster
(
x3dOutput
.
addCluster
(
...
...
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