필터 지우기
필터 지우기

Change imellipse position when the string in edit-text uicontrol is updated.

조회 수: 4 (최근 30일)
Hi All,
I rather have a strange requirement. I display an image in an axes of a GUI figure created using GUIDE. I use imellipse to select a circle in the image. Although imellipse allows me to resize it by dragging the boundaries, I also want to resize it based on the vector entered in the uicontrol edit-text.
Essentially, when imellipse is run, a popup window with edit-text uicontrol is created with some initial position vector of the ellipse. I want to change the position vector in the edit-text which gets reflected in the position of ellipse in the image and also that the resizing of imellipse updates the vector in edit-text.
I was able to do the latter part using the following lines of code (under a function called crop) -
EllipseHandle = imellipse(gca,[0.25*width 0.25*height 0.5*width 0.5*height]);
addNewPositionCallback(EllipseHandle,@(p) set(handles.CroppingVector,'String',num2str(p,3)));
CroppingVector is the tag for the edit-text uicontrol.
Now, I want to update the position of the ellipse when the vector in edit-text is changed. I am able to read the updated vector in the callback function for edit-text which looks like this:
function CroppingVector_Callback(hObject, eventdata, handles)
% hObject handle to CroppingVector (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Pos = str2num(get(handles.CroppingVector,'String'));
However, I am having difficulty trying to understand how to update the ellipse position. I tried using (immediately after above line of code in the callback function for edit-text)
setConstrainedPosition(EllipseHandle,Pos);
But I get the following error
Undefined function 'setConstrainedPosition' for input arguments of type 'double'.
Obviously, EllipseHandle is not recognized. Can anyone please suggest a working solution to my problem?
-- Thanks, Ram.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by