How to update polygon location in standard MATLAB script

조회 수: 4 (최근 30일)
Kris Hoffman
Kris Hoffman 2018년 11월 14일
댓글: Kris Hoffman 2018년 11월 16일
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개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by