Slider Event Listener Creates a new figure instead of updating Existing figure.

조회 수: 1 (최근 30일)
Hellooo Fellow Matlabbers
I'm having a bit of trouble with a GUI I'm putting together, basically I have a slider which I'm using to vary the contrast of the image I'm viewing.
The image itself is in an axis figure, and for the last few months I've been using the slider Callback to get the image to update with its new contrast value, but as you know the image only updates once you've let go of the mouse. Now I want the image to continuously update as I move the slider. I've done this with an event listener like so:
addlistener(handles.dispmaxslider,'ContinuousValueChange',@(hobject, event) maxSliderChanged(hObject, event, handles));
And within maxSliderChanged all I do is set the current axes to those within my GUI and update the image with the new values with a call to
imshow(image, [min max]);
Where min and max are defined by my sliders. Now the trouble arises when I use the slider, instead of updating my axes, which I've safe guarded with a call to
axes(currentAxes)
This ensures that after every update, the updated image is displayed in the correct place. But now a new figure is created when I move the slider and that image is now updated after every cal, it's as if I never had that call to the axes() method. I suspect that there's something in my addListener function that I can use to prevent this, however the solution eludes me. Any thoughts?
Will

채택된 답변

Justin
Justin 2014년 5월 8일
편집: Justin 2014년 5월 8일
Hello :)
I don't have the image processing toolbox but I believe imshow will work similar to some other functions. You should be able to designate the parent axes in the function when you call it so instead of:
imshow(image, [min max]);
use
imshow(image, [min max]), 'Parent', handles.AxesHandleName);
Let me know if that works.
Edit: maybe: 'Parent', gca); will be fine also

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by