### Sample image and/or macro code

So I simulated simple data consisting of 2 matrices a and b. b is a deformed version of a. I want to find a transformation that will make b as a. Thus I decided on registration, and since I expect in my data not only translations, but also more nonlinear changes I decided on the optical flow algorithm. But the results of it look terrible. I don’t fully understand what OF does under the hood, but the scikit-image example from the docs (with the motorcycle) was quite impressive. Is there anything I’m doing wrong, or it wouldn’t work in this case? If so, why?

```
from skimage.transform import warp
from skimage.registration import optical_flow_tvl1
import numpy as np
import matplotlib.pyplot as plt
a = np.zeros((20, 20))
a[3:15,4:17] = 1
b = np.zeros((20, 20))
b[4:17,3:18] = 1
b[10:15,11:15] = 0
v, u = optical_flow_tvl1(a, b)
nr, nc = a.shape
r_coords, c_coords = np.meshgrid(np.arange(nr), np.arange(nc), indexing='ij')
b_warp = warp(mask1, np.array([r_coords + v, c_coords + u]), mode='nearest')
b_warp = (b_warp - np.min(b_warp)) / np.max(b_warp)
plt.figure(figsize=(15,3))
plt.subplot(131)
plt.imshow(a)
plt.subplot(132)
plt.imshow(b)
plt.subplot(133)
plt.imshow(b_warp)
plt.show()
```

From left to right you have a, b and b after OF transformation.

### Analysis goals

Transform matrix b too look as close as possible to a.