Minor fixes addressing @tonysyu's comments.

This commit is contained in:
Andreas Mueller
2012-08-05 20:30:43 +01:00
parent 530f2c31c4
commit e0034e384a
2 changed files with 6 additions and 13 deletions
+4 -8
View File
@@ -11,21 +11,17 @@ def _felzenszwalb_segmentation_grey(image, scale=1, sigma=0.8, min_size=20):
"""Felzenszwalb's efficient graph based segmentation for a single channel.
Produces an oversegmentation of a 2d image using a fast, minimum spanning
tree based clustering on the image grid. The parameter ``scale`` sets an
observation level. Higher scale means less and larger segments. ``sigma``
is the diameter of a Gaussian kernel, used for smoothing the image prior to
segmentation.
tree based clustering on the image grid.
The number of produced segments as well as their size can only be
controlled indirectly through ``scale``. Segment size within an image can
vary greatly depending on local contrast.
Parameters
----------
image: (width, height) ndarray
image: ndarray
Input image
scale: float
Free parameter. Higher means larger clusters.
Sets the obervation level. Higher means larger clusters.
sigma: float
Width of Gaussian kernel used in preprocessing.
min_size: int
@@ -33,7 +29,7 @@ def _felzenszwalb_segmentation_grey(image, scale=1, sigma=0.8, min_size=20):
Returns
-------
segment_mask: ndarray, [width, height]
segment_mask: (height, width) ndarray
Integer mask indicating segment labels.
"""
if image.ndim != 2:
+2 -5
View File
@@ -75,15 +75,12 @@ def quickshift(image, ratio=1., kernel_size=5, max_dist=10, return_tree=False,
cdef np.ndarray[dtype=np.float_t, ndim=3, mode="c"] image_c \
= np.ascontiguousarray(image) * ratio
if random_seed is None:
random_state = np.random.RandomState()
else:
random_state = np.random.RandomState(random_seed)
random_state = np.random.RandomState(random_seed)
# We compute the distances twice since otherwise
# we get crazy memory overhead (width * height * windowsize**2)
# TODO join orphant roots?
# TODO join orphaned roots?
# Some nodes might not have a point of higher density within the
# search window. We could do a global search over these in the end.
# Reference implementation doesn't do that, though, and it only has