From 96d0e677dd1c5be440be7417be7506c87c5c9325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Sun, 24 Mar 2013 15:52:14 +0100 Subject: [PATCH] cosmectics (flake8) --- skimage/transform/_hough_transform.pyx | 13 ++++++----- skimage/transform/hough_transform.py | 23 +++++++++++-------- .../transform/tests/test_hough_transform.py | 5 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/skimage/transform/_hough_transform.pyx b/skimage/transform/_hough_transform.pyx index 2d5d0230..b2250ef3 100644 --- a/skimage/transform/_hough_transform.pyx +++ b/skimage/transform/_hough_transform.pyx @@ -21,8 +21,8 @@ cdef inline Py_ssize_t round(double r): def hough_circle(cnp.ndarray img, - cnp.ndarray[ndim=1, dtype=cnp.intp_t] radius, - char normalize=True): + cnp.ndarray[ndim=1, dtype=cnp.intp_t] radius, + char normalize=True): """Perform a circular Hough transform. Parameters @@ -112,7 +112,8 @@ def hough_line(cnp.ndarray img, cnp.ndarray[ndim=1, dtype=cnp.double_t] theta=No ----- The origin is the top left corner of the original image. X and Y axis are horizontal and vertical edges respectively. - The distance is the minimal algebraic distance from the origin to the detected line. + The distance is the minimal algebraic distance from the origin + to the detected line. Examples -------- @@ -163,7 +164,7 @@ def hough_line(cnp.ndarray img, cnp.ndarray[ndim=1, dtype=cnp.double_t] theta=No # finally, run the transform cdef Py_ssize_t nidxs, nthetas, i, j, x, y, accum_idx - nidxs = y_idxs.shape[0] # x and y are the same shape + nidxs = y_idxs.shape[0] # x and y are the same shape nthetas = theta.shape[0] for i in range(nidxs): x = x_idxs[i] @@ -175,8 +176,8 @@ def hough_line(cnp.ndarray img, cnp.ndarray[ndim=1, dtype=cnp.double_t] theta=No def probabilistic_hough_line(cnp.ndarray img, int threshold=10, - int line_length=50, int line_gap=10, - cnp.ndarray[ndim=1, dtype=cnp.double_t] theta=None): + int line_length=50, int line_gap=10, + cnp.ndarray[ndim=1, dtype=cnp.double_t] theta=None): """Return lines from a progressive probabilistic line Hough transform. Parameters diff --git a/skimage/transform/hough_transform.py b/skimage/transform/hough_transform.py index 1b356127..8f56efe9 100644 --- a/skimage/transform/hough_transform.py +++ b/skimage/transform/hough_transform.py @@ -1,7 +1,5 @@ __all__ = ['hough_line_peaks'] -from itertools import izip as zip - import numpy as np from scipy import ndimage from skimage import measure, morphology @@ -10,30 +8,35 @@ from skimage import measure, morphology from ._hough_transform import hough_line, probabilistic_hough_line from skimage._shared.utils import deprecated + @deprecated('hough_line') def hough(img, theta=None): return hough_line(img, theta) + @deprecated('probabilistic_hough') def probabilistic_hough(img, threshold=10, line_length=50, line_gap=10, theta=None): return probabilistic_hough_line(img, threshold=threshold, - line_length=line_length, line_gap=line_gap, theta=theta) + line_length=line_length, line_gap=line_gap, + theta=theta) + @deprecated('hough_peaks') def hough_peaks(hspace, angles, dists, min_distance=10, min_angle=10, threshold=None, num_peaks=np.inf): return hough_line_peaks(hspace, angles, dists, min_distance, min_angle, - threshold, num_peaks) + threshold, num_peaks) -def hough_line_peaks(hspace, angles, dists, min_distance=10, min_angle=10, - threshold=None, num_peaks=np.inf): + +def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10, + threshold=None, num_peaks=np.inf): """Return peaks in hough transform. - Identifies most prominent lines separated by a certain angle and distance in - a hough transform. Non-maximum suppression with different sizes is applied - separately in the first (distances) and second (angles) dimension of the - hough space to identify peaks. + Identifies most prominent lines separated by a certain angle and distance + in a hough transform. Non-maximum suppression with different sizes is + applied separately in the first (distances) and second (angles) dimension + of the hough space to identify peaks. Parameters ---------- diff --git a/skimage/transform/tests/test_hough_transform.py b/skimage/transform/tests/test_hough_transform.py index 395e6faa..256c88a8 100644 --- a/skimage/transform/tests/test_hough_transform.py +++ b/skimage/transform/tests/test_hough_transform.py @@ -2,7 +2,6 @@ import numpy as np from numpy.testing import * import skimage.transform as tf -import skimage.transform.hough_transform as ht from skimage.draw import circle_perimeter, line @@ -50,7 +49,7 @@ def test_probabilistic_hough(): # as mentioned in article of Galambos et al theta = np.linspace(0, np.pi, 45) lines = tf.probabilistic_hough_line(img, threshold=10, line_length=10, - line_gap=1, theta=theta) + line_gap=1, theta=theta) # sort the lines according to the x-axis sorted_lines = [] for line in lines: @@ -110,7 +109,7 @@ def test_hough_line_peaks_num(): img[:, 40] = True hspace, angles, dists = tf.hough_line(img) assert len(tf.hough_line_peaks(hspace, angles, dists, min_distance=0, - min_angle=0, num_peaks=1)[0]) == 1 + min_angle=0, num_peaks=1)[0]) == 1 def test_hough_circle():