How can we use phase_correlation with view_as_windows

Particle Image Velocimetry analysis https://en.wikipedia.org/wiki/Particle_image_velocimetry can be seen as phase_correlation https://scikit-image.org/docs/0.13.x/auto_examples/transform/plot_register_translation.html of multiple blocks of two images. Instead of a loop over all the blocks (typically between 8x8 to 128 x 128 pixels with overlapping regions) we would like to use the view_as_windows https://scikit-image.org/docs/dev/api/skimage.util.html#skimage.util.view_as_windows

But I couldn’t figure out how to implement phase_correlation to each of the views (blocks).

Thanks for any idea,
Alex

Hi @alexlib ! This is not exactly what you’re asking, but the second example of https://scikit-image.org/docs/dev/auto_examples/registration/plot_opticalflow.html#sphx-glr-auto-examples-registration-plot-opticalflow-py is related to PIV (the optical_flow_ilk algorithm has not yet been released, but scikit-image 0.18 will include it and should be released next week).

Regarding view_as_windows, it will give you a list of patches, on which you can iterate (with a for loop for example) to compute the cross-correlation for each pair of patches in two images. The syntax could be:

from skimage.registration import phase_cross_correlation
patches1 = view_as_windows(img1, window_shape)
patches2 = view_as_windows(img2, window_shape)
for (patch1, patch2) in zip (patches1, patches2):
     shift = phase_cross_correlation(patch1, patch2)