Simplifying the question. I want to find the relevant position of an ROI to other ROIs and place the results in a matrix.
example, here is a picture containing a series of ROIs.
Positions of ROIs can be pulled using the region props
function.
stats = regionprops(ROIs,'centroid');
First I thought of taking a centroid and using it as an anchor for other points
t1 = transpose([stats.Centroid]);
t2 = transpose(reshape(t1,[2,40]));
[~,idx] = find(t2(:,1)==min(t2(:,1)));
anchorpoint = t2(idx,:);
ydif = t2(:,1)-anchorpoint(1);
xdif = t2(:,2)-anchorpoint(2);
This will give me relative distances to the anchor point with sign (+ -) denoting before, after or above, below. what would be the next step?
I can find the supposed dimensions of the array from the anchor point
ydim = sum((abs(ydif)<20))
ydim = 5
xdim = sum((abs(xdif)<20))
xdim = 8
but this is relative as there are gaps in ROIs.
I'm an lost as to what to do from this point