Filter löschen
Filter löschen

coordinates of region segmented

1 Ansicht (letzte 30 Tage)
sbei arafet
sbei arafet am 20 Mär. 2016
Kommentiert: Image Analyst am 20 Mär. 2016
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

Antworten (1)

Image Analyst
Image Analyst am 20 Mär. 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 Kommentare
sbei arafet
sbei arafet am 20 Mär. 2016
Bearbeitet: sbei arafet am 20 Mär. 2016
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 am 20 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by