Esempio n. 1
0
def motion(I1, I2):
    """Extract motion from two rainrate fields."""
    # Convert the rainfall maps to unsigned byte, as required by the Optflow 
    # motion detection algorithms. Gaussian filter with std. dev. 3 is applied.
    Iu = []
    for i, I in enumerate([I1, I2]):
        Iu.append(utils.rainfall_to_ubyte(I, R_min=0.05, R_max=15.0, filter_stddev=3.0))
    # Compute the motion field by using the Python <-> C++ API and the Proesmans 
    # algorithm.
    return extract_motion_proesmans(Iu[0], Iu[1], lam=25.0, num_iter=250, num_levels=6)
Esempio n. 2
0
cb.set_label("rain rate (mm/h)")
xticks([])
yticks([])
savefig("input1.png", bbox_inches="tight")

figure()
imshow(I2_, vmin=0.05, vmax=10)
cb = colorbar()
cb.set_label("rain rate (mm/h)")
xticks([])
yticks([])
savefig("input2.png", bbox_inches="tight")

# Convert the rainfall maps to unsigned byte, as required by the Optflow 
# motion detection algorithms. Gaussian filter with std. dev. 3 is applied.
I1_ubyte = utils.rainfall_to_ubyte(I1, R_min=0.05, R_max=10.0, filter_stddev=3.0)
I2_ubyte = utils.rainfall_to_ubyte(I2, R_min=0.05, R_max=10.0, filter_stddev=3.0)

# Compute the motion field by using the Python <-> C++ API and the Proesmans 
# algorithm.
V = extract_motion_proesmans(I1_ubyte, I2_ubyte, lam=25.0, num_iter=250, 
                             num_levels=6)[0]

# Extrapolate the first input image five time steps.
for t in arange(1, 6):
  I_extrap = semilagrangian(I1, V, t, 15, n_iter=3, inverse=True)
  figure()
  I = I_extrap.copy()
  I[I < 0.05] = nan
  imshow(I, vmin=0.05, vmax=10)
  cb = colorbar()
Esempio n. 3
0
cb.set_label("rain rate (mm/h)")
xticks([])
yticks([])
savefig("input1.png", bbox_inches="tight")

figure()
imshow(I2_, vmin=0.05, vmax=10)
cb = colorbar()
cb.set_label("rain rate (mm/h)")
xticks([])
yticks([])
savefig("input2.png", bbox_inches="tight")

# Convert the precipitation fields to unsigned byte, as required by the Optflow 
# motion estimation algorithms. Gaussian filter with std. dev. 3 is applied.
I1_ubyte = utils.rainfall_to_ubyte(I1, R_min=0.05, R_max=10.0, filter_stddev=3.0)
I2_ubyte = utils.rainfall_to_ubyte(I2, R_min=0.05, R_max=10.0, filter_stddev=3.0)

# Compute the motion field by using the Python <-> C++ API and the Proesmans 
# algorithm.
V = extract_motion_proesmans(I1_ubyte, I2_ubyte, lam=25.0, num_iter=250, 
                             num_levels=6)[0]

# Extrapolate the first input image five time steps.
for t in arange(1, 6):
  I_extrap = semilagrangian(I1, V, t, 15, n_iter=3, inverse=True)
  figure()
  I = I_extrap.copy()
  I[I < 0.05] = nan
  imshow(I, vmin=0.05, vmax=10)
  cb = colorbar()
Esempio n. 4
0
def rr2ubyte(rr, R_min=0.05, R_max=10.0, filter_stddev=3.0):
    return utils.rainfall_to_ubyte(rr,
                                   R_min=R_min,
                                   R_max=R_max,
                                   filter_stddev=filter_stddev)