import openpiv.tools import openpiv.process import openpiv.scaling img_a = openpiv.tools.imread( 'a.jpg' ) img_b = openpiv.tools.imread( 'b.jpg' ) # cause a.jpg and b.jpg are color images, one needs to convert them to greyscale # cause the image is too large and the flow is in a small region, we can crop it. imshow(img_a) frame_a = img_a[220:420,:,0] frame_b = img_b[220:420,:,0] imshow(frame_a,cmap=cm.gray) u, v, sig2noise = openpiv.process.extended_search_area_piv( frame_a, frame_b, window_size=32, overlap=16, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' ) x, y = openpiv.process.get_coordinates( image_size=frame_a.shape, window_size=32, overlap=16 ) u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 1.3 ) u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2) x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 1.0 ) openpiv.tools.save(x, y, u, v, mask, 'tutorial-part3.txt' ) # openpiv.tools.display_vector_field('tutorial-part3.txt', scale=100, width=0.0025) ax = axes() quiver(x,y,u,v,(u**2+v**2)**(0.5)) axis('tight') ax.set_aspect(.9) f = gcf() f.set_size_inches(15,3) colorbar(orientation='horizontal')