|
9 | 9 | import numpy as np |
10 | 10 | import openpiv.windef as windef |
11 | 11 | from test_process import create_pair, shift_u, shift_v, threshold |
| 12 | +import pathlib |
12 | 13 |
|
13 | 14 | frame_a, frame_b = create_pair(image_size=256) |
14 | 15 |
|
@@ -60,7 +61,7 @@ def test_multi_pass_circ(): |
60 | 61 | print("\n", x, y, u_old, v_old, s2n) |
61 | 62 | assert np.mean(np.abs(u_old - shift_u)) < threshold |
62 | 63 | assert np.mean(np.abs(v_old - shift_v)) < threshold |
63 | | - for i in range(1, iterations ): |
| 64 | + for i in range(1, iterations): |
64 | 65 | x, y, u, v, s2n = windef.multipass_img_deform( |
65 | 66 | frame_a, |
66 | 67 | frame_b, |
@@ -108,6 +109,109 @@ def test_first_pass_lin(): |
108 | 109 | assert np.mean(np.abs(v - shift_v)) < threshold |
109 | 110 |
|
110 | 111 |
|
| 112 | +def test_invert(): |
| 113 | + """ Test windef.piv with invert option """ |
| 114 | + |
| 115 | + file_a = pathlib.Path(__file__).parent / '../examples/test1/exp1_001_a.bmp' |
| 116 | + file_b = pathlib.Path(__file__).parent / '../examples/test1/exp1_001_b.bmp' |
| 117 | + |
| 118 | + settings = windef.Settings() |
| 119 | + 'Data related settings' |
| 120 | + # Folder with the images to process |
| 121 | + settings.filepath_images = pathlib.Path(__file__).parent / '../examples/test1' |
| 122 | + settings.save_path = '.' |
| 123 | + # Root name of the output Folder for Result Files |
| 124 | + settings.save_folder_suffix = 'test' |
| 125 | + # Format and Image Sequence |
| 126 | + settings.frame_pattern_a = 'exp1_001_a.bmp' |
| 127 | + settings.frame_pattern_b = 'exp1_001_a.bmp' |
| 128 | + |
| 129 | + 'Region of interest' |
| 130 | + # (50,300,50,300) #Region of interest: (xmin,xmax,ymin,ymax) or 'full' for full image |
| 131 | + settings.ROI = 'full' |
| 132 | + # settings.ROI = (0,1024,200,500) |
| 133 | + |
| 134 | + 'Image preprocessing' |
| 135 | + |
| 136 | + settings.invert = True |
| 137 | + # 'None' for no masking, 'edges' for edges masking, 'intensity' for intensity masking |
| 138 | + # WARNING: This part is under development so better not to use MASKS |
| 139 | + settings.dynamic_masking_method = 'None' |
| 140 | + settings.dynamic_masking_threshold = 0.005 |
| 141 | + settings.dynamic_masking_filter_size = 7 |
| 142 | + |
| 143 | + 'Processing Parameters' |
| 144 | + settings.correlation_method = 'circular' # 'circular' or 'linear' |
| 145 | + settings.normalized_correlation = 'True' |
| 146 | + |
| 147 | + settings.deformation_method = 'symmetric' |
| 148 | + settings.iterations = 3 # select the number of PIV passes |
| 149 | + # add the interroagtion window size for each pass. |
| 150 | + # For the moment, it should be a power of 2 |
| 151 | + settings.windowsizes = (64, 32, 16) # if longer than n iteration the rest is ignored |
| 152 | + # The overlap of the interroagtion window for each pass. |
| 153 | + settings.overlap = (32, 16, 8) # This is 50% overlap |
| 154 | + # Has to be a value with base two. In general window size/2 is a good choice. |
| 155 | + # methode used for subpixel interpolation: 'gaussian','centroid','parabolic' |
| 156 | + settings.subpixel_method = 'gaussian' |
| 157 | + # order of the image interpolation for the window deformation |
| 158 | + settings.interpolation_order = 3 |
| 159 | + settings.scaling_factor = 1 # scaling factor pixel/meter |
| 160 | + settings.dt = 1 # time between to frames (in seconds) |
| 161 | + 'Signal to noise ratio options (only for the last pass)' |
| 162 | + # It is possible to decide if the S/N should be computed (for the last pass) or not |
| 163 | + settings.extract_sig2noise = True # 'True' or 'False' (only for the last pass) |
| 164 | + # method used to calculate the signal to noise ratio 'peak2peak' or 'peak2mean' |
| 165 | + settings.sig2noise_method = 'peak2peak' |
| 166 | + # select the width of the masked to masked out pixels next to the main peak |
| 167 | + settings.sig2noise_mask = 2 |
| 168 | + # If extract_sig2noise==False the values in the signal to noise ratio |
| 169 | + # output column are set to NaN |
| 170 | + 'vector validation options' |
| 171 | + # choose if you want to do validation of the first pass: True or False |
| 172 | + settings.validation_first_pass = True |
| 173 | + # only effecting the first pass of the interrogation the following passes |
| 174 | + # in the multipass will be validated |
| 175 | + 'Validation Parameters' |
| 176 | + # The validation is done at each iteration based on three filters. |
| 177 | + # The first filter is based on the min/max ranges. Observe that these values are defined in |
| 178 | + # terms of minimum and maximum displacement in pixel/frames. |
| 179 | + settings.MinMax_U_disp = (-30, 30) |
| 180 | + settings.MinMax_V_disp = (-30, 30) |
| 181 | + # The second filter is based on the global STD threshold |
| 182 | + settings.std_threshold = 4 # threshold of the std validation |
| 183 | + # The third filter is the median test (not normalized at the moment) |
| 184 | + settings.median_threshold = 3 # threshold of the median validation |
| 185 | + # On the last iteration, an additional validation can be done based on the S/N. |
| 186 | + settings.median_size = 1 #defines the size of the local median |
| 187 | + 'Validation based on the signal to noise ratio' |
| 188 | + # Note: only available when extract_sig2noise==True and only for the last |
| 189 | + # pass of the interrogation |
| 190 | + # Enable the signal to noise ratio validation. Options: True or False |
| 191 | + settings.do_sig2noise_validation = False # This is time consuming |
| 192 | + # minmum signal to noise ratio that is need for a valid vector |
| 193 | + settings.sig2noise_threshold = 1.2 |
| 194 | + 'Outlier replacement or Smoothing options' |
| 195 | + # Replacment options for vectors which are masked as invalid by the validation |
| 196 | + settings.replace_vectors = True # Enable the replacment. Chosse: True or False |
| 197 | + settings.smoothn = True # Enables smoothing of the displacemenet field |
| 198 | + settings.smoothn_p = 0.5 # This is a smoothing parameter |
| 199 | + # select a method to replace the outliers: 'localmean', 'disk', 'distance' |
| 200 | + settings.filter_method = 'localmean' |
| 201 | + # maximum iterations performed to replace the outliers |
| 202 | + settings.max_filter_iteration = 10 |
| 203 | + settings.filter_kernel_size = 2 # kernel size for the localmean method |
| 204 | + 'Output options' |
| 205 | + # Select if you want to save the plotted vectorfield: True or False |
| 206 | + settings.save_plot = False |
| 207 | + # Choose wether you want to see the vectorfield or not :True or False |
| 208 | + settings.show_plot = False |
| 209 | + settings.scale_plot = 10 # select a value to scale the quiver plot of the vectorfield |
| 210 | + # run the script with the given settings |
| 211 | + windef.piv(settings) |
| 212 | + |
| 213 | + |
| 214 | + |
111 | 215 | def test_multi_pass_lin(): |
112 | 216 | """ test fot the multipass """ |
113 | 217 | window_size = (128, 64, 32) |
|
0 commit comments