Skip to content

Commit 9d3f577

Browse files
authored
Merge pull request OpenPIV#328 from nepomnyi/master
Normalized median filter is added to `windef.py`.
2 parents 309e3d2 + a863992 commit 9d3f577

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

openpiv/validation.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,22 @@ def typical_validation(
408408
# plt.quiver(u,v,color='k')
409409

410410

411-
flag_m = local_median_val(
412-
u,
413-
v,
414-
u_threshold=settings.median_threshold,
415-
v_threshold=settings.median_threshold,
416-
size=settings.median_size,
417-
)
411+
if settings.median_normalized:
412+
flag_m = local_norm_median_val(
413+
u,
414+
v,
415+
ε=0.2, # use the recomended value at this point, later add user's input for this
416+
threshold=settings.median_threshold,
417+
size=settings.median_size
418+
)
419+
else:
420+
flag_m = local_median_val(
421+
u,
422+
v,
423+
u_threshold=settings.median_threshold,
424+
v_threshold=settings.median_threshold,
425+
size=settings.median_size,
426+
)
418427

419428
# u[flag_m] = np.ma.masked
420429
# v[flag_m] = np.ma.masked

openpiv/windef.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ class PIVSettings:
129129
min_max_v_disp: Tuple=(-30, 30)
130130
# The second filter is based on the global STD threshold
131131
std_threshold: int=10 # threshold of the std validation
132-
# The third filter is the median test (not normalized at the moment)
132+
# The third filter is the median test: pick between normalized and regular
133+
median_normalized: bool=False # False = do regular median, True = do normalized median
133134
median_threshold: int=3 # threshold of the median validation
135+
median_size: int=1 # defines the size of the local median
134136
# On the last iteration, an additional validation can be done based on
135137
# the S/N.
136-
median_size: int=1 # defines the size of the local median
137138

138139

139140

0 commit comments

Comments
 (0)