How can we use phase_correlation with view_as_windows

Particle Image Velocimetry analysis can be seen as phase_correlation 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

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

Thanks for any idea,

Hi @alexlib ! This is not exactly what you’re asking, but the second example of 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)
1 Like

Dear Emmanuelle,

Thanks a lot for the reply. We do precisely this in openpiv-python. The question was about some clever way of applying phase_cross_correlation without looping through the views.

Best regards