coordinates of region segmented
1 view (last 30 days)
Show older comments
Hi,
I'm trying to recuperate coordinates of region segmented by fuzzy connectedness algorithm to use the foreground and the background as new seeds for the segmentation by the graph cut algorithm so the foreground will be the source and the background the sink , the problem that when i try to get new seeds it returns the first seeds chosen for fuzzy connectedness algorithm here is the source code
FC=afc(S,K);%Absolute FC
u=FC>thresh;
v=FC<thresh;
s=regionprops(u, 'PixelIdxList');%listes de pixels de l'objet
t=regionprops(v, 'PixelIdxList');%listes de pixels de l'arrière plan
[a,b]=size(s);
[w,c]= size(t)
for i=1:a
for j=1:b
[y,x] = ind2sub(size(u), s(i,j).PixelIdxList);
end
end
for k=1:w
for d=1:c
[y1,x1] = ind2sub(size(v), t(k,d).PixelIdxList);
end
end
0 Comments
Answers (1)
Image Analyst
on 20 Mar 2016
To get the x,y coordinates, don't do all that stuff with ind2sub() because regionprops() gives you the coordinates directly. Just ask regionprops() for PixelList instead of PixelIdxList.
2 Comments
Image Analyst
on 20 Mar 2016
You've made a very, very common mistake that beginners usually make. In fact, so far, this is the second time I've had to correct people just today. You've swapped x and y. The syntax for find is NOT
[x, y] = find(signal);
It is
[rows, columns] = find(signal);
or equivalently
[y, x] = find(signal);
I'm not sure what else you're doing and possibly doing wrong but make that correction and see if it fixes things.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!