Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Merge requests
!60
Local thickness wrapper
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Local thickness wrapper
local_thickness_wrapper
into
main
Overview
0
Commits
10
Pipelines
0
Changes
3
Merged
Local thickness wrapper
s184058
requested to merge
local_thickness_wrapper
into
main
Mar 6, 2024
Overview
0
Commits
10
Pipelines
0
Changes
3
0
0
Merge request reports
Viewing commit
a4748508
Prev
Next
Show latest version
3 files
+
68
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
a4748508
Added unit tests
· a4748508
Stefan Peter Engelmann Jensen
authored
Mar 6, 2024
qim3d/tests/processing/test_local_thickness.py
0 → 100644
+
37
−
0
View file @ a4748508
Edit in single-file editor
Open in Web IDE
import
qim3d
import
numpy
as
np
from
skimage.draw
import
disk
,
ellipsoid
import
pytest
def
test_local_thickness_2d
():
# Create a binary 2D image
shape
=
(
100
,
100
)
img
=
np
.
zeros
(
shape
,
dtype
=
bool
)
rr1
,
cc1
=
disk
((
65
,
65
),
30
,
shape
=
shape
)
rr2
,
cc2
=
disk
((
25
,
25
),
20
,
shape
=
shape
)
img
[
rr1
,
cc1
]
=
True
img
[
rr2
,
cc2
]
=
True
lt_manual
=
np
.
zeros
(
shape
)
lt_manual
[
rr1
,
cc1
]
=
30
lt_manual
[
rr2
,
cc2
]
=
20
# Compute local thickness
lt
=
qim3d
.
processing
.
local_thickness
(
img
)
assert
np
.
allclose
(
lt
,
lt_manual
,
rtol
=
1e-1
)
def
test_local_thickness_3d
():
disk3d
=
ellipsoid
(
15
,
15
,
15
)
# Remove weird border pixels
border_thickness
=
2
disk3d
=
disk3d
[
border_thickness
:
-
border_thickness
,
border_thickness
:
-
border_thickness
,
border_thickness
:
-
border_thickness
]
disk3d
=
np
.
pad
(
disk3d
,
border_thickness
,
mode
=
'
constant
'
)
lt
=
qim3d
.
processing
.
local_thickness
(
disk3d
)
lt_manual
=
np
.
zeros
(
disk3d
.
shape
)
lt_manual
[
disk3d
]
=
15
assert
np
.
allclose
(
lt
,
lt_manual
,
rtol
=
1e-1
)
Loading