How to update polygon location in standard MATLAB script

4 vues (au cours des 30 derniers jours)
Kris Hoffman
Kris Hoffman le 14 Nov 2018
Commenté : Kris Hoffman le 16 Nov 2018
I'm trying to update the location of a polygon. As it is moved around an image it does a statistical calculation the output of which is then passed to a text box. All in a figure window (with uicontrols). I can't seem to nail down the syntax for 'addlistener' or 'listener' functions. To be honest, I don't know if it is possible via listeners as I get errors saying that listeners are not available for "images.roi.polygon". "Addlistener does not support vector of hg handles" OR "While adding a PostGet listener, property 'Position' in class 'images.roi.Polygon' is not defined to be GetObservable."
When I try to make change the Set/Get Observable property, it says it's read only. In the code below I realize that roipoly may seem redundant.
How to go about this? Thanks!
p = drawpolygon('LineWidth',2,'Color','cyan','Tag','Polygon');
addlistener(p,'Position','PostGet',@(src,ed)));
Bounds = round(p.Position);
ROI = roipoly(T2,Bounds(:,1),Bounds(:,2));

Réponse acceptée

Walter Roberson
Walter Roberson le 15 Nov 2018
The properties for that object that you can PostGet or PostSet on are
ALimInclude ApplicationData CLimInclude Copyable DefaultPropMap_Internal Description DimensionNames ErrorCallback HandleVisibility Internal NodeChildren NodeParent Parent Serializable SerializableApplicationData SerializableUserData Tag TransformForPrintFcn TransformForPrintFcnImplicitInvoke UserData Visible XLimInclude YLimInclude ZLimInclude
Perhaps you could instead
addlistener(p, 'ROIMoved', YourFunctionHandleHere)
  1 commentaire
Kris Hoffman
Kris Hoffman le 16 Nov 2018
Yes! Iwas going down a property/meta property rabbit hole looking for one that would work. Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by