How to update polygon location in standard MATLAB script

3 visualizaciones (últimos 30 días)
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));

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by