from pylab import *
from scipy.ndimage import measurements
L = 100
pv = [0.2,0.3,0.4,0.5,0.6,0.7]
z = rand(L,L)
for i in range(len(pv)):
p = pv[i]
m = z<p
lw, num = measurements.label(m)
area = measurements.sum(m, lw, index=arange(lw.max() + 1))
areaImg = area[lw]
subplot(2,3,i+1)
tit = 'p='+str(p)
imshow(areaImg, origin='lower')
title(tit)
axis()
I'm trying to run this code in vscode but it is showing this thing on terminal
DeprecationWarning: Please import label
from the scipy.ndimage
namespace; the scipy.ndimage.measurements
namespace is deprecated and will be removed in SciPy 2.0.0.
lw, num = measurements.label(m)
DeprecationWarning: Please import sum
from the scipy.ndimage
namespace; the scipy.ndimage.measurements
namespace is deprecated and will be removed in SciPy 2.0.0.
area = measurements.sum(m, lw, index=arange(lw.max() + 1))
i actually new and dont know how to import label and sum.
On the second line, instead of from scipy.ndimage import measurements
, you can import label
and sum
with
from scipy.ndimage import label, sum
Then you need to adjust to remove measurements
from the rest of your code, like this:
lw, num = label(m) # works when you import label
area = sum(m, lw, index=arange(lw.max() + 1)) # works when you import sum