From 09abee3aba7ee72dbe4ebf6dcaa26793ed11d2d5 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 11 Jan 2024 14:46:50 +0000 Subject: [PATCH] Add a features histogram example --- examples/features_hist.py | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/features_hist.py diff --git a/examples/features_hist.py b/examples/features_hist.py new file mode 100644 index 00000000..899ddef3 --- /dev/null +++ b/examples/features_hist.py @@ -0,0 +1,42 @@ +""" +Hisogram of features +==================== +""" + +import napari +import numpy as np +import numpy.typing as npt +from skimage.measure import regionprops_table + +# make a test label image +label_image: npt.NDArray[np.uint16] = np.zeros((100, 100), dtype=np.uint16) + +label_image[10:20, 10:20] = 1 +label_image[50:70, 50:70] = 2 + +feature_table_1 = regionprops_table( + label_image, properties=("label", "area", "perimeter") +) +feature_table_1["index"] = feature_table_1["label"] + +# make the points data +n_points = 100 +points_data = 100 * np.random.random((100, 2)) +points_features = { + "feature_0": np.random.random((n_points,)), + "feature_1": np.random.random((n_points,)), + "feature_2": np.random.random((n_points,)), +} + +# create the viewer +viewer = napari.Viewer() +viewer.add_labels(label_image, features=feature_table_1) +viewer.add_points(points_data, features=points_features) + +# make the widget +viewer.window.add_plugin_dock_widget( + plugin_name="napari-matplotlib", widget_name="FeaturesHistogram" +) + +if __name__ == "__main__": + napari.run() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy