Effacer les filtres
Effacer les filtres

ginput

9 vues (au cours des 30 derniers jours)
bahar cham
bahar cham le 13 Fév 2012
Modifié(e) : Youssef Khmou le 10 Oct 2013
Hi all,
I have 160 slices(408*544*160) with a 3d patch on it. I need to find one point on each slice and take in return a 3d matrix of patch: it is my idea but it seems has a fundamental misunderstanding.
d=zeros(408,544,160);
for i=1:160
figure,imshow(image(:,:,i)),[]);
[a,b]=ginput(1);
z=image(a,b,i);
d(a,b,i)=z;
end
how can i fix it?
I was wondering if I can select random point in each slice?when I use ginput, there is noting to stop it from receiving points. How can take it in return as 3d matrix?

Réponse acceptée

Sean de Wolski
Sean de Wolski le 13 Fév 2012
d=zeros(408,544,160);
image = rand(size(d));
for i=1:160
figure,imshow(image(:,:,i),[]);
[a,b]=ginput(1);
a = round(a);
b = round(b);
z=image(a,b,i);d(a,b,i)=z;
end
You have to round the points returned from ginput to account for floating points. I would also recommend against opening a new figure on each iteration.
  2 commentaires
bahar cham
bahar cham le 13 Fév 2012
Thanks. It works. But, can you say what do you mean:"recommend against opening a new figure on each iteration"and what is your idea?
Sean de Wolski
Sean de Wolski le 13 Fév 2012
well if you run the above code, you'll end up with 160 open figures. Which is a lot of clutter, not to mention used memory. I would either close the figure after ginput() or overwrite the image with each call to imshow().

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Visual Exploration dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by