coordinates of region segmented

1 次查看(过去 30 天)
sbei arafet
sbei arafet 2016-3-20
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

回答(1 个)

Image Analyst
Image Analyst 2016-3-20
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 个评论
sbei arafet
sbei arafet 2016-3-20
编辑:sbei arafet 2016-3-20
Thanks for the ansewer i've tried PixelList but it gives the same resulat , so i tried
[x, y]=find(FC(:)>thresh)
[x1,y1]=find(FC(:)<thresh)
it gives the result but with a little problem seeds defined for the first segmentation are defined as background seed for the second segmentation as you can see,the green region aquire the red seeds wich are ues as foreground seeds for the first segmentation,i'll be grateful if have an idea about what could cause this problem
Image Analyst
Image Analyst 2016-3-20
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.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by