Group Abstract Group Abstract

Message Boards Message Boards

Image Correlation in Particle Image Velocimetry is behaving strangely

Attachments:
POSTED BY: Ali Hashmi
8 Replies

Hi Henrik and Sander,

I have the code up on Github and mentioned you guys in the credits:

https://github.com/alihashmiii/simple-piv/blob/master/flowtrack.m

POSTED BY: Ali Hashmi

Hi Ali,

yes, I do think so: See documentation about FindGeometricTransform ->"Details and Options" -> TransformationClass.

Regards -- Henrik

POSTED BY: Henrik Schachner

Hi Henrik,

I had a a quick question. Will Geometric Transformation work in a complex case: for example, consider some particles in one region of the image rotate a little whereas particles in the second region of the image undergo a linear translation?

Regards, Ali

POSTED BY: Ali Hashmi

Also, I I think we should crop the image so that the edges are not taken into account during computation. But overall your procedure is way faster !! so thumbs up :)

POSTED BY: Ali Hashmi

Hi Henrik,

This is a very nice implementation. The advantage of using Mathematica is that solutions can be implemented using multiple approaches. Btw i have a little to offer to your code. We need to make sure that the points are in the image coordinate system. This was a mistake I made earlier when the flow-field looked queer. We can use a modified version of your code below:

images = Import["C:\\Users\\Ali Hashmi\\Desktop\\PIV\\Testpiv3.gif"];
imgDim = ImageDimensions[First@images];
windowsize = 32;
imgCorrD = First@imgDim;
img = ImageCrop[#, imgDim - (2*windowsize)] & /@ images; 
gtrf = Last[FindGeometricTransform @@ img];
rpts = RandomInteger[{windowsize, windowsize+First@ImageDimensions[First@img]}, {1000, 2}];
Graphics[{Arrowheads[.01], Darker@Cyan,  Arrow /@ Transpose[{Map[Abs[# - {0, imgCorrD}] &, #] &@rpts,
     Map[Abs[# - {0, imgCorrD}] &, #] &@gtrf[rpts]}]}, ImageSize -> 600]

enter image description here

POSTED BY: Ali Hashmi

Hi Ali,

maybe I do not really understand your question, but is it not as simple as:

img = Binarize /@ Import["Testpiv3.gif"];
gtrf = Last[FindGeometricTransform @@ img];

Ready! -- Now one can do e.g.:

rpts = RandomInteger[{1, First@ImageDimensions[First@img]}, {1000, 2}];
Graphics[{Arrowheads[.01], Arrow /@ Transpose[{rpts, gtrf[rpts]}]}, ImageSize -> 600]

which gives:

enter image description here

Regards -- Henrik

POSTED BY: Henrik Schachner

Hi Sander,

I need time to understand what you mentioned in point #2.

Btw i think i found a mistake which atleast solves the issue. The position that are returned needs to be converted to image coordinate system. Silly mistake i would say.

See github code for the fix: https://github.com/alihashmiii/simple-piv/blob/master/flowtrack.m

![enter image description here][1]

POSTED BY: Ali Hashmi

Hi Ali,

What commercial codes does is a bit more elaborate. Generally one uses multi-pass processing:

  1. For a course window (e.g. 128x128) one does the piv like you did. This will give you the rough motion for that area.
  2. Now one does the smaller scale: (64x64 or 32x32). But one does not compare the same pixels from each image; one already shifts the window by this approximate large-scale PIV. This will give much stronger correlation, because the overlap will be much larger.

This can be seen in your bottom-left, the displacement is large (~10-12 pixels i estimate) which is large fraction of your window. By selecting a windows that is roughly 10 pixels displaced already the correlation is much better.

In PIV one generally aims for 5-6 pixels displacement. Too small and one loses precision in determining the displacement. Too large and your windows need to be very large or many 'passes'.

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard