-
Notifications
You must be signed in to change notification settings - Fork 157
openpiv-python refactoring #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sity for the strided images
…ipynb, and 6 more files...
…e.compare_images gives us some confidence on the use of the new vectorized correlation in the extended_search_area_piv
pyprocess3d.py passes tests
|
Dear Prof. Liberzon, Maybe, you should add a window deformation function to def deform_windows(frame, x, y, u, v, interpolation_order = 1, kx = 3, ky = 3):
# this part needs some rewording since I am not good at this type of stuff yet
"""Deform an image by window deformation where a new grid is defined based
on the grid and displacements of the previous pass and pixel values are interpolated
onto the new grid.
Parameters
----------
frame : 2d np.ndarray, dtype=np.int32
an two dimensions array of integers containing grey levels of
the first frame.
x : 2d np.ndarray
a two dimensional array containing the x coordinates of the
interrogation window centers, in pixels.
y : 2d np.ndarray
a two dimensional array containing the y coordinates of the
interrogation window centers, in pixels.
u : 2d np.ndarray
a two dimensional array containing the u velocity component,
in pixels/seconds.
v : 2d np.ndarray
a two dimensional array containing the v velocity component,
in pixels/seconds.
interpolation_order: scalar
the degree of the frame interpolation (deformation) of the mesh
kx : scalar
the degree of the interpolation of the B-splines over the x-axis of a rectangular mesh
ky : scalar
the degree of the interpolation of the B-splines over the y-axis of a rectangular mesh
Returns
-------
frame_def:
a deformed image based on the meshgrid and displacements of the previous pass
"""
frame = frame.astype(np.float32)
y1 = y[:, 0] # extract first coloumn from meshgrid
y1 = y1[::-1] #flip
x1 = x[0, :] #extract first row from meshgrid
side_x = np.arange(0, np.size(frame[0, :]), 1) #extract the image grid
side_y = np.arange(0, np.size(frame[:, 0]), 1)
# interpolating displacements onto a new meshgrid
ip = RectBivariateSpline(y1, x1, u, kx = kx, ky = ky)
ut = ip(side_y, side_x)# the way how to use the interpolation functions differs
#from matlab
ip2 = RectBivariateSpline(y1, x1, v, kx = kx, ky = ky)
vt = ip2(side_y, side_x)
#deform the image by using the map coordinates function (old grid + displacement)
x, y = np.meshgrid(side_x, side_y)#create a meshgrid
frame_def = scn.map_coordinates(
frame, ((y-vt, x+ut,)), order=interpolation_order,mode='nearest')
return frame_def |
|
Great idea. Please think of a test function that checks the essential parts of this function. |
|
Dear Prof. Liberzon, I am not sure how to proceed with making a test function. Furthermore, I am still puzzled on how the functions in OpenPIV test folder work. Maybe, @TKaeufer can help? The function presented above is nearly identical to the deformation function in Regards, |
what you could do is just to write a simple function that takes a known input, uses |
|
Hi everbody, I have a look at the new windef and test it on some images. I also think that we should either create a new .py file that contains the windef related function (first pass, multipass, deform_windows) or add those functions to the pyprocess.py to make the windef.py more clearly arranged. Since the windef.py now wraps around the extended search array PIV we might even consider renaming it with a more general name, e.g. PIV_interrogation_setup.py Maybe we can also talk about this on Monday. Best Regards, Theo |
|
@AndreasBauerGit please test this branch, it might destroy few things. I'm here if needed. |
|
Hey @alexlib, I had a look on the the new windef wrap arround the extended search area PIV and it worked fine for me. I tested it with some syntheic images and a PIV challange case and the vector fields seem reasonable. I also added a new method for the window deformation that splits the deformation symetrically on both frames. I modified the deform windows function according to my needs and also created another one that just calculates the deformation field. I tested it on syntheic images and the result was fine. However, before commiting i would like to know if you use autopep and if so wich settings you use. Then i can formate the code like you do. Best regards, Theo Best regards Theo |
Yes, I use |
|
Dear Alex, I tested the GUI and only one line needed to be changed ( Edit: Steps to reproduce: Operating system and specs: PS; it is verry scary to use a mobile phone to comment on GitHub. The |
|
For clarification, the error occured on the refactored version and not the original. The error occured on line 282 in |
…nb, and 14 more files...
…ch case_B_windef_small_window.ipynb
…og(0) is encountered or when the peak is at the border. eps = 1e-7 is added to prevent log(0) and it works well, see also sklearn forum that does precisely this border cases are solved by returning 0 (bad vector) for those peaks. new Jupyter notebook presents the corner cases of the find_subpixel_position - should be a proper test one day
I'm not sure about the name - probably somebody has to suggest a single naming convention so we rename all functions in the same spirit - the name should say by itself what the function does |
@ErichZimmer please test again with the new commit d542287 |
@ErichZimmer - is it possible to have a screencast of your test? I'd like to make it a Jupyter notebook test where I can see differences of .0001% between every new version of the code. I don't know if it's possible to do it with GUI. Thanks in advance. |
@ErichZimmer - I repeated this test and created a new Jupyter notebook that does these 5 step deformation analysis. However, I cannot find the raw data to compare the results to. Do you have a synthetic case with the raw data, so instead of running comparisons we'll run the comparison with the ground truth? |
I added a new method for the window deformation. The new option allows to choose wether one would like to deform bot images by half of the displacement (option: 'symetric') or deform just the second image with the whole displacement( option: 'second image'). Therfore, another parameter in the settings which is called "deformation_method" was added. Default is now 'symetric'. It's only a small change.
TKaeufer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the windef.py combined with the example_windef_run.py and both worked for me.
I see it's implemented. Thanks. a86a602 |
from openpiv import piv piv.piv_example()
This is a big milestone with a lot of refactoring: