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
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!