mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-18 12:40:14 +08:00
Bigger example
This commit is contained in:
@@ -9,8 +9,8 @@ from IPython.core.debugger import Tracer
|
||||
tracer = Tracer()
|
||||
|
||||
|
||||
img = img_as_float(lena())[::2, ::2, :].copy("C")
|
||||
segments = quickshift(img)
|
||||
img = img_as_float(lena())
|
||||
segments = quickshift(img, sigma=5, tau=20)
|
||||
segments = np.unique(segments, return_inverse=True)[1].reshape(img.shape[:2])
|
||||
|
||||
plt.subplot(131, title="original")
|
||||
|
||||
@@ -33,6 +33,7 @@ def quickshift(np.ndarray[dtype=np.float_t, ndim=3, mode="c"] image, sigma=5, ta
|
||||
|
||||
# We compute the distances twice since otherwise
|
||||
# we might get crazy memory overhead (width * height * windowsize**2)
|
||||
# if you want to speed up things: computing exp in C is the bottleneck ;)
|
||||
|
||||
# TODO do smoothing beforehand?
|
||||
# TODO manage borders somehow?
|
||||
@@ -64,7 +65,7 @@ def quickshift(np.ndarray[dtype=np.float_t, ndim=3, mode="c"] image, sigma=5, ta
|
||||
for c in xrange(channels):
|
||||
dist += (current_pixel_p[c] - image[x_, y_, c])**2
|
||||
dist += (x - x_)**2 + (y - y_)**2
|
||||
densities[x, y] += float(exp(-dist / sigma))
|
||||
densities[x, y] += exp(-dist / sigma)
|
||||
current_pixel_p += channels
|
||||
|
||||
print("densities: %f" % (time() - start))
|
||||
|
||||
Reference in New Issue
Block a user