Skip to content
Snippets Groups Projects
Commit 521f75e1 authored by Felipe Delestro Matos's avatar Felipe Delestro Matos
Browse files

Example notebook for annotation tool

parent a1f9598c
No related branches found
No related tags found
No related merge requests found
%% 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)
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment