I've been posting examples of Hough Transform since last month, and now is the time to switch to other examples.
1. Reading image and comparing 2 images side by side
Ia = imread('pic23a.jpg');
Ib = imread('pic23b.jpg');
2. Finding the location of green object in 2 images
a. Set the threshold value for green color
p/s: I can't make the "&" appear in text, so the text aboved is in image format.
b. Find the location of the green object
[y1,x1] = find(Ia_green==1);
[y2,x2] = find(Ib_green==1);
c. Find the centroid of the green object
x1 = round(mean(x1));
y1 = round(mean(y1));
x2 = round(mean(x2));
y2 = round(mean(y2));
3. Putting 2 images together and show the movement of the objects
imshow(Ia); hold on;
The '*' indicates the start point of the object while the 'o' is the stop point of the object. Other objects' movement could be found by modifying the step number 2.