cosmectics (flake8)

This commit is contained in:
François Boulogne
2013-03-24 15:52:14 +01:00
parent 0e4d107754
commit 96d0e677dd
3 changed files with 22 additions and 19 deletions
+7 -6
View File
@@ -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
+13 -10
View File
@@ -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
----------
@@ -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():