correlation matrix

43 views
Skip to first unread message

Rabinder Kaur

unread,
Jul 29, 2025, 9:31:17 AMJul 29
to PIVlab
Hi William, 

I am working with PivLab for PIV analysis; I have some questions:

1. I am trying to save the correlation matrix in the PivLab session as a saved variable; I also toggled from zero to one the do_correlation_matrix command line in pivlab_gui, but still I am not getting saved the correlation matrix automatically; How can I do that, please?

2. I have analyzed the images and obtained the velocity data required; as a part of the anaysis, I wanted somehow to distinguish between low-fidelity data and high-fidelity data, depending on how the data is processed from the images (my geometry is a duct and near the wall, where the excluded areas with the mask terminates, there is some reflection and the velocity data is visibly not correct in a small portion); is there any way to obtain it form PivLab, maybe by combining some tools like the correlation matrix? 

Looking forward to hear from you

JSingh

thielickeoptolution

unread,
Jul 30, 2025, 6:34:06 AMJul 30
to PIVlab
Dear  JSingh,
1: are you talking about the correlation matrix for each vector (e.g. 32x32px for each vector)? Or are you talking about the correlation map (1 value per vector)?
2: The correlation coefficient in Plot -> Spatial ...-> Correlation coefficient will tell you how good the correlation is. But this is only meaningful if you subtracted the background image.

Rabinder Kaur

unread,
Aug 4, 2025, 8:35:55 AMAug 4
to PIVlab
Hi William,

thank you for the reply; actually, I could not get the difference between the correlation matrix and map? I need a correlation variable ranging from 0 to 1 indicating the quality of the processed velocity data over the interrogation areas, so to distinguish between low and high quality data.
What I understood is the correlation map that will give one scalar value for each vector, so it would be a matrix mxn as the velocity field data or the image resolution; is it correct?
Instead, I could not imagine the correlation matrix? Will it give a matrix sxt for each vector present in mxn image?

Could you explain it better or give a reference for these variables, please? Maybe, you could recommend which variable to use between the two on the basis of the description of what I am looking for?

Thank you for your time. Looking forward to hearing from you.

thielickeoptolution

unread,
Aug 6, 2025, 7:13:12 AMAug 6
to PIVlab
Hi, this is a correlation matrix:

This can also be given by PIVlab if you enable the do_correlation_matrix flag. But this is not what you want. You want the correlation coefficient. This is available in PIVlab under Plot->Spatial:derive parameters -> correlation coefficient. You can export by going to File-> Export-> MAT file. The variable in the mat file is called "correlation_map"

Rabinder Kaur

unread,
Aug 6, 2025, 8:47:53 AMAug 6
to PIVlab
Hi William,

thank you for the reply; to the point in explaining the correlation matrix and highlighting that I probably need the correltion coefficient; 

I applied your instructions for the correlation coefficient and exported the data that is seen as correlation map; now, this variable mainly varies between 0 and 1 in my case, but it has also some negative values in the matrix for each frame; I have totally 10 frames and each one of them has negative values;  I will attach an image to see tha case visually; moreover, this variable is applied only at the frames having the couple of images and not to the mean frame extrcyed through temporal: derive parameters frame;

1. Could you please explain what does the correlation map shows or describe? What does it correlate and shows (physically what does it mean)? and why it has negative values? 
2. This correaltion map is for now maybe the nearest variable that I could use for my scope. Still, this variable varies  theorically between 0 and 1; is there anyway that I could just have a matrix of only ones or zeroes defining that this interrogation area is good so one and the other one is not correlated well so it is zero; one way could be to use the correlation map with a threshold value, but is there any direct way somehow?

I really thank you for your patience and all the clarifications you are giving. 

Looking to hear from you soon. 

JSingh
pivlab_correlation_map_example.png

thielickeoptolution

unread,
Aug 6, 2025, 9:38:57 AMAug 6
to PIVlab
PIVlab uses Matlab function corr2 to calculate the correlation between input subimage a an B (in the last pass, after image deformation). Negative values mean that there is negative correlation. Maximum correlation of 1 is given when both subimages are identical. As I said above: "But this is only meaningful if you subtracted the background image.  " Because there might also be a strong correlation between the subimages when there is a stron and constant background signal.
I do not understand your second question. The strength of a correlation (and its maximum value) depend on the experimental conditions. How many particles are present, how much noise, how much background signal. 
Reply all
Reply to author
Forward
0 new messages