dimanche 19 avril 2015

displaying images on a biograph object in Matlab

I use a biograph object to represent a connected graph, where each node stands for an image. I would like to display a node's image when clicking on it.


In the following code, when clicking on a node, the relevant image is displayed in a different figure. How can I display it on the same figure as the biograph, just next to the relevant node?


If there is a more friendly way to handle connected graphs in Matlab, which can solve my problem, I'd be happy to learn about it.


Thank you in advance!


My code:


% anchors_mat is the connection matrix


bg=biograph(anchors_mat);


set(bg, 'NodeCallbacks', @node_callbacks)


% s is a struct which holds all images


for i=1:size(anchors_mat,1)



% 'UserData' for each node gets the relevant image:
bg.nodes(i).UserData=s(i).image;


end


view(bg);


function node_callbacks(node)


figure;imshow(node.UserData)


end


Aucun commentaire:

Enregistrer un commentaire