Newer
Older
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import qim3d\n",
"import matplotlib.pyplot as plt\n",
"vol = qim3d.examples.bone_128x128x128\n",
"\n",
"# Start annotation tool\n",
"annotation_tool = qim3d.gui.annotation_tool.Interface()\n",
"\n",
"# We can directly pass the image we loaded to the interface\n",
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"app = annotation_tool.launch(vol[0], server_name=\"10.197.104.229\")"
]
},
{
"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)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
}
},
"nbformat": 4,