def test_skin(): """Test that "skin" image can be loaded. Needs internet connection. """ skin = data.skin() assert skin.ndim == 3
This segmentation algorithm is called trainable segmentation in other software such as ilastik [2]_ or ImageJ [3]_ (where it is also called "weka segmentation"). .. [1] https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html .. [2] https://www.ilastik.org/documentation/pixelclassification/pixelclassification .. [3] https://imagej.net/Trainable_Weka_Segmentation#Training_features_.282D.29 """ import numpy as np import matplotlib.pyplot as plt from skimage import data, segmentation, feature, future from sklearn.ensemble import RandomForestClassifier from functools import partial full_img = data.skin() img = full_img[:900, :900] # Build an array of labels for training the segmentation. # Here we use rectangles but visualization libraries such as plotly # (and napari?) can be used to draw a mask on the image. training_labels = np.zeros(img.shape[:2], dtype=np.uint8) training_labels[:130] = 1 training_labels[:170, :400] = 1 training_labels[600:900, 200:650] = 2 training_labels[330:430, 210:320] = 3 training_labels[260:340, 60:170] = 4 training_labels[150:200, 720:860] = 4 sigma_min = 1
plt.figure() plt.title(name) if image.ndim == 2: plt.imshow(image, cmap=plt.cm.gray) else: plt.imshow(image) plt.show() ############################################################################ # Thumbnail image for the gallery # sphinx_gallery_thumbnail_number = -1 fig, axs = plt.subplots(nrows=3, ncols=3) for ax in axs.flat: ax.axis("off") axs[0, 0].imshow(data.hubble_deep_field()) axs[0, 1].imshow(data.immunohistochemistry()) axs[0, 2].imshow(data.lily()) axs[1, 0].imshow(data.microaneurysms()) axs[1, 1].imshow(data.moon(), cmap=plt.cm.gray) axs[1, 2].imshow(data.retina()) axs[2, 0].imshow(data.shepp_logan_phantom(), cmap=plt.cm.gray) axs[2, 1].imshow(data.skin()) further_img = np.full((300, 300), 255) for xpos in [100, 150, 200]: further_img[150 - 10:150 + 10, xpos - 10:xpos + 10] = 0 axs[2, 2].imshow(further_img, cmap=plt.cm.gray) plt.subplots_adjust(wspace=-0.3, hspace=0.1)
import dash_daq as daq # pip install dash-daq import plotly.express as px import pandas as pd # pip install pandas from skimage import data # pip install scikit-image and pip install pooch for access to demo data btns = [ "drawline", "drawopenpath", "drawclosedpath", "drawcircle", "drawrect", "eraseshape", ] # Build image img = data.skin() fig_img = px.imshow(img).update_layout(dragmode="drawclosedpath") # more dragmode option -- https://plotly.com/python/reference/layout/#layout-dragmode # Build line chart # https://healthdata.nj.gov/dataset/Late-Stage-Female-Breast-Cancer-Incidence-Rate-cas/3hep-nd78 df = pd.read_csv( "Late-Stage_Female_Breast_Cancer_Incidence_Rate__cases_per_100_000_females.csv" ) fig_scatter = px.scatter(data_frame=df, x='Year', y='Rate (per 100,000 females)', color='Race') app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) app.layout = dbc.Container([