Repository: scikit-image/scikit-image

Issue:
regionsprops_table is not mentioned in the doc
We should use it in an existing example, or add a new example.


Discussion:
@mkcor can be a good way to get started, writing a documentation example showing the table of props.
Note that we probably want to add pandas to our docs dependencies for maximum effect here. =)
(btw it's `regionprops_table` not `regionsprops_table`)

Resolving patch:
diff --git a/doc/examples/segmentation/plot_regionprops.py b/doc/examples/segmentation/plot_regionprops.py
--- a/doc/examples/segmentation/plot_regionprops.py
+++ b/doc/examples/segmentation/plot_regionprops.py
@@ -3,15 +3,17 @@
 Measure region properties
 =========================
 
-This example shows how to measure properties of labelled image regions.
+This example shows how to measure properties of labelled image regions. We
+analyze an image with two ellipses.
 
 """
 import math
 import matplotlib.pyplot as plt
 import numpy as np
+import pandas as pd
 
 from skimage.draw import ellipse
-from skimage.measure import label, regionprops
+from skimage.measure import label, regionprops, regionprops_table
 from skimage.transform import rotate
 
 
@@ -22,19 +24,27 @@
 
 image = rotate(image, angle=15, order=0)
 
+rr, cc = ellipse(100, 100, 60, 50)
+image[rr, cc] = 1
+
 label_img = label(image)
 regions = regionprops(label_img)
 
+#####################################################################
+# We use the :py:func:`skimage.measure.regionprops` result to draw certain
+# properties on each region. For example, in red, we plot the major and minor
+# axes of each ellipse.
+
 fig, ax = plt.subplots()
 ax.imshow(image, cmap=plt.cm.gray)
 
 for props in regions:
     y0, x0 = props.centroid
     orientation = props.orientation
-    x1 = x0 + math.cos(orientation) * 0.5 * props.major_axis_length
-    y1 = y0 - math.sin(orientation) * 0.5 * props.major_axis_length
-    x2 = x0 - math.sin(orientation) * 0.5 * props.minor_axis_length
-    y2 = y0 - math.cos(orientation) * 0.5 * props.minor_axis_length
+    x1 = x0 + math.cos(orientation) * 0.5 * props.minor_axis_length
+    y1 = y0 - math.sin(orientation) * 0.5 * props.minor_axis_length
+    x2 = x0 - math.sin(orientation) * 0.5 * props.major_axis_length
+    y2 = y0 - math.cos(orientation) * 0.5 * props.major_axis_length
 
     ax.plot((x0, x1), (y0, y1), '-r', linewidth=2.5)
     ax.plot((x0, x2), (y0, y2), '-r', linewidth=2.5)
@@ -47,3 +57,22 @@
 
 ax.axis((0, 600, 600, 0))
 plt.show()
+
+#####################################################################
+# We use the :py:func:`skimage.measure.regionprops_table` to compute
+# (selected) properties for each region. Note that
+# ``skimage.measure.regionprops_table`` actually computes the properties,
+# whereas ``skimage.measure.regionprops`` computes them when they come in use
+# (lazy evaluation).
+
+props = regionprops_table(label_img, properties=('centroid',
+                                                 'orientation',
+                                                 'major_axis_length',
+                                                 'minor_axis_length'))
+
+#####################################################################
+# We now display a table of these selected properties (one region per row),
+# the ``skimage.measure.regionprops_table`` result being a pandas-compatible
+# dict.
+
+pd.DataFrame(props)


Test patch: