Frage

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

War es hilfreich?

Lösung

Just cracked it, if anyone is interested, I made a simple change to the imshow() method to force it to update that particular UI element. Like so:

axes(currentAxes);
imshow(image, [min max]);

becomes:

imshow(image, [min max], 'Parent', axisHandle);

This way the correct image panel will now update continuously in response to the slider being changed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top