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
Commits
4f9c67b3
Commit
4f9c67b3
authored
7 months ago
by
Alessia Saccardo
Browse files
Options
Downloads
Patches
Plain Diff
add gif and description
parent
e2cc0aa6
No related branches found
No related tags found
1 merge request
!135
Threshold exploration
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/assets/screenshots/interactive_thresholding.gif
+0
-0
0 additions, 0 deletions
docs/assets/screenshots/interactive_thresholding.gif
docs/viz.md
+1
-0
1 addition, 0 deletions
docs/viz.md
qim3d/viz/explore.py
+44
-15
44 additions, 15 deletions
qim3d/viz/explore.py
with
45 additions
and
15 deletions
docs/assets/screenshots/interactive_thresholding.gif
0 → 100644
+
0
−
0
View file @
4f9c67b3
536 KiB
This diff is collapsed.
Click to expand it.
docs/viz.md
+
1
−
0
View file @
4f9c67b3
...
...
@@ -9,6 +9,7 @@ The `qim3d` library aims to provide easy ways to explore and get insights from v
-
orthogonal
-
vol
-
chunks
-
threshold
-
itk_vtk
-
mesh
-
local_thickness
...
...
This diff is collapsed.
Click to expand it.
qim3d/viz/explore.py
+
44
−
15
View file @
4f9c67b3
...
...
@@ -779,25 +779,61 @@ def chunks(zarr_path: str, **kwargs):
def
threshold
(
volume
:
np
.
ndarray
,
axis
:
int
=
0
,
cmap_volume
:
str
=
'
gray
'
,
cmap_image
:
str
=
'
viridis
'
,
cmap_threshold
:
str
=
'
gray
'
,
vmin
:
float
=
None
,
vmax
:
float
=
None
,
):
"""
Interactive thresholding of a 3D volume.
This function provides an interactive interface to explore thresholding on a
3D volume slice-by-slice. Users can either manually set the threshold value
using a slider or select an automatic thresholding method from `skimage`.
The visualization includes the original image slice, a binary mask showing regions above the
threshold and an overlay combining the binary mask and the original image.
Args:
volume (np.ndarray): 3D volume to threshold.
cmap_image (str, optional): Colormap for the original image. Defaults to
'
gray
'
.
cmap_threshold (str, optional): Colormap for the thresholded image. Defaults to
'
gray
'
.
cmap_image (str, optional): Colormap for the original image. Defaults to
'
viridis
'
.
cmap_threshold (str, optional): Colormap for the binary image. Defaults to
'
gray
'
.
vmin (float, optional): Minimum value for the colormap. Defaults to None.
vmax (float, optional): Maximum value for the colormap. Defaults to None.
Returns:
slicer_obj (widgets.VBox): The interactive widget for thresholding a 3D volume.
Interactivity:
- **Manual Thresholding**:
Select
'
Manual
'
from the dropdown menu to manually adjust the threshold
using the slider.
- **Automatic Thresholding**:
Choose a method from the dropdown menu to apply an automatic thresholding
algorithm. Available methods include:
- Otsu
- Isodata
- Li
- Mean
- Minimum
- Triangle
- Yen
The threshold slider will display the computed value and will be disabled
in this mode.
Example:
```python
import qim3d
# Load a sample volume
vol = qim3d.examples.bone_128x128x128
# Visualize interactive thresholding
qim3d.viz.threshold(vol)
```

"""
threshold_methods
=
{
'
Otsu
'
:
threshold_otsu
,
'
Isodata
'
:
threshold_isodata
,
...
...
@@ -826,7 +862,7 @@ def threshold(
else
vmax
)
axes
[
0
].
imshow
(
slice_img
,
cmap
=
cmap_
volum
e
,
vmin
=
new_vmin
,
vmax
=
new_vmax
)
axes
[
0
].
imshow
(
slice_img
,
cmap
=
cmap_
imag
e
,
vmin
=
new_vmin
,
vmax
=
new_vmax
)
axes
[
0
].
set_title
(
'
Original
'
)
axes
[
0
].
axis
(
'
off
'
)
...
...
@@ -901,19 +937,12 @@ def threshold(
method
=
method_dropdown
,
)
#slicer_obj.layout = widgets.Layout(align_items='flex-start')
# Group sliders vertically (left column)
controls_left
=
widgets
.
VBox
([
position_slider
,
threshold_slider
])
# Place the method dropdown in a separate column (right)
controls_right
=
widgets
.
VBox
([
method_dropdown
])
# Combine the controls horizontally (sliders on the left, dropdown on the right)
controls_layout
=
widgets
.
HBox
([
controls_left
,
controls_right
],
layout
=
widgets
.
Layout
(
justify_content
=
'
space-between
'
))
slicer_obj
=
widgets
.
VBox
([
controls_layout
,
slicer_obj
.
children
[
-
1
]])
slicer_obj
.
layout
.
align_items
=
"
flex-start
"
# Combine the controls with the interactive slicer object
slicer_obj
=
widgets
.
VBox
([
controls_layout
,
slicer_obj
.
children
[
-
1
]])
# Add sliders + dropdown above the plot
return
slicer_obj
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