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

1 回表示 (過去 30 日間)
William
William 2014 年 5 月 8 日
コメント済み: William 2014 年 5 月 9 日
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
  1 件のコメント
William
William 2014 年 5 月 9 日
Indeed that does work! First time too!
Thank you for your input :D

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by