Skip to content

Instantly share code, notes, and snippets.

@DragaDoncila
Created October 17, 2025 00:43
Show Gist options
  • Select an option

  • Save DragaDoncila/fcf4962dc4f20d11b9543afd8ec7f41b to your computer and use it in GitHub Desktop.

Select an option

Save DragaDoncila/fcf4962dc4f20d11b9543afd8ec7f41b to your computer and use it in GitHub Desktop.
Shapes to labels issue
import numpy as np
import napari
# shapes = np.asarray([[122, 314 ],
# [255, 123],
# [443, 395],
# [261, 230]], dtype=np.float32)
shapes = np.asarray([[122.022385, 314.54358 ],
[255.77983 , 123.14169 ],
[443.26413 , 395.69348 ],
[261.37637 , 285.44153 ]], dtype=np.float32)
viewer = napari.Viewer()
shapes_layer = viewer.add_shapes(shapes, shape_type='polygon')
labels = shapes_layer.to_labels()
viewer.add_labels(labels)
napari.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment