Thank you for your answers, all methods work fine :)
One extra thing
For multiple time steps, how do I create a table which calculates the occurrences
e.g.
for n = 1:10
endii = imerode(A(:,:,1),[1 1 1;1 0 1;1 1 1]) > A(:,:,1) &...
imerode(A(:,:,2),[1;0;1;0;0]) < 0 &...
imdilate(A(:,:,3),[1,1,0]) > A(:,:,3);
[r,c] = find(ii);
end
Instead of it just displaying a the r and c value for every n value in the command window, could another matrix be created which fills in r and n values as it goes along e.g.
1 4 34
2 3 90
2 7 75
3 14 89
Where in the above the first column is n, the second r and the third c.