In [1]:
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
In [2]:
from scipy.ndimage.filters import gaussian_filter
def smooth_noise(shape, sigma):
return gaussian_filter(np.random.normal(size=shape),sigma)
shape = (500,500)
S1 = smooth_noise(shape, 8)
S2 = smooth_noise(shape, 32)
fig, (ax1, ax2) = plt.subplots(ncols=2,figsize=(12,12))
ax1.imshow(S1)
ax2.imshow(S2)
Out[2]:
In [3]:
from skimage.filter import threshold_otsu
fig, (ax1, ax2) = plt.subplots(ncols=2,figsize=(12,12))
S1t = S1 > threshold_otsu(S1)
S2t = S2 > threshold_otsu(S2)
ax1.imshow(S1t, cmap='gray')
ax2.imshow(S2t, cmap='gray')
Out[3]: