From 21d3f151c0531b625f5acce05a85b4da6cb80b13 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Mon, 15 Dec 2014 02:20:12 +0200 Subject: [PATCH] Fix warnings generated by gallery examples --- doc/examples/plot_label.py | 3 ++- doc/examples/plot_rag_draw.py | 2 +- doc/examples/plot_regionprops.py | 3 +-- doc/examples/plot_tinting_grayscale_images.py | 10 ++++++---- doc/examples/plot_windowed_histogram.py | 4 +++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/examples/plot_label.py b/doc/examples/plot_label.py index dd3e777d..f80271ce 100644 --- a/doc/examples/plot_label.py +++ b/doc/examples/plot_label.py @@ -19,7 +19,8 @@ import matplotlib.patches as mpatches from skimage import data from skimage.filters import threshold_otsu from skimage.segmentation import clear_border -from skimage.morphology import label, closing, square +from skimage.measure import label +from skimage.morphology import closing, square from skimage.measure import regionprops from skimage.color import label2rgb diff --git a/doc/examples/plot_rag_draw.py b/doc/examples/plot_rag_draw.py index abf2ba08..0c1e1abc 100644 --- a/doc/examples/plot_rag_draw.py +++ b/doc/examples/plot_rag_draw.py @@ -1,5 +1,5 @@ """ -===================================== +====================================== Drawing Region Adjacency Graphs (RAGs) ====================================== diff --git a/doc/examples/plot_regionprops.py b/doc/examples/plot_regionprops.py index 065bae55..c4a8fc29 100644 --- a/doc/examples/plot_regionprops.py +++ b/doc/examples/plot_regionprops.py @@ -11,8 +11,7 @@ import matplotlib.pyplot as plt import numpy as np from skimage.draw import ellipse -from skimage.morphology import label -from skimage.measure import regionprops +from skimage.measure import label, regionprops from skimage.transform import rotate diff --git a/doc/examples/plot_tinting_grayscale_images.py b/doc/examples/plot_tinting_grayscale_images.py index f3ff5466..f4dde6fd 100644 --- a/doc/examples/plot_tinting_grayscale_images.py +++ b/doc/examples/plot_tinting_grayscale_images.py @@ -37,7 +37,7 @@ ax2.imshow(yellow_multiplier * image) In many cases, dealing with RGB values may not be ideal. Because of that, there are many other `color spaces`_ in which you can represent a color image. One -popular color space is called HSV_, which represents hue (~the color), +popular color space is called HSV, which represents hue (~the color), saturation (~colorfulness), and value (~brightness). For example, a color (hue) might be green, but its saturation is how intense that green is---where olive is on the low end and neon on the high end. @@ -46,6 +46,9 @@ In some implementations, the hue in HSV goes from 0 to 360, since hues wrap around in a circle. In scikit-image, however, hues are float values from 0 to 1, so that hue, saturation, and value all share the same scale. +.. _color spaces: + http://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses + Below, we plot a linear gradient in the hue, with the saturation and value turned all the way up: """ @@ -69,6 +72,8 @@ Notice how the colors at the far left and far right are the same. That reflects the fact that the hues wrap around like the color wheel (see HSV_ for more info). +.. _HSV: http://en.wikipedia.org/wiki/HSL_and_HSV + Now, let's create a little utility function to take an RGB image and: 1. Transform the RGB image to HSV @@ -147,7 +152,4 @@ plt.show() For coloring multiple regions, you may also be interested in `skimage.color.label2rgb `_. -.. _color spaces: - http://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses -.. _HSV: http://en.wikipedia.org/wiki/HSL_and_HSV """ diff --git a/doc/examples/plot_windowed_histogram.py b/doc/examples/plot_windowed_histogram.py index ebd6ea2f..65e67706 100644 --- a/doc/examples/plot_windowed_histogram.py +++ b/doc/examples/plot_windowed_histogram.py @@ -60,10 +60,12 @@ def windowed_histogram_similarity(image, selem, reference_hist, n_bins): # a measure of distance between histograms X = px_histograms Y = reference_hist + num = (X - Y) ** 2 denom = X + Y + denom[denom == 0] = np.infty frac = num / denom - frac[denom == 0] = 0 + chi_sqr = 0.5 * np.sum(frac, axis=2) # Generate a similarity measure. It needs to be low when distance is high