|
21 | 21 | from openpiv import smoothn |
22 | 22 | from skimage.util import invert |
23 | 23 |
|
| 24 | +def simple_multipass(frame_a, frame_b, windows = None): |
| 25 | + """ Simple windows deformation multipass run with |
| 26 | + default settings |
| 27 | + """ |
| 28 | + settings = Settings() # default, see below |
| 29 | + |
| 30 | + if windows is not None: |
| 31 | + settings.num_iterations = len(windows) |
| 32 | + settings.windowsizes = windows |
| 33 | + settings.overlap = [int(w/2) for w in windows] |
| 34 | + |
| 35 | + x, y, u, v, s2n = first_pass( |
| 36 | + frame_a, |
| 37 | + frame_b, |
| 38 | + settings |
| 39 | + ) |
| 40 | + |
| 41 | + |
| 42 | + u = np.ma.masked_array(u, mask=np.ma.nomask) |
| 43 | + v = np.ma.masked_array(v, mask=np.ma.nomask) |
| 44 | + |
| 45 | + if settings.validation_first_pass: |
| 46 | + u, v, mask = validation.typical_validation(u, v, s2n, settings) |
| 47 | + |
| 48 | + u, v = filters.replace_outliers(u, v) |
| 49 | + |
| 50 | + if settings.smoothn: |
| 51 | + u,_,_,_ = smoothn.smoothn(u, s=settings.smoothn_p) |
| 52 | + v,_,_,_ = smoothn.smoothn(v, s=settings.smoothn_p) |
| 53 | + # multipass |
| 54 | + for i in range(1, settings.num_iterations): |
| 55 | + |
| 56 | + x, y, u, v, s2n, mask = multipass_img_deform( |
| 57 | + frame_a, |
| 58 | + frame_b, |
| 59 | + i, |
| 60 | + x, |
| 61 | + y, |
| 62 | + u, |
| 63 | + v, |
| 64 | + settings |
| 65 | + ) |
| 66 | + |
| 67 | + # If the smoothing is active, we do it at each pass |
| 68 | + # but not the last one |
| 69 | + if settings.smoothn is True and i < settings.num_iterations-1: |
| 70 | + u, dummy_u1, dummy_u2, dummy_u3 = smoothn.smoothn( |
| 71 | + u, s=settings.smoothn_p |
| 72 | + ) |
| 73 | + v, dummy_v1, dummy_v2, dummy_v3 = smoothn.smoothn( |
| 74 | + v, s=settings.smoothn_p |
| 75 | + ) |
| 76 | + |
| 77 | + # replance NaNs by zeros |
| 78 | + u = u.filled(0.) |
| 79 | + v = v.filled(0.) |
| 80 | + |
| 81 | + # # "scales the results pixel-> meter" |
| 82 | + # x, y, u, v = scaling.uniform(x, y, u, v, |
| 83 | + # scaling_factor=settings.scaling_factor) |
| 84 | + |
| 85 | + x, y, u, v = transform_coordinates(x, y, u, v) |
| 86 | + return (x,y,u,v,s2n) |
| 87 | + |
24 | 88 |
|
25 | 89 | def piv(settings): |
26 | 90 | """ the func fuction is the "frame" in which the PIV evaluation is done """ |
|
0 commit comments