Exemple #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)
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()
  cb.set_label("rain rate (mm/h)")
  xticks([])
  yticks([])
  savefig("input_extrap_%d.png" % t, bbox_inches="tight")
  close()
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()
  cb.set_label("rain rate (mm/h)")
  xticks([])
  yticks([])
  savefig("input_extrap_%02d.png" % t, bbox_inches="tight")
  close()
Exemple #4
0
def motion(rr0ubyte, rr1ubyte, lam=25.0, num_iter=250, num_levels=6):
    return extract_motion_proesmans(rr0ubyte,
                                    rr1ubyte,
                                    lam=lam,
                                    num_iter=num_iter,
                                    num_levels=num_levels)[0]