How to update polygon location in standard MATLAB script

3 次查看(过去 30 天)
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));

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by