In [12]:
%matplotlib inline
from matplotlib import pyplot as plt
import numpy as np
from scipy.ndimage.filters import gaussian_filter
def scaling_noise(shape):
S = np.zeros(shape)
i = np.max(shape) / 8
while i >= 2:
noise = gaussian_filter(np.random.normal(size=shape),i)
S += noise * (i+1)**2
i /= 2
return S
h,w=300,400
shape=(h,w)
J, I = np.mgrid[0:h,0:w]
S = scaling_noise(shape)
# normalize and exp scale for coloration
nS = (S - np.min(S)) / np.ptp(S)
fig, (ax1) = plt.subplots(ncols=1,figsize=(20,10))
ax1.imshow(nS**3,cmap='terrain') # exp scale, but just for coloration
ax1.contour(I,J,S,colors='black',levels=np.linspace(np.min(S),np.max(S),20))
Out[12]: