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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Commits
521f75e1
Commit
521f75e1
authored
1 year ago
by
Felipe Delestro Matos
Browse files
Options
Downloads
Patches
Plain Diff
Example notebook for annotation tool
parent
a1f9598c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/notebooks/annotation_tool.ipynb
+47
-6
47 additions, 6 deletions
docs/notebooks/annotation_tool.ipynb
with
47 additions
and
6 deletions
docs/notebooks/annotation_tool.ipynb
+
47
−
6
View file @
521f75e1
...
@@ -7,19 +7,60 @@
...
@@ -7,19 +7,60 @@
"outputs": [],
"outputs": [],
"source": [
"source": [
"import qim3d\n",
"import qim3d\n",
"from scipy import ndimage\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.pyplot as plt\n",
"qim3d.io.logger.level(\"info\")\n",
"\n",
"\n",
"# Load example image\n",
"# Load example image\n",
"
img
= qim3d.examples.bone_128x128x128\n",
"
vol
= qim3d.examples.bone_128x128x128\n",
"\n",
"\n",
"# Start annotation tool\n",
"# Start annotation tool\n",
"
interface
= qim3d.gui.annotation_tool.Interface()\n",
"
annotation_tool
= qim3d.gui.annotation_tool.Interface()\n",
"\n",
"\n",
"# We can directly pass the image we loaded to the interface\n",
"# We can directly pass the image we loaded to the interface\n",
"#interface.launch()\n",
"app = annotation_tool.launch(vol[0], server_name=\"10.197.104.229\")"
"interface.launch(ndimage.zoom(img[0], 3, order=0))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"annotation_tool.get_result()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"from IPython.display import clear_output\n",
"import numpy as np\n",
"import time\n",
"\n",
"while True:\n",
" clear_output(wait=True) \n",
" masks_dict = annotation_tool.get_result()\n",
" if len(masks_dict) == 0:\n",
" masks_dict[\"No mask\"] = np.zeros((32,32))\n",
" \n",
" fig, axs = plt.subplots(1, len(masks_dict), figsize=(8,3))\n",
"\n",
" if len(masks_dict) == 1:\n",
" axs = [axs]\n",
" for idx, (name, mask) in enumerate(masks_dict.items()):\n",
"\n",
" axs[idx].imshow(mask, cmap='gray', interpolation='none')\n",
" axs[idx].set_title(name)\n",
" axs[idx].axis('off')\n",
" \n",
" plt.tight_layout()\n",
"\n",
" \n",
" plt.show()\n",
" time.sleep(2)"
]
]
}
}
],
],
...
...
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
qim3d
import
qim3d
from
scipy
import
ndimage
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
qim3d
.
io
.
logger
.
level
(
"
info
"
)
# Load example image
# Load example image
img
=
qim3d
.
examples
.
bone_128x128x128
vol
=
qim3d
.
examples
.
bone_128x128x128
# Start annotation tool
# Start annotation tool
interface
=
qim3d
.
gui
.
annotation_tool
.
Interface
()
annotation_tool
=
qim3d
.
gui
.
annotation_tool
.
Interface
()
# We can directly pass the image we loaded to the interface
# We can directly pass the image we loaded to the interface
#interface.launch()
app
=
annotation_tool
.
launch
(
vol
[
0
],
server_name
=
"
10.197.104.229
"
)
interface
.
launch
(
ndimage
.
zoom
(
img
[
0
],
3
,
order
=
0
))
```
%% Cell type:code id: tags:
```
python
annotation_tool
.
get_result
()
```
%% Cell type:code id: tags:
```
python
%
matplotlib
inline
import
matplotlib.pyplot
as
plt
from
IPython.display
import
clear_output
import
numpy
as
np
import
time
while
True
:
clear_output
(
wait
=
True
)
masks_dict
=
annotation_tool
.
get_result
()
if
len
(
masks_dict
)
==
0
:
masks_dict
[
"
No mask
"
]
=
np
.
zeros
((
32
,
32
))
fig
,
axs
=
plt
.
subplots
(
1
,
len
(
masks_dict
),
figsize
=
(
8
,
3
))
if
len
(
masks_dict
)
==
1
:
axs
=
[
axs
]
for
idx
,
(
name
,
mask
)
in
enumerate
(
masks_dict
.
items
()):
axs
[
idx
].
imshow
(
mask
,
cmap
=
'
gray
'
,
interpolation
=
'
none
'
)
axs
[
idx
].
set_title
(
name
)
axs
[
idx
].
axis
(
'
off
'
)
plt
.
tight_layout
()
plt
.
show
()
time
.
sleep
(
2
)
```
```
...
...
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