Fix houghtf docs.

This commit is contained in:
Stefan van der Walt
2009-09-24 12:00:41 +02:00
parent 134b56ef59
commit 67e5f0b7b8
+20 -14
View File
@@ -50,22 +50,28 @@ def hough(img, angles=None):
Examples
--------
# Generate a test image
img = np.zeros((100, 150), dtype=bool)
img[30, :] = 1
img[:, 65] = 1
img[35:45, 35:50] = 1
for i in range(90):
img[i, i] = 1
img += np.random.random(img.shape) > 0.95
Generate a test image:
out, angles, d = houghtf(img)
>>> img = np.zeros((100, 150), dtype=bool)
>>> img[30, :] = 1
>>> img[:, 65] = 1
>>> img[35:45, 35:50] = 1
>>> for i in range(90):
>>> img[i, i] = 1
>>> img += np.random.random(img.shape) > 0.95
Apply the Hough transform:
>>> out, angles, d = houghtf(img)
Plot the results:
>>> import matplotlib.pyplot as plt
>>> plt.imshow(out, cmap=plt.cm.bone)
>>> plt.xlabel('Angle (degree)')
>>> plt.ylabel('Distance %d (pixel)' % d[0])
>>> plt.show()
import matplotlib.pyplot as plt
plt.imshow(out, cmap=plt.cm.bone)
plt.xlabel('Angle (degree)')
plt.ylabel('Distance %d (pixel)' % d[0])
plt.show()
"""
if img.ndim != 2:
raise ValueError("Input must be a two-dimensional array")