Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gnomon-package-tissueimagemesh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gnomon
gnomon-packages
gnomon-package-tissueimagemesh
Commits
66ba60f8
Commit
66ba60f8
authored
1 year ago
by
CERUTTI Guillaume
Browse files
Options
Downloads
Patches
Plain Diff
use function in mesh decimation
parent
d13bdf83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#924983
failed
1 year ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/gnomon_package_tissueimagemesh/algorithm/meshFilter/surfaceCellMeshDecimation.py
+8
-52
8 additions, 52 deletions
...agemesh/algorithm/meshFilter/surfaceCellMeshDecimation.py
with
8 additions
and
52 deletions
src/gnomon_package_tissueimagemesh/algorithm/meshFilter/surfaceCellMeshDecimation.py
+
8
−
52
View file @
66ba60f8
...
...
@@ -9,20 +9,12 @@ from gnomon.utils.decorators import meshInput, meshOutput
# #}
# add your imports before the next gnomon tag
from
copy
import
deepcopy
from
timagetk_geometry.image_surface.tissue_image_mesh
import
surface_tissue_mesh_collapse_same_label_edges
import
numpy
as
np
import
scipy.ndimage
as
nd
from
cellcomplex.property_topomesh.analysis
import
compute_topomesh_property
,
compute_topomesh_vertex_property_from_faces
from
cellcomplex.property_topomesh.topological_operations
import
topomesh_collapse_edge
from
cellcomplex.property_topomesh.extraction
import
clean_topomesh_properties
from
cellcomplex.utils
import
array_dict
# {# gnomon, plugin.class
# do not modify, any code after the gnomon tag will be overwritten
@algorithmPlugin
(
version
=
'
0.1.0
'
,
coreversion
=
'
0.81.0
'
,
name
=
"
Surface
C
ell
Projec
tion
"
)
@algorithmPlugin
(
version
=
'
0.1.0
'
,
coreversion
=
'
0.81.0
'
,
name
=
"
Surface
c
ell
mesh decima
tion
"
)
@meshInput
(
attr
=
'
in_surface_topomesh
'
,
data_plugin
=
'
gnomonMeshDataPropertyTopomesh
'
)
@meshOutput
(
attr
=
'
surface_topomesh
'
,
data_plugin
=
'
gnomonMeshDataPropertyTopomesh
'
)
class
surfaceCellMeshDecimation
(
gnomon
.
core
.
gnomonAbstractMeshFilter
):
...
...
@@ -35,57 +27,21 @@ class surfaceCellMeshDecimation(gnomon.core.gnomonAbstractMeshFilter):
self
.
_parameters
=
{}
# self.seg_img = {}
self
.
in_surface_topomesh
=
{}
self
.
surface_topomesh
=
{}
def
run
(
self
):
self
.
surface_topomesh
=
{}
for
time
in
self
.
in_surface_topomesh
.
keys
():
surface_topomesh
=
deepcopy
(
self
.
in_surface_topomesh
[
time
]
)
in_
surface_topomesh
=
self
.
in_surface_topomesh
[
time
]
# #}
# implement the run method
edges
=
np
.
array
(
list
(
surface_topomesh
.
wisps
(
1
)))
edge_vertices
=
surface_topomesh
.
wisp_property
(
'
vertices
'
,
1
).
values
(
edges
)
edge_vertex_cells
=
surface_topomesh
.
wisp_property
(
'
label
'
,
0
).
values
(
edge_vertices
)
inner_edges
=
edges
[
edge_vertex_cells
[:,
1
]
==
edge_vertex_cells
[:,
0
]]
inner_edge_lengths
=
surface_topomesh
.
wisp_property
(
'
length
'
,
1
).
values
(
inner_edges
)
inner_edges
=
inner_edges
[
np
.
argsort
(
inner_edge_lengths
)]
collapsed_edges
=
inner_edges
iteration
=
0
while
len
(
collapsed_edges
)
>
0
:
collapsed_edges
=
[]
affected_edges
=
set
()
for
e
in
inner_edges
:
if
not
e
in
affected_edges
:
neighbor_edges
=
set
(
surface_topomesh
.
border_neighbors
(
1
,
e
))
collapsed
=
topomesh_collapse_edge
(
surface_topomesh
,
e
)
if
collapsed
:
collapsed_edges
+=
[
e
]
affected_edges
|=
set
(
neighbor_edges
)
iteration
+=
1
print
(
f
"
Collapsed
{
len
(
collapsed_edges
)
}
edges
"
)
clean_topomesh_properties
(
surface_topomesh
)
compute_topomesh_property
(
surface_topomesh
,
'
vertices
'
,
1
)
compute_topomesh_property
(
surface_topomesh
,
'
length
'
,
1
)
edges
=
np
.
array
(
list
(
surface_topomesh
.
wisps
(
1
)))
edge_vertices
=
surface_topomesh
.
wisp_property
(
'
vertices
'
,
1
).
values
(
edges
)
edge_vertex_cells
=
surface_topomesh
.
wisp_property
(
'
label
'
,
0
).
values
(
edge_vertices
)
inner_edges
=
edges
[
edge_vertex_cells
[:,
1
]
==
edge_vertex_cells
[:,
0
]]
inner_edge_lengths
=
surface_topomesh
.
wisp_property
(
'
length
'
,
1
).
values
(
inner_edges
)
inner_edges
=
inner_edges
[
np
.
argsort
(
inner_edge_lengths
)]
surface_topomesh
=
surface_tissue_mesh_collapse_same_label_edges
(
in_surface_topomesh
)
compute_topomesh_property
(
surface_topomesh
,
'
borders
'
,
2
)
compute_topomesh_property
(
surface_topomesh
,
'
vertices
'
,
2
)
compute_topomesh_property
(
surface_topomesh
,
'
oriented_vertices
'
,
2
)
compute_topomesh_property
(
surface_topomesh
,
'
oriented_borders
'
,
3
)
print
(
surface_topomesh
.
nb_wisps
(
0
))
print
(
surface_topomesh
.
wisp_property
(
'
label
'
,
0
))
self
.
surface_topomesh
[
time
]
=
surface_topomesh
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment