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

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Justin
Justin am 8 Mai 2014
Bearbeitet: Justin am 8 Mai 2014
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

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by