Shrediquette / PIVlab

Particle Image Velocimetry for Matlab, official repository
https://shrediquette.github.io/PIVlab/
MIT License
126 stars 30 forks source link

Add image undistortion and image rectification #89

Open Shrediquette opened 1 year ago

Shrediquette commented 1 year ago

Here is an answer to my question in Matlab answers: https://de.mathworks.com/matlabcentral/answers/1919160-image-undistortion-with-fixed-camera-position-and-single-calibration-image?s_tid=srchtitle#answer_1181145

Maybe use the existing lens distortion GUI in the iamge acquisition toolbox. Use the parameters in PIVlab. Also provide a way to do image rectification.

But the big question is: where do we undistort? Do we do this before the analysis? So is it smart to interpolate/undistort the input images? Or should the images be processed with PIV as they are and then the results (vector coordinates and displacements) are corrected for image distortion? I think that the latter would not work properly, as the cross-correlation would be performed on distorted sub-images. This can't be optimal. But undistorting/interpolating an image before analysis will also alter pixel information and maybe change the shape of some particle images. This is also not really good...

ErichZimmer commented 1 year ago

@Shrediquette You can implement the marker detection like this (updated). I designed it to use the same correlation algorithms that is used in PIV to limit the the use of third party software so I can transcribe it into c++17 or rust 2021. Please note that the marker detection function is still being refactored.

For camera calibration, I recommend a pinhole camera model. To calibrate it, first put a calibration plate directly in front of the camera so that lens distortion can be estimated. Then, the camera parameters can be estimated using Zang's method and moving the calibration plate throughout the volume (for 3D calibration). The RMS error is usually around 0.25 pixels without applying self calibration based on Wieneke's methods.

ErichZimmer commented 1 year ago

I think this article can help you make better decisions for where the image rectification occurs. Distortion correction of two-component - two-dimensional PIV using a large imaging sensor with application to measurements of a turbulent boundary layer flow at Re = 2386

From experience, it is best to interpolate the image if only performing a single pass else add the undistortion matrix to the window deformation matrix and then deform the images. The latter avoids smoothing from performing multiple interpolations when performing multi-pass window deformation analysis.

ErichZimmer commented 2 months ago

If you want some additional references, I created a curated list of PIV papers earlier today/last night that includes a few papers covering calibration techniques. Later this week I plan on adding more papers along with creating drop-down summaries to help aid readers in locating some research papers.