mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-17 11:32:45 +08:00
ENH renamed "felzenszwalb_segmentation" to "felzenszwalb", remove debug output from slic
This commit is contained in:
@@ -63,12 +63,12 @@ import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
from skimage.data import lena
|
||||
from skimage.segmentation import felzenszwalb_segmentation, \
|
||||
from skimage.segmentation import felzenszwalb, \
|
||||
visualize_boundaries, slic, quickshift
|
||||
from skimage.util import img_as_float
|
||||
|
||||
img = img_as_float(lena()[::2, ::2])
|
||||
segments_fz = felzenszwalb_segmentation(img, scale=100, sigma=0.5, min_size=50)
|
||||
segments_fz = felzenszwalb(img, scale=100, sigma=0.5, min_size=50)
|
||||
segments_slic = slic(img, ratio=10, n_segments=250, sigma=1)
|
||||
segments_quick = quickshift(img, kernel_size=3, max_dist=6, ratio=0.5)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from .random_walker_segmentation import random_walker
|
||||
from .felzenszwalb import felzenszwalb_segmentation
|
||||
from .felzenszwalb import felzenszwalb
|
||||
from .slic import slic
|
||||
from .quickshift import quickshift
|
||||
from .boundaries import find_boundaries, visualize_boundaries
|
||||
|
||||
@@ -7,7 +7,7 @@ from skimage.morphology.ccomp cimport find_root, join_trees
|
||||
from ..util import img_as_float
|
||||
|
||||
|
||||
def _felzenszwalb_segmentation_grey(image, scale=1, sigma=0.8, min_size=20):
|
||||
def _felzenszwalb_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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import warnings
|
||||
import numpy as np
|
||||
|
||||
from ._felzenszwalb import _felzenszwalb_segmentation_grey
|
||||
from ._felzenszwalb import _felzenszwalb_grey
|
||||
|
||||
|
||||
def felzenszwalb_segmentation(image, scale=1, sigma=0.8, min_size=20):
|
||||
def felzenszwalb(image, scale=1, sigma=0.8, min_size=20):
|
||||
"""Computes Felsenszwalb's efficient graph based image segmentation.
|
||||
|
||||
Produces an oversegmentation of a multichannel (i.e. RGB) image
|
||||
@@ -46,7 +46,7 @@ def felzenszwalb_segmentation(image, scale=1, sigma=0.8, min_size=20):
|
||||
#image = img_as_float(image)
|
||||
if image.ndim == 2:
|
||||
# assume single channel image
|
||||
return _felzenszwalb_segmentation_grey(image, scale=scale, sigma=sigma)
|
||||
return _felzenszwalb_grey(image, scale=scale, sigma=sigma)
|
||||
|
||||
elif image.ndim != 3:
|
||||
raise ValueError("Got image with ndim=%d, don't know"
|
||||
@@ -61,7 +61,7 @@ def felzenszwalb_segmentation(image, scale=1, sigma=0.8, min_size=20):
|
||||
# compute quickshift for each channel
|
||||
for c in xrange(n_channels):
|
||||
channel = np.ascontiguousarray(image[:, :, c])
|
||||
s = _felzenszwalb_segmentation_grey(channel, scale=scale, sigma=sigma,
|
||||
s = _felzenszwalb_grey(channel, scale=scale, sigma=sigma,
|
||||
min_size=min_size)
|
||||
segmentations.append(s)
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ def slic(image, n_segments=100, ratio=10., max_iter=10, sigma=1,
|
||||
grid_y, grid_x = np.mgrid[:height, :width]
|
||||
means_y = grid_y[::step, ::step]
|
||||
means_x = grid_x[::step, ::step]
|
||||
print(means_y, means_x)
|
||||
|
||||
means_color = np.zeros((means_y.shape[0], means_y.shape[1], 3))
|
||||
cdef np.ndarray[dtype=np.float_t, ndim=2] means \
|
||||
|
||||
Reference in New Issue
Block a user