This notebook contains timing results from the skimage.measure.regionprops function, to guide optimisation efforts.
First, we load up previously run timings. You can run these with the regprops.py script, though currently, saving these to csv requires a bit of wrangling.
In [1]:
import pandas as pd
data = pd.read_csv('profiles.csv', index_col=0)
data = data / 100 # results are from 100 runs
data.head()
Out[1]:
Now we plot the uncached timing against the cached timing, annotated with the function name thanks to mpld3 tooltips:
In [2]:
# set up environment
%matplotlib inline
from matplotlib import pyplot as plt
import mpld3
from mpld3 import plugins
mpld3.enable_notebook()
# make matplotlib plot
fig, ax = plt.subplots()
points = ax.scatter(data['timing-cached'], data['timing-uncached'],
s=100, alpha=0.5)
m = data.max().max()
ax.plot((0, m), (0, m), color='k', alpha=0.5)
ax.set_xlabel(u'timing-cached (µs / run)', size=15)
ax.set_ylabel(u'timing-uncached (µs / run)', size=15)
ax.set_xlim(-50, m + 50)
ax.set_ylim(-50, m + 50)
# set up mpld3 tooltip plugin
labels = ["{0}, ({1:.2f}, {2:.2f})".format(name, coords[0], coords[1])
for name, coords in data.iterrows()]
tooltip = plugins.PointLabelTooltip(points, labels)
# connect the plugin to the mpl figure
plugins.connect(fig, tooltip)
plt.show()
Some interesting observations from this plot:
convex_hull_image, solidity, convex_area) are much slower than other properties. Use them only if you are absolutely sure you need them.bbox.