Note
Click here to download the full example code
TV-L1 vs iLKΒΆ
Comparison the TV-L1 and iLK methods for the optical flow estimation.
Out:
Processing the Beanbags sequence
TV-L1 processing time: 2.598048sec
ILK processing time: 0.454992sec
Processing the Dimetrodon sequence
TV-L1 processing time: 1.877484sec
ILK processing time: 0.313538sec
Processing the Dogdance sequence
TV-L1 processing time: 2.664790sec
ILK processing time: 0.458793sec
Processing the Grove2 sequence
TV-L1 processing time: 2.905357sec
ILK processing time: 0.456460sec
Processing the Grove3 sequence
TV-L1 processing time: 2.968026sec
ILK processing time: 0.458371sec
Processing the Hydrangea sequence
TV-L1 processing time: 2.124195sec
ILK processing time: 0.313094sec
Processing the Minicooper sequence
TV-L1 processing time: 2.884015sec
ILK processing time: 0.457555sec
Processing the Rubberwhale sequence
TV-L1 processing time: 2.235224sec
ILK processing time: 0.312935sec
Processing the Urban2 sequence
TV-L1 processing time: 2.663834sec
ILK processing time: 0.457162sec
Processing the Urban3 sequence
TV-L1 processing time: 2.621930sec
ILK processing time: 0.458131sec
Processing the Venus sequence
TV-L1 processing time: 1.429141sec
ILK processing time: 0.228746sec
Processing the Walking sequence
TV-L1 processing time: 2.456856sec
ILK processing time: 0.458667sec
from time import time
import matplotlib.pyplot as plt
import pyimof
seq_list = pyimof.data.__all__
seq_count = len(seq_list)
fig = plt.figure(figsize=((9, 2*seq_count)))
ax_array = fig.subplots(seq_count, 3)
ax_array[0, 0].set_title("Reference image")
ax_array[0, 1].set_title("TV-L1 result")
ax_array[0, 2].set_title("iLK result")
# --- Loop over available sequences
for name, (ax0, ax1, ax2) in zip(seq_list, ax_array):
title = name.capitalize()
print(f"Processing the {title} sequence")
# --- Load data
I0, I1 = pyimof.data.__dict__[name]()
ax0.imshow(I0, cmap='gray')
ax0.set_ylabel(title)
ax0.set_xticks([])
ax0.set_yticks([])
# --- Run TV-L1
t0 = time()
u, v = pyimof.solvers.tvl1(I0, I1)
t1 = time()
pyimof.display.plot(u, v, ax=ax1, colorwheel=False)
print("\tTV-L1 processing time: {:02f}sec".format(t1-t0))
# --- Run iLK
t0 = time()
u, v = pyimof.solvers.ilk(I0, I1)
t1 = time()
pyimof.display.plot(u, v, ax=ax2, colorwheel=False)
print("\tILK processing time: {:02f}sec".format(t1-t0))
fig.tight_layout()
plt.show()
Total running time of the script: ( 0 minutes 35.773 seconds)