How to make bwlabel count in the same order in two different images?

조회 수: 3 (최근 30일)
Changoleon
Changoleon 2016년 10월 22일
Hi folks,
I am trying to write a code that can track particles. So I have an image pair. In the first one particles have a specific location. In the second one, the same particles have moved a certain distance and are in new locations because of the flow. (please take a moment and see the attached pictures - you should be able to see that they move by toggling the pictures). After pre-processing these images, I have used the code below to count the particles:
[L_particle1, num_particle1]=bwlabel(M1);
[L_particle2, num_particle2]=bwlabel(M2);
The counting and numbering is accurate. Both pictures have 100 particles each. But the problem is since bwlabel starts counting from northwest, the very same particles have different numbers (order). For instance, the red particle that I have illustrated has the number 26 in the first image, and in the second image, it is 21st particle. Now in case you wonder why this is important, it is because once I am done with counting them, I use region props to locate the centroide in each particle in both pictures and I use following code to find the cartesian coordinates:
for
i=1:length(s1);
x_centroid1(i) = s1(i).Centroid(1);
y_centroid1(i) = s1(i).Centroid(2);
end
Later on, once I have the cartesian coordinates of both particles sets, and velocity in x and y direction, I use quiver to plot the actual velocity vectors. But all of these would be erroneous if the number order is not accurate.
Please let me know if you need more explanation. I would be very appreciated if someone can help here.
Sina Dadgar

답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Volume Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by