Expanding object: how do I calculate the speed of expansion from the movement of the edges?

Hello everyone,
I have a 320x320X360 cell in which a video of a (more or less) rectangular object is saved. The size of the object increses over the 360 frames and I would like to claculate the speed of expansion of the object and its change over time.
To do that, I would like to track the position of the edges at a certain row and column.
The images in the cell are binarized and I used the Canny method to extract the edges. Also, I know how big a pixel is (80x80 µm)
Until now I only have
for k = 1:framenumber
vertical(:,k) = bin_edge{1,k}(:,160);
horizontal (:,k) = bin_edge{1,k) (160,:);
end
which returns two matrices with zeros and ones, the ones indicating the found edges.
But how do I now calculate the speed from that? How can I measure the "distances", or the number of zeros between the ones (for they represent the edges)?
And what makes it even harder (at least for me, as a beginner) is that in some columns I have more than 2 ones. Sometimes, "edge" finds more edges within the objects, which I would like to exclude for the calculations.
I realy hope you can help me, since I tried for quite some time now and don't have any ideas anymore.
Many thanks from Germany Julian

 Accepted Answer

Why are you tracking edges? Why not find the area and log how that changes over the frames?

5 Comments

Because I need the ratio of vertical and horizontal expansion to distinguish between different mechanisms behind the expansion.
So the fact that they could expand differently in the long axis direction and the short axis direction is important, and they need to be measured separately? Are you sure that your camera and the object are always aligned so that the object is parallel with rows and columns of your image matrix?
Looking at your image below, in your "Answer" I don't see why you can't just use sum() to sum the image vertically and horizontally and then threshold or use findpeaks() (In the Signal Processing Toolbox) or imregionalmax() (in the Image Processing Toolbox) to find the row or column where the flat edges lie.
This is a good idea, but the objects change their shape considerably (link to the object at frame 100 http://imgur.com/ADUeKxY ). I would like to describe the behavior only at a certain row and column. Additionally, "camera" and object are not alway perfectly aligned (I have more than 100 of these MRI videos).
To calculate the speed of expansion I "only" need the distance between the pixel at the very top and the very bottom of a row. The rest I can do by myself. I just can't think of a way to get that distance :(
Something like
for col = 1 : columns
thisColumn = yourImage(:, col);
topRow = find(thisColumn, 1, 'first');
bottomRow = find(thisColumn, 1, 'last');
height(col) = bottomRow - topRow; % Add 1 if you're doing pixel based instead of pixel center - to - pixel center.
end
Ah, the 'first', 'last' does the trick. Thank you a lot!
This one here is working just fine:
if sum (vertical(:,k)) < 2
else
topedge (1,k) = find (vertical(:,k), 1, 'first');
bottomedge (1,k) = find (vertical(:,k), 1, 'last');
end
if sum (horizontal(:,k)) < 2
else
leftedge (1,k) = find (horizontal(:,k), 1, 'first');
rightedge (1,k) = find (horizontal(:,k), 1, 'last');
end
height = bottomedge - topedge;
diameter = rightedge - leftedge;
Thanks again!
Julian

Sign in to comment.

More Answers (1)

Here is an example image
The edges deform quite a bit over time.
Here is a link to the "vertical" matrix in which column 160 is saved for all frames ( http://www.speedshare.org/download.php?id=EFCFBB7C1 )
Then, I used
[rowIdx,colIdx] = find (vertical(1:160,:));
[rowIdx2,colIdx2] = find (vertical(161:320,:));
to find the indices of the upper and lower boundaries of the object.
Link to rowIdx of the upper edge: http://www.speedshare.org/download.php?id=FE0FBF4F1
Now, as you can see in "vertical" quite often, there is more than one 1 in a column. How do I only "detect" the ones with the lowest row number (for the upper edges) and the highest row numer (for the lower edges)?
Am I on the right way, to solve my problem, or do you have a better idea?
Thank you Julian

3 Comments

I don't believe this is an "Answer" to your question, so it should have been a comment to my Answer or an edit to your original post.
Yes, you're right of course. The boards I usualy frequent (not matlab related stuff) don't distinguish between answers and comments, so in this case I just klicked the answer button withouth thinking about it. Won't happen again.
Did you notice the comment I posted above, under my answer, that had some code in it?

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!