Cross-Correlation for Particle Image Velocimetry (PIV) using MATLAB

In this tutorial, I discuss the concept of cross-correlation and how it can be used to study and analyze images obtained from a PIV set-up.
Support my work: www.buymeacoffee.com/iamtanmay

Пікірлер: 111

  • @songswrittenbyme
    @songswrittenbyme6 жыл бұрын

    Thanks Tanmay for the fluid explanation. This was extremely helpful.

  • @arpansow3870
    @arpansow38703 жыл бұрын

    Omg ! This means a lot !! I have learned PIV imaging in just 3 videos ! Amazing ! Thanks @Tanmay

  • @sreedharmatkm
    @sreedharmatkm6 жыл бұрын

    Great video with excellent presentation. Thank you, it helps a lot for beginners like me.

  • @sreelakshmig1698
    @sreelakshmig16987 жыл бұрын

    It is really very well explained video Tanmay. We are actually looking forward about how to capture shear strain under plane strain condition.

  • @Willa1980
    @Willa19805 жыл бұрын

    Hi, this video seems very nice, good work! Cheers, William from PIVlab

  • @arnabchakraborty6342
    @arnabchakraborty63426 жыл бұрын

    thank you Tanmay, you did great. I am looking to capture strains in an arch. hopefully I shall be able to do it now.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    Good luck. I am glad it helps.

  • @Alimaliyu
    @Alimaliyu6 жыл бұрын

    Fantastic explanation. Very useful.

  • @ashutoshpati7874
    @ashutoshpati78747 жыл бұрын

    Thank you Tanmay.

  • @pawandev23
    @pawandev234 жыл бұрын

    good job Mr. Tanmay!

  • @kumaruiuc3498
    @kumaruiuc34987 жыл бұрын

    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?

  • @yernurchakenov4659
    @yernurchakenov46594 жыл бұрын

    Thanks, very good implementation

  • @berkcanozturk655
    @berkcanozturk6553 жыл бұрын

    Great video, really helpful.

  • @madepython
    @madepython5 жыл бұрын

    Thank you Tanmay

  • @roshanjoshi8069
    @roshanjoshi80693 жыл бұрын

    Thank you very much for the video. It was very helpful.

  • @shareyguleria54
    @shareyguleria546 жыл бұрын

    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?

  • @souradippaul7466
    @souradippaul74665 жыл бұрын

    It is a nice video about cross correlation in a image. Can you please explain the displacement part ?

  • @ASHISHKUMAR-be7ly
    @ASHISHKUMAR-be7ly6 жыл бұрын

    thanxx tanmay :)

  • @flowingcode8069
    @flowingcode80696 жыл бұрын

    Thank you very much. It was very helpful. :-)

  • @alexandradupere5377
    @alexandradupere53773 жыл бұрын

    you just saved my life bro

  • @melvinabraham3451
    @melvinabraham34516 жыл бұрын

    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 ?

  • @MrKestable

    @MrKestable

    6 жыл бұрын

    I was thinking the same...

  • @mfoucault1984
    @mfoucault19846 жыл бұрын

    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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    Please feel free to do the same. If possible, please share your code which could help others.

  • @amonahud3250
    @amonahud32502 жыл бұрын

    @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

  • @alexanderbraun8742
    @alexanderbraun87424 жыл бұрын

    Nice job, thx.

  • @nabil9223
    @nabil92233 жыл бұрын

    Thanks for these two videos. Can you please uplode the Powerpiont in the discription?

  • @deepbhatt2254
    @deepbhatt22544 жыл бұрын

    Hello, Great video bro...but i got an error while running the same programme for a test section can you help me with this

  • @lovelyboy1366
    @lovelyboy13667 жыл бұрын

    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)

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    I believe you are talking about stereo PIV, is that correct?

  • @ansumansahu5245
    @ansumansahu52454 жыл бұрын

    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?

  • @omarsalem5832
    @omarsalem58324 күн бұрын

    great explanation , thank you!

  • @yogeshwarang2043
    @yogeshwarang20432 жыл бұрын

    can you explain about the multi-pass option to obtain the velocity field of the captured images? Can share any literatutre related to that

  • @mehbubbasha2615
    @mehbubbasha26153 жыл бұрын

    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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    3 жыл бұрын

    You need to calculate vorticity the mathematical way, using gradients, after calculating velocity.

  • @muhammadnawaz9818
    @muhammadnawaz98182 жыл бұрын

    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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    2 жыл бұрын

    Look up the book ob PIV by Raffel. That is pretty much everything you'd need.

  • @mohsinqureshi5075
    @mohsinqureshi50754 жыл бұрын

    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,

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    It's a shifting of coordinates you can imagine. The way normxcorr2 works is that it gives a zero padding in the system.

  • @nazimbennini9721
    @nazimbennini97214 жыл бұрын

    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 ?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    FFT works with frequency space. Functions like normxcorr2 take advantage of that.

  • @asharmd2001
    @asharmd20017 жыл бұрын

    Hi! Have you calculated turbulent energy dissipation rate from PIV/LDA datas using MATLAB code? Thanks.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    No, sorry.

  • @8880Blue
    @8880Blue6 жыл бұрын

    Its really work. Could you please publish Matlabcode?

  • @muhammadchoudhry5864
    @muhammadchoudhry58644 жыл бұрын

    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!

  • @yuvanscircle3437
    @yuvanscircle34376 жыл бұрын

    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!

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    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 :)

  • @mostafanagi8406
    @mostafanagi84065 жыл бұрын

    Thanks, but how can i overlay the flow vectors on the image, the coordinates are different

  • @TanmayAgrawal7

    @TanmayAgrawal7

    5 жыл бұрын

    Can you explain in detail what you meant?

  • @ansumansahu5245
    @ansumansahu52454 жыл бұрын

    Could you explain Line number 61 and 62 of the code ?

  • @christianarmstrong754
    @christianarmstrong7544 жыл бұрын

    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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    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.

  • @christianarmstrong754

    @christianarmstrong754

    4 жыл бұрын

    @@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

  • @mohammadhdaib3300
    @mohammadhdaib33005 жыл бұрын

    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.

  • @mohammadhdaib3300

    @mohammadhdaib3300

    5 жыл бұрын

    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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    5 жыл бұрын

    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.

  • @ludwigprandtl39
    @ludwigprandtl394 жыл бұрын

    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?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    Hello. I'm not sure what CHC is since I'm not an expert in PIV. Please consult research papers.

  • @ahmadsyazwan6555
    @ahmadsyazwan65555 жыл бұрын

    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?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    5 жыл бұрын

    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.

  • @asrithpyla606
    @asrithpyla6066 жыл бұрын

    How to get 3D plot with correlation coefficient on the z-axis?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    I think you're asking about the surface plot. Use the command surf, that should help.

  • @VikiJoker1924
    @VikiJoker192411 ай бұрын

    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?

  • @ahsanzaman1562
    @ahsanzaman15625 жыл бұрын

    How do you interpret the graph you obtained using quiver? what do all those vectors represent? Thanks.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    5 жыл бұрын

    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.

  • @ahsanzaman1562

    @ahsanzaman1562

    5 жыл бұрын

    Thank you, Tanmay! You're a superstar!

  • @ahsanzaman1562

    @ahsanzaman1562

    5 жыл бұрын

    @@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 :)

  • @SGK2325
    @SGK23254 жыл бұрын

    can you share piv images for matlab prg

  • @ChiefEngr-GabsonAcademy
    @ChiefEngr-GabsonAcademy7 жыл бұрын

    I am looking for ways to like this video more than once, if not 1million times. Is the 2nd and last video on PIV?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    7 жыл бұрын

    Thanks for the kind words. Most probably, yes. But at max, there could be one more.

  • @maheshtom9003

    @maheshtom9003

    6 жыл бұрын

    hello tanmay what correlation is used here. Is it direct correlation or FFT type?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    It is FFT based cross-correlation.

  • @maheshtom9003

    @maheshtom9003

    6 жыл бұрын

    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)

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    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

  • @sumitzanje9660
    @sumitzanje96603 жыл бұрын

    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{:});

  • @TanmayAgrawal7

    @TanmayAgrawal7

    3 жыл бұрын

    Hi, I think your template is a uniform matrix with no changes at all. That is why...

  • @manjupoorvi7701
    @manjupoorvi77016 жыл бұрын

    Hlo it's showing error at line 54 as index exceeds matrix dimension

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    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

  • @solnik6236
    @solnik62365 жыл бұрын

    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 .

  • @TanmayAgrawal7

    @TanmayAgrawal7

    5 жыл бұрын

    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.

  • @santiagocanozapata9572

    @santiagocanozapata9572

    5 жыл бұрын

    Hola, ¿lo lograste solucionar?

  • @aathirahvalmaypriyono6954
    @aathirahvalmaypriyono69544 жыл бұрын

    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!

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    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.

  • @nesbittwei6307
    @nesbittwei63074 жыл бұрын

    3:27 "Ah Oh" cutie pie lol

  • @Rahul-ny4ee
    @Rahul-ny4ee7 жыл бұрын

    make some more using dantec if possible

  • @sanjaykalita711
    @sanjaykalita7112 ай бұрын

    Can you please tell me logic behind starting from 200 and ending at 864 matlab code line number 20

  • @user-kr8ev8rs9t
    @user-kr8ev8rs9t Жыл бұрын

    Hello, I am confused why I always get a peak on the center of correlation matrix

  • @jasonwong2726
    @jasonwong2726 Жыл бұрын

    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?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    Жыл бұрын

    Can you check the start and end indices? Debugging line by line might be the way to go.

  • @RahmanIITDelhi
    @RahmanIITDelhi2 жыл бұрын

    Sir how to calibrate .. .

  • @cwprsselvabalan7872
    @cwprsselvabalan78723 жыл бұрын

    good

  • @sevvalsaregulduren1955
    @sevvalsaregulduren19552 жыл бұрын

    Can we calculate the velocity of the particle according to this?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    2 жыл бұрын

    This approach provides a spatially averaged (in the window) velocity. For individual particle, please look up Lagrangian approaches.

  • @sevvalsaregulduren1955

    @sevvalsaregulduren1955

    2 жыл бұрын

    @@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.

  • @TanmayAgrawal7

    @TanmayAgrawal7

    2 жыл бұрын

    @@sevvalsaregulduren1955 Precisely! The time difference between the two snapshots is fixed by the camera and the code calculates the displacement between two windows.

  • @PaulaGarciaRuiz
    @PaulaGarciaRuiz4 жыл бұрын

    could you share the tiff files?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    4 жыл бұрын

    Please write to me on tanmayagrawal7@gmail.com

  • @sameerkosurkar7801
    @sameerkosurkar78013 жыл бұрын

    I have a project related to this, can you just help me with it ?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    3 жыл бұрын

    Please email me on tanmayagrawal7@gmail.com

  • @kbrajasekarababu3878
    @kbrajasekarababu38782 жыл бұрын

    Bro could you help me to buy the PIV?

  • @TanmayAgrawal7

    @TanmayAgrawal7

    2 жыл бұрын

    What specifically are you after? What is your budget?

  • @raghuvanshnarayan916
    @raghuvanshnarayan9163 жыл бұрын

    can u send me the code??

  • @ramavathjagadeesh1030
    @ramavathjagadeesh1030 Жыл бұрын

    Sir can you please share the Matlab code

  • @mkschreder
    @mkschreder5 жыл бұрын

    Talks of windows, windows pops up a useless modal dialog, clicks the dialog, windows derails presentation...

  • @ernestadisi491
    @ernestadisi4916 жыл бұрын

    hi, thanks for the vid, would it be possible to ask some questions please via email

  • @TanmayAgrawal7

    @TanmayAgrawal7

    6 жыл бұрын

    Yes sure. It's tanmayagrawal7@gmail.com

  • @ernestadisi491

    @ernestadisi491

    6 жыл бұрын

    hi tanmay, is it the correct one please, email wont send

  • @ernestadisi491

    @ernestadisi491

    6 жыл бұрын

    sorry my mistake, sent it now thank you Tanmay

  • @SahadevanVigneshN

    @SahadevanVigneshN

    3 жыл бұрын

    @@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); >>

  • @harshavardhanreddy4671
    @harshavardhanreddy4671 Жыл бұрын

    Lqq