How to update polygon location in standard MATLAB script

2 Ansichten (letzte 30 Tage)
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));

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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 Kommentar
Kris Hoffman
Kris Hoffman am 16 Nov. 2018
Yes! Iwas going down a property/meta property rabbit hole looking for one that would work. Thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by