Skip to content
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

Add interpolation schemes #30

Open
ErichZimmer opened this issue Jul 2, 2022 · 8 comments
Open

Add interpolation schemes #30

ErichZimmer opened this issue Jul 2, 2022 · 8 comments

Comments

@ErichZimmer
Copy link
Contributor

Add interpolation schemes for future window deformation. An example can be seen here
https://github.com/ErichZimmer/OpenPIV-Python-cxx/tree/eb_fix/src/interpolation/_2D

@timdewhirst
Copy link
Member

This is the interrogation grid interpolation?

@ErichZimmer
Copy link
Contributor Author

The bilinear interpolation is for interpolating the vector grid into the image grid. The Whittaker-Shannon interpolation is used for interpolating the new image grid into one or both of the images (first or second order image deformation).

@timdewhirst
Copy link
Member

For clarity:

  • image grid is the initial grid make by sub dividing the image
  • vector grid is the image grid + |v|/2 for each grid location
  • the interpolation is to produce a set of vectors at the original image grid locations?

The Whittaker-Shannon interpolation: could you describe that in more detail?

@ErichZimmer
Copy link
Contributor Author

On Whittaker-Shannon interpolation, it is superior, but slower that a third order b-spline interpolation. In fact, the only interpolation routine that has similar accuracy is a gaussian interpolation kernel (at least from my synthetic tests). See http://dx.doi.org/10.1007/s00348-004-0902-3 for an idea on the performance of a sinc kernel.

On interpolation as a whole, first, the old coordinates and velocity components are interpolated onto a new grid, usually with a window size half of the old grid's window size. Then, the velocity component is interpolated onto the image grid. Say the image size is 1300x1600px and new grid size is 40x50 vectors. The velocity field is interpolated to the pixel level of the image so that we can use it to map the locations of the new pixels. Once we get the dense predictor (aka deformation field), we can use a Whittaker-Shannon interpolation scheme to deform the image based on the dense predictor field. In OpenPIV-Python, scipy 's map_coordinates (spline interpolation) is used for the window deformation. Two examples of a complete window deformation algorithm can be seen in OpenPIV-Python's windef module and PIVlab's fft_multi.

@ErichZimmer
Copy link
Contributor Author

I'll do a quick multi-pass example to see how feasible it is with the current grid generator.

@ErichZimmer
Copy link
Contributor Author

I have a basic interpolation function setup, however the x, y, u, v components are std::vector<double> for simplicity. Core::gf_image could also be used as well as a dedicated structure with components to be interpolated.

@ErichZimmer
Copy link
Contributor Author

ErichZimmer commented Jul 4, 2023

Interpolation routines (X, Y, U, Xq, Yq):

  • bilinear interpolation

Mapping routines (U, Xq, Yq):

  • Whittaker-Shannon Sinc interpolation (7x7 and 11x11 kernels)
  • Taylor Expansion with Finite Differences (2x2, 4x4, 6x6, 8x8, 10x10)
  • Gaussian interpolation (5x5, 7x7, 9x9, 11x11)
  • Bilinear interpolation (For now, using Taylor Expansion with Finite Differences 2x2 kernel)
  • Nearest neighbor interpolation

NOTICE:
Taylor Expansion with Finite Differences is using a c++ implementation of David Stein's fast_interp package. This package is licensed under Apache 2.0.

@ErichZimmer
Copy link
Contributor Author

FWI, I decided to make a matrix and vector class for the convolutional kernels and vector fields. The matrix class would be useful for holding a 2D representation of the vector field for interpolation purposes. I also plan on either implementing a linear algebra library (for fun) or use eigen for the decompositions since I am also working on a sparse volume class for tomographic PIV and multiple camera calibration. Basically, I would like this library to be an all round PIV software equivalent to commercial software in both abilities and processing efficiency while being as portable as possible so that python bindings could be made on as many platforms and python versions as possible for interoperability with OpenPIV-Python. Luckily, in-progress enhancements from the OpenPIV-Python project ports neatly into c++ (albeit, with a lack of OOP if that is a problem) as long as nonlinear algebra is avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants