0

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.

enter image description here

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

Hojo.Timberwolf
  • 985
  • 1
  • 11
  • 32
  • relevant? relative you mean? Its not clear what is the thing you want to do. Do you want the relative distances of all points to all other points? Then you need to do exactly what you have done, but not to 1 anchor point, but in a for loop to all existing points. The best way to store this is in a `Nroi x Nroi x Nd` lower triangular matrix – Ander Biguri Nov 13 '18 at 10:35
  • in the end I want to label the ROI based on a 5x8 matrix. for instance the first ROI is 1,1 and the gap would fill the 5x4 position – Hojo.Timberwolf Nov 13 '18 at 11:18
  • ahh, you are looking for the missing blocks in a higher order grid, I get i t now. Why 5x4 and not 5x1, does it matter where is the origin? Also, is the grid always this regular? – Ander Biguri Nov 13 '18 at 11:20
  • 1
    I think this is a very very hard problem. I'd start looking at https://stackoverflow.com/questions/29550785/algorithm-to-group-sets-of-points-together-that-follow-a-direction – Ander Biguri Nov 13 '18 at 11:38
  • yes the grid will be regular as I am looking at multi well plates. These plates are 5x8, 10x8, or 6x4. I actually import a cell matrix containing a label for each ROI. As for the origin, I dont think it matters as long as I know where the ROI is relative to a 5x8 format. – Hojo.Timberwolf Nov 13 '18 at 12:05
  • @AnderBiguri thanks for pointing me in the right direction. I kind of thought this was a difficult question but didn't realize just how difficult it is. The code in the link does help and provide me with a starting point. – Hojo.Timberwolf Nov 14 '18 at 06:01
  • No worries. Feel free to post an answer here if you end up cracking the problem. – Ander Biguri Nov 14 '18 at 09:57

0 Answers0