Next step

2020 has been a very, very bumpy ride. We started with terrible bush fires preventing any field excursions then came the coronavirus, lockdown and homeschooling, and then came the decision of the university to terminate the teaching of geology.

Consequently, I am transitioning out of academia and may not be able to update TecPIV for a while. If you are willing please take over the source code and have fun.

My intention was to move tecpiv from Matlab to python + Qt. Many progress there, but it is not ready yet because it is simply not as good as the matlab version yet. However, if python is your thing and tecpiv is of interest give me a shout and I will share my codes.

Converting raw images to DNG

TecPIV reads either 16-bit tiff files or adobe dng files, which are then converted to 16-bits tiff files. This allows abstracting the specificities of each camera make and model. The conversion from a raw image in the format of the camera maker (eg. .raw, .nef) is delegated to other existing software like Adobe DNG Converter.

However, despite being designed to be an open standard, the dng format produced by Adobe DNG converter is non-unique. You can specify some options when converting and not all options are compatible with how TecPIV reads the dng file.

Converting the raw files into DNG is advantageous because you can keep a copy of the files in a documented format, that preserves the colour information while the 16-bit tiffs employed for the PIV calculation are grayscale.

So here are some screen captures of Adobe DNG converter with the settings producing dng files which can safely be imported into TecPIV and converted to 16-bit tiff files.

Screenshot 2020-04-10 11.04.36

Capture of Adobe DNG converter 12 on macos. Select the directory containing the raw files and click the change preferences button.

Screenshot 2020-04-10 11.05.02

Select custom compatibility, and embed the original raw file in the dng (all metadata will be preserved)

Screenshot 2020-04-10 11.05.17

Select DNG 1.4 and uncompressed and not demosaiced (we will do that in TecPIV).

2-D finite displacements and strain from particle imaging velocimetry (PIV) analysis of tectonic analogue models with TecPIV

Solid Earth, 10, 1123–1139, 2019

We published a paper detailing the progress made on TecPIV:  2-D finite displacements and strain from particle imaging velocimetry (PIV) analysis of tectonic analogue models with TecPIV. The open-access paper can be downloaded from the link above. 


Screenshot 2019-08-11 11.01.48

TecPIV outputs with strain rate components instead of velocity gradients.




Screenshot 2019-08-11 11.02.56

Finite deformation ellipses from cumulative Lagrangian sums.






Image correlation is the key step of Particle Imaging Velocimetry. This is where successive images are evaluated and displacements are calculated.  How does it work?

The images are separated into numerous smaller sub-areas or interrogation windows. It is the interrogation windows that are correlated not the entire images. The correlation of an interrogation image with another in the successive image yields one single vector, assigned to the point at the center of the interrogation area. When the image is separated into NxM interrogation areas along its x and y axes, we obtain NxM vectors.

To obtain a denser velocity grid, the interrogation areas may be overlapping. A common value is 50% overlap, but I have used up to 75% when employing a single pass procedure.



Correlation of successive images. (a) the image is correlated in sub-areas. (b) two sub-areas at successive times are correlated. (c) correlation map shows how well the two sub-images fit one another when shifted along x- and y-axes. (d) a Gaussian curve is fitted to the correlation map to find the position of the peak with sub-pixel precision.



Multi-pass with window deformation. (a) first pass with overlap 50% yields the gray vectors and the blue one at the center. (b) Vectors from the first pass are interpolated to a smaller grid (red vectors). Interpolated vectors are employed to pre-shift and deform the interrogation area of the second pass. Correlation of shifted and deformed interrogation area yields a corrector to the interpolated first pass (predictor).

New perceptually uniform colormaps

Color maps portray the spatial variations of a scalar value. In PIV analysis, the scalar value may be a spatial derivative of the vector field, or an invariant or a principal component.

In many cases, the plotted scalar value varies between 0 and a maximum value, or between a negative minimum value and 0. In these cases, a perceptually uniform color map allows to faithfully report the small and large variations of the scalar value.

I have now included in the colormap folder of TecPIV the common colormaps from python matplotlib: viridis, magma, plasma, and inferno. viridis is a yellow-green-blue colormap while the others are yellow-orange-pink-purple.

I also created three new color maps following the same pattern: C1, C2, and C3. They are perceptually uniform varying between orange or pale yellow and dark purple.

The perceptual uniformity is obtained by sampling regularly in the L-a-b space instead of RGB space and enforcing that the luminance L (blue curve in figures below) is varying linearly throughout the color map like in the grayscale map.

The perceptual uniformity means that the human eye should be able to perceive the small variations equally across the entire colormap. The figure below shows a small-scale periodic variation that can be seen correctly from one side to the other.

The new colormaps and the inverses are available in the TecPIV repository, in the colormap folder.





Image calibration and rectification

An important step, perhaps the most important step, in using the Particle Imaging Velocimetry method is the calibration/rectification of the views of the model.

At it simplest the calibration assigns a scale to the images, allowing displacements in the image space (in pixel) to be converted to displacements in the physical world. However, the images are usually distorted and a single scale can not be applied uniformly. The distortions must be assessed and removed, in order to have such spatially uniform simple scale. This is the role of the calibration / rectification procedure.

In TecPIV the calibration / rectification for 2D PIV employs one single view of a calibration board with a known checkerboard pattern. For a surface view, the calibration board can be placed horizontally above the surface of the model, or above where the surface of the model will be, and then the camera can be lowered precisely to compensate this height difference. What matters is the relative position of the calibration board / model surface and camera.


Experimental set-up with checkerboard calibration board placed in order to constrain images of the model surface. The camera can be displaced vertically, and take oblique views of the calibration board / model surface.

Control points are found in the views of the calibration board. The relative positions of the control points is know. For example, the calibration board can have 30 by 30 squares that are 15 mm wide. The Harris corner detector allows finding the control points with subpixel precision. The positions are then evaluated against a target, ideal, position calculated using the position of the central point and the image resolution around this central point.


Image of the calibration board with control points (red crosses) before rectification. The four corners are selected by the user (pink circles), and the control points are found with sub-pixel precision. A dimension of the squares and number of squares are provided by the user. 


Projective rectification of the calibration view. The control points are now in a position that is much closer to the target regular grid, but the error on the rectification is still important. For example, some cushioning can be seen along the top and bottom lines.


Polynomial 3 rectification after the projective rectification. Polynomial corrections after projection allow the removal of the non-linear distortion. Now the error on the correction is about 1.2 pixels, while the resolution is 15.58 pixels / mm.

Linear (projective) and non-linear function are used sequentially to move all the control points towards their target positions. The error is calculated for the user to select the best projection method.

Here 875 control points have been employed to constrain a large portion of the image space, where the model will be.

It is important to note that only the area covered by the control points is calibrated. The model deformation should not be analyzed outside of the calibrated area.

The model views can be rectified using the functions defined during the calibration procedure, using the calibration board, and cropped such that the model outside the calibrated area is removed.

TecPIV v1901

A new version of TecPIV is available on github. TecPIV is not developed on MATLAB 2018b. The windows of the GUI have been redesigned. Each window is a separate figure, which gives more flexibility to adapt its size to the content. That’s a minor change for the user but was lots of change under the hood.

What’s more important, is the ability to calculate the Lagrangian sum of displacement and finite strain tensor components.

The GUI is clearer now, the user can plot as a scalar value, the derivatives of the incremental or cumulative displacements, the components of the small strain tensor, or the components of the finite strain tensor. Also available are the first and second invariant of these tensors (assuming a 2D tensor), and principal strain.

Back on the more trivial topics, the colormap of the plotted scalar value, and the rectified view of the model are now fused into one single bitmap. Previous versions of TecPIV exported two bitmap on top of one another with the top one being semi-transparent. This was difficult to handle in graphics packages like Inkscape, and sometimes the scalar colormap was gone. Now the output files (pdf) should be more friendly in Inkscape.

I will post some features of the new version here soon.

The Journey Begins

TecPIV is a bundle of MATLAB functions designed to facilitate the Particle Imaging Velocimetry analysis of tectonic models.
The aim is to make the analysis of the models and quantification of deformation more accessible.
As a new version of TecPIV is approaching, a dedicated web page seems appropriate.
On this page, I will provide information about the development, as well as links to the various versions, and help videos.