Used new function to generate binary blobs in existing gallery example

This commit is contained in:
emmanuelle
2015-05-09 12:08:21 +02:00
parent 1c3af75dd3
commit a8a39ebf35
@@ -25,30 +25,11 @@ from scipy import ndimage
import matplotlib.pyplot as plt
from skimage.segmentation import random_walker
def microstructure(l=256):
"""
Synthetic binary data: binary microstructure with blobs.
Parameters
----------
l: int, optional
linear size of the returned image
"""
n = 5
x, y = np.ogrid[0:l, 0:l]
mask = np.zeros((l, l))
generator = np.random.RandomState(1)
points = l * generator.rand(2, n ** 2)
mask[(points[0]).astype(np.int), (points[1]).astype(np.int)] = 1
mask = ndimage.gaussian_filter(mask, sigma=l / (4. * n))
return (mask > mask.mean()).astype(np.float)
from skimage.data import binary_blobs
import skimage
# Generate noisy synthetic data
data = microstructure(l=128)
data = skimage.img_as_float(binary_blobs(length=128, seed=1))
data += 0.35 * np.random.randn(*data.shape)
markers = np.zeros(data.shape, dtype=np.uint)
markers[data < -0.3] = 1