@Tanmay ,Your tutorial makes cross cotrelation easy to understand. I am using PIV technique in thermoacoustic device. I acquired data inside a hear exchanger channel by PIV but now I need to stitch 6 data together through Matlab to have images for full channel. Unfortunately, I don't know how to that in matlab as I don't have coding background. Would great if you could help, how can I contact you? Many thanks
Hi Sir! Your videos are very informative. Can you please make a video on how we can perform this experiment in a lab and if we put some flexible vegetation at different location in a channel then on which locations we have to find velocities. Also if you suggest some manuals on how to setup PIV and calculate velocity ? Your response is highly appreciated.
It seems this process is now made easier with the invention of the MATLAB extension, PIVLab by WIlliam Thielicke, could you make another video if possible using PIVLab?
Hello Tanmay Thank you for the video introduction to cross correlation. My background is particle localization and I am new to the field of PIV and therefore I have the following question. I have movies with 3D information of particle flow with time (with less density than your movies so I can do particle localization and particle trajectory linking) and I would like to do their time-dependent PIV. As i understand there is the cross correlation strategy which most people seem to use in 2D and there is the method of localizing particle positions, linking trajectories and therefore getting velocity vectors of each particle which seems to be the approach of some research websites doing 3D imaging and consequent PIV. Is it a common practice in the field to take the approach of cross correlation while doing 2D PIV and not using the same for 3D maybe because the time tomaximize the cross correlation in 3D space is maybe longer? Or is my naive observation not valid?
pretty cool man, congrats. Im just trying to change a little bit your code to do the same thing but in polar coordinates, for a fluid in a magnetic agitator.
I followed your script and I am getting this error: 'Unable to perform assignment because the size of the left size is 1-by-1 and the size of the right side is 2-by-1. Error in cross correlation (line 53) dpx(i,j) = xpeak1 - xgrid(I); ........anyone ? any help would be appreciated!
Can you please tell how to fit correlation peak with Gaussian curve to determine the peak location approximately and getting position data with some accuracy?
thanks for the quick reply.to do this cross correlation..do I need to install along with MATLAB additional software like PIV 4 toolbox or PIVlab? or can it be done directly on MATLAB alone?(I have MATLAB 2009)
No. MATLAB's image processing toolbox is all you need. It contains the inbuilt function normxcorr2 about which you can read more on au.mathworks.com/help/images/ref/normxcorr2.html
Hi Tanmay, Nice explaination for the topic. If you please explain how did you do the rescaling for the peaks' location. It will highly be appreciated. Thanks,
I'm getting following error: Error using normxcorr2>checkIfFlat (line 283) The values of TEMPLATE cannot all be the same. Error in normxcorr2>ParseInputs (line 250) checkIfFlat(T); Error in normxcorr2 (line 61) [T, A] = ParseInputs(varargin{:});
Awesome stuff! I tried running your commands on Matlab, but it's not working. I used an image from google images twice and displaced the particles a little bit in the +y-direction. However, I kept getting the following error: Index exceeds matrix dimensions. Error in CrossCorrelation (line 57) test_imb = imageb((test_xmin-x_disp_max):(test_xmax+x_disp_max),... I realized maybe the images where small or not clear enough. So I tried creating 2 images in Paint with white dots on a black background. However, I got the following error: Error in CrossCorrelation (line 65) dpx(i,j) = xpeak1 - xgrid(i); Please let me know what to do. I am very fascinated by the video!
Thank you. These errors are usually encountered when there is some problem with the window sizes or when you are doing something wrong with the indexing. I am not sure if the code is universally correct, but a double-checking wouldn't hurt :)
Hi, really nice work Tanmay! Just to inundate you with another question, has MATLAB updated its language? I tried to run your code. However in MATLAB 2020a, the matrices: test_ima and test_imb, are not fully populated with values. It seems that the for loop does not iterate past i = 1, filling even that window with arbitrary values. Therefore the normxcorr2 func reports that the template and image values cannot be the same and the script does not advance. Your code obviously runs in MATLAB 2016a as evident in the video, however the exact same code with similar image resolutions does not function in MATLAB 2020a. I understand this is an older video, however any advice would be great. Thanks.
Not sure what's going on there. I haven't run it in my current version of MATLAB. Please have a look manually what's going wrong and more importantly, why the two matrices are of similar size.
@@TanmayAgrawal7 Thank you for your reply. After some experimenting with the code, I found an embarassingly simple cause of error. The template image had areas of identically dark areas where pixel values were uniform. When the first window of the template tried to be compared with that of the subsequent image, MATLAB was identifying the entire image to be the same. Reframing the template to cover a more complex area of system (with regards to the 2D signal produced) and/or changing the window size rectified the issue. Thanks again for your help. Best wishes, Christian
hii, thank you for the introduction to cross correlation, can we find the voricity by defining the density of vectors? or else can you help to explain how to find vorticity of the flow field.
the sequence at 12:14 reminded me something I was doing some months ago in Matlab using the same image processing functions you're using and I had to do some tests to find out actully that fact about rows and columuns which made my program giving really weird results at first ... Nice video overall Please I have a question, I have read that the computational cost is much higher with direct cross-correlation than for fft cross-correlation. do you know about the fft cross-correlation ?
Thanks for the video. How about 3d cross correlation? Is it easy to use it on 2 images from different angles to extract out of plane displacement? (Z direction)
when i was reading some articles about PIV. I read something called planar self-calibration and volumetric self-calibration, are the the same as correlation or an other types of correlation????? thanks a lot for your videos.
when i tried to find a definition of it. i found it is a method to correct the misalignments between laser light sheet and calibration plane. but i don't have any idea wt is calibration plane and laser light sheet.
Yes. Calibration during an experiment is to make sure that your data is meaningful once you get it and you can get some sort of reference to measure it against. Correlation on the other hand is a post processing tool.
hi .thanks for video its realy helpfull . I'm using your code but i have a problem that i couldn't find answer for it can you help me ? at the line of 63 dpx(i,j)=xpeak1 - xgrid(i); i have an eror : "Assignment has more non-singleton rhs dimensions than non-singleton subscripts" how i can fix it ? it says the dimensions doesnt match but i cant accept that . i tryed this code on 2014 2016a 2017b matlabs and all of them had this error .
This is a very common problem and is usually encountered when the size of windows/image do not match their counterparts. OR. When you are trying to assign a matrix to another which is not of same size. Please do careful debugging. It should be solvable.
Hello, Tanmay dada, I am from Bangladesh. Can you please tell me what CHC is in terms of PIV analysis? And can its value be negative? like -2? I haven't yet started my PhD. Actually my potential supervisor asked me to do a calculation of determining time averaged velocity field and turbulent kinetic energy from some data which shows the u and v velocity data in different x and y co-ordinates. Can you help me in this?
A very basic tool could be to use snipping tool of windows to do that. Otherwise you can read the full image in MATLAB using imagesc and then make two matrices out of the one big matrix.
@@TanmayAgrawal7 Hello again! I need some help with PIV lab and MATLAB for my project. Is it possible I could discuss that with you in length? Kindly let me know. Regards :)
@@TanmayAgrawal7 So average velocity can be find from displacement values over time difference between pictures, right? because I could not see it in the code.
@@sevvalsaregulduren1955 Precisely! The time difference between the two snapshots is fixed by the camera and the code calculates the displacement between two windows.
Please check some of the numbers such as those related to size of the image (pixels). Or the numbers involved in the window. Make sure that the window#2 still lies within the image. Problems might occur when it is close to the boundary, hope that helps
your video is realllyyy save my ass! but may I ask, what is the dimension of your image instant1 and instant2? Since I don't know where 864 and 1696 came from for xgrid and ygrid. Thank you!
I believe it should be 1080 X 1920. That's where we trimmed the sides to make the dimensions 864 and 1696. Also this is related to the window size so that we are sure that everything fits nicely.
@@TanmayAgrawal7 I am receiving error. Could you help me please? Error using normxcorr2>checkSizesTandA (line 272) TEMPLATE must contain at least 2 elements. Error in normxcorr2>ParseInputs (line 242) checkSizesTandA(T,A) Error in normxcorr2 (line 61) [T, A] = ParseInputs(varargin{:}); Error in piv_code (line 52) correlation = normxcorr2(test_ima, test_imb);
Hi, this video seems very nice, good work! Cheers, William from PIVlab
Omg ! This means a lot !! I have learned PIV imaging in just 3 videos ! Amazing ! Thanks @Tanmay
great explanation , thank you!
Thanks Tanmay for the fluid explanation. This was extremely helpful.
thank you Tanmay, you did great. I am looking to capture strains in an arch. hopefully I shall be able to do it now.
Good luck. I am glad it helps.
It is really very well explained video Tanmay. We are actually looking forward about how to capture shear strain under plane strain condition.
good job Mr. Tanmay!
you just saved my life bro
Thanks, very good implementation
Great video with excellent presentation. Thank you, it helps a lot for beginners like me.
Thank you Tanmay.
Fantastic explanation. Very useful.
@Tanmay ,Your tutorial makes cross cotrelation easy to understand.
I am using PIV technique in thermoacoustic device. I acquired data inside a hear exchanger channel by PIV but now I need to stitch 6 data together through Matlab to have images for full channel. Unfortunately, I don't know how to that in matlab as I don't have coding background. Would great if you could help, how can I contact you? Many thanks
Thank you very much for the video. It was very helpful.
Hi Sir! Your videos are very informative. Can you please make a video on how we can perform this experiment in a lab and if we put some flexible vegetation at different location in a channel then on which locations we have to find velocities. Also if you suggest some manuals on how to setup PIV and calculate velocity ? Your response is highly appreciated.
Look up the book ob PIV by Raffel. That is pretty much everything you'd need.
Great video, really helpful.
Hello, I am confused why I always get a peak on the center of correlation matrix
Can you please tell me logic behind starting from 200 and ending at 864 matlab code line number 20
It seems this process is now made easier with the invention of the MATLAB extension, PIVLab by WIlliam Thielicke, could you make another video if possible using PIVLab?
Thank you Tanmay
Thanks for these two videos. Can you please uplode the Powerpiont in the discription?
Hello Tanmay
Thank you for the video introduction to cross correlation. My background is particle localization and I am new to the field of PIV and therefore I have the following question.
I have movies with 3D information of particle flow with time (with less density than your movies so I can do particle localization and particle trajectory linking) and I would like to do their time-dependent PIV.
As i understand there is the cross correlation strategy which most people seem to use in 2D and there is the method of localizing particle positions, linking trajectories and therefore getting velocity vectors of each particle which seems to be the approach of some research websites doing 3D imaging and consequent PIV.
Is it a common practice in the field to take the approach of cross correlation while doing 2D PIV and not using the same for 3D maybe because the time tomaximize the cross correlation in 3D space is maybe longer? Or is my naive observation not valid?
pretty cool man, congrats. Im just trying to change a little bit your code to do the same thing but in polar coordinates, for a fluid in a magnetic agitator.
Please feel free to do the same. If possible, please share your code which could help others.
It is a nice video about cross correlation in a image. Can you please explain the displacement part ?
I followed your script and I am getting this error: 'Unable to perform assignment because the size of the left size is 1-by-1 and the size of the right side is 2-by-1. Error in cross correlation (line 53) dpx(i,j) = xpeak1 - xgrid(I); ........anyone ? any help would be appreciated!
Can you please tell how to fit correlation peak with Gaussian curve to determine the peak location approximately and getting position data with some accuracy?
I am looking for ways to like this video more than once, if not 1million times.
Is the 2nd and last video on PIV?
Thanks for the kind words.
Most probably, yes. But at max, there could be one more.
hello tanmay what correlation is used here. Is it direct correlation or FFT type?
It is FFT based cross-correlation.
thanks for the quick reply.to do this cross correlation..do I need to install along with MATLAB additional software like PIV 4 toolbox or PIVlab? or can it be done directly on MATLAB alone?(I have MATLAB 2009)
No. MATLAB's image processing toolbox is all you need. It contains the inbuilt function normxcorr2 about which you can read more on au.mathworks.com/help/images/ref/normxcorr2.html
can you explain about the multi-pass option to obtain the velocity field of the captured images? Can share any literatutre related to that
Tanmay dude this is a pretty good tutorial , good job
Btw, would a 30 fps DSLR or 120 fps Iphone suffice for a small setup ?
I was thinking the same...
Don't know if I will get a response, but using your code and my images, my test_ima and b arrays appear to be all zeros, why is this the case?
Can you check the start and end indices?
Debugging line by line might be the way to go.
Hi Tanmay,
Nice explaination for the topic. If you please explain how did you do the rescaling for the peaks' location. It will highly be appreciated.
Thanks,
It's a shifting of coordinates you can imagine. The way normxcorr2 works is that it gives a zero padding in the system.
I'm getting following error:
Error using normxcorr2>checkIfFlat (line 283)
The values of TEMPLATE cannot all be the same.
Error in normxcorr2>ParseInputs (line 250)
checkIfFlat(T);
Error in normxcorr2 (line 61)
[T, A] = ParseInputs(varargin{:});
Hi,
I think your template is a uniform matrix with no changes at all. That is why...
as per the point mentioned at 3:56 mins Can you explain how to find the x and y displacements of the center of the window?
Awesome stuff!
I tried running your commands on Matlab, but it's not working. I used an image from google images twice and displaced the particles a little bit in the +y-direction. However, I kept getting the following error:
Index exceeds matrix dimensions.
Error in CrossCorrelation (line 57)
test_imb = imageb((test_xmin-x_disp_max):(test_xmax+x_disp_max),...
I realized maybe the images where small or not clear enough. So I tried creating 2 images in Paint with white dots on a black background. However, I got the following error:
Error in CrossCorrelation (line 65)
dpx(i,j) = xpeak1 - xgrid(i);
Please let me know what to do. I am very fascinated by the video!
Thank you. These errors are usually encountered when there is some problem with the window sizes or when you are doing something wrong with the indexing.
I am not sure if the code is universally correct, but a double-checking wouldn't hurt :)
Nice job, thx.
Its really work. Could you please publish Matlabcode?
can you share piv images for matlab prg
Hello, Great video bro...but i got an error while running the same programme for a test section can you help me with this
Could you explain Line number 61 and 62 of the code ?
Hi, really nice work Tanmay!
Just to inundate you with another question, has MATLAB updated its language? I tried to run your code. However in MATLAB 2020a, the matrices: test_ima and test_imb, are not fully populated with values. It seems that the for loop does not iterate past i = 1, filling even that window with arbitrary values. Therefore the normxcorr2 func reports that the template and image values cannot be the same and the script does not advance. Your code obviously runs in MATLAB 2016a as evident in the video, however the exact same code with similar image resolutions does not function in MATLAB 2020a. I understand this is an older video, however any advice would be great. Thanks.
Not sure what's going on there. I haven't run it in my current version of MATLAB. Please have a look manually what's going wrong and more importantly, why the two matrices are of similar size.
@@TanmayAgrawal7 Thank you for your reply. After some experimenting with the code, I found an embarassingly simple cause of error. The template image had areas of identically dark areas where pixel values were uniform. When the first window of the template tried to be compared with that of the subsequent image, MATLAB was identifying the entire image to be the same. Reframing the template to cover a more complex area of system (with regards to the 2D signal produced) and/or changing the window size rectified the issue. Thanks again for your help.
Best wishes, Christian
Thank you very much. It was very helpful. :-)
thanxx tanmay :)
hii, thank you for the introduction to cross correlation, can we find the voricity by defining the density of vectors? or else can you help to explain how to find vorticity of the flow field.
You need to calculate vorticity the mathematical way, using gradients, after calculating velocity.
the sequence at 12:14 reminded me something I was doing some months ago in Matlab using the same image processing functions you're using and I had to do some tests to find out actully that fact about rows and columuns which made my program giving really weird results at first ...
Nice video overall
Please I have a question, I have read that the computational cost is much higher with direct cross-correlation than for fft cross-correlation. do you know about the fft cross-correlation ?
FFT works with frequency space. Functions like normxcorr2 take advantage of that.
Thanks for the video.
How about 3d cross correlation? Is it easy to use it on 2 images from different angles to extract out of plane displacement? (Z direction)
I believe you are talking about stereo PIV, is that correct?
good
when i was reading some articles about PIV. I read something called planar self-calibration and volumetric self-calibration, are the the same as correlation or an other types of correlation?????
thanks a lot for your videos.
when i tried to find a definition of it. i found it is a method to correct the misalignments between laser light sheet and calibration plane.
but i don't have any idea wt is calibration plane and laser light sheet.
Yes. Calibration during an experiment is to make sure that your data is meaningful once you get it and you can get some sort of reference to measure it against. Correlation on the other hand is a post processing tool.
Hi! Have you calculated turbulent energy dissipation rate from PIV/LDA datas using MATLAB code? Thanks.
No, sorry.
hi .thanks for video its realy helpfull . I'm using your code but i have a problem that i couldn't find answer for it can you help me ?
at the line of 63 dpx(i,j)=xpeak1 - xgrid(i);
i have an eror :
"Assignment has more non-singleton rhs dimensions than non-singleton subscripts"
how i can fix it ?
it says the dimensions doesnt match but i cant accept that .
i tryed this code on 2014 2016a 2017b matlabs and all of them had this error .
This is a very common problem and is usually encountered when the size of windows/image do not match their counterparts. OR. When you are trying to assign a matrix to another which is not of same size. Please do careful debugging. It should be solvable.
Hola, ¿lo lograste solucionar?
Thanks, but how can i overlay the flow vectors on the image, the coordinates are different
Can you explain in detail what you meant?
Hello, Tanmay dada, I am from Bangladesh. Can you please tell me what CHC is in terms of PIV analysis? And can its value be negative? like -2? I haven't yet started my PhD. Actually my potential supervisor asked me to do a calculation of determining time averaged velocity field and turbulent kinetic energy from some data which shows the u and v velocity data in different x and y co-ordinates. Can you help me in this?
Hello. I'm not sure what CHC is since I'm not an expert in PIV. Please consult research papers.
Sir can you please share the Matlab code
I have a picture with double frames and i need to change it to individual single frame to do this in piv. Anyone know how?
A very basic tool could be to use snipping tool of windows to do that. Otherwise you can read the full image in MATLAB using imagesc and then make two matrices out of the one big matrix.
3:27 "Ah Oh" cutie pie lol
How do you interpret the graph you obtained using quiver? what do all those vectors represent? Thanks.
It plots the two dimensional matrix as a vector plot. In our case, it's a displacement plot you can say for various X and Y locations.
Thank you, Tanmay! You're a superstar!
@@TanmayAgrawal7 Hello again! I need some help with PIV lab and MATLAB for my project. Is it possible I could discuss that with you in length? Kindly let me know. Regards :)
Sir how to calibrate .. .
How to get 3D plot with correlation coefficient on the z-axis?
I think you're asking about the surface plot. Use the command surf, that should help.
Can we calculate the velocity of the particle according to this?
This approach provides a spatially averaged (in the window) velocity. For individual particle, please look up Lagrangian approaches.
@@TanmayAgrawal7 So average velocity can be find from displacement values over time difference between pictures, right? because I could not see it in the code.
@@sevvalsaregulduren1955 Precisely! The time difference between the two snapshots is fixed by the camera and the code calculates the displacement between two windows.
Hlo it's showing error at line 54 as index exceeds matrix dimension
Please check some of the numbers such as those related to size of the image (pixels). Or the numbers involved in the window. Make sure that the window#2 still lies within the image. Problems might occur when it is close to the boundary, hope that helps
make some more using dantec if possible
Bro could you help me to buy the PIV?
What specifically are you after? What is your budget?
your video is realllyyy save my ass!
but may I ask, what is the dimension of your image instant1 and instant2? Since I don't know where 864 and 1696 came from for xgrid and ygrid. Thank you!
I believe it should be 1080 X 1920. That's where we trimmed the sides to make the dimensions 864 and 1696. Also this is related to the window size so that we are sure that everything fits nicely.
Talks of windows, windows pops up a useless modal dialog, clicks the dialog, windows derails presentation...
I have a project related to this, can you just help me with it ?
Please email me on tanmayagrawal7@gmail.com
could you share the tiff files?
Please write to me on tanmayagrawal7@gmail.com
can u send me the code??
hi, thanks for the vid, would it be possible to ask some questions please via email
Yes sure. It's tanmayagrawal7@gmail.com
hi tanmay, is it the correct one please, email wont send
sorry my mistake, sent it now thank you Tanmay
@@TanmayAgrawal7 I am receiving error. Could you help me please?
Error using normxcorr2>checkSizesTandA (line 272)
TEMPLATE must contain at least 2 elements.
Error in normxcorr2>ParseInputs (line 242)
checkSizesTandA(T,A)
Error in normxcorr2 (line 61)
[T, A] = ParseInputs(varargin{:});
Error in piv_code (line 52)
correlation = normxcorr2(test_ima, test_imb);
>>
Lqq