Hello guys, I want to ask about slider in GUI. How do I use the slider for increment level value to thresholding grayscale image and then show it in the axes box? I hope you guys understand,please help me.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Jul. 2016

1 Stimme

First set up the min and max properties, like 0 and 255, either in GUIDE or in your code. Then, when you need to use its value, get the slider value from any callback like this:
sliderValue = handles.slider1.Value;
Then use it to binarize an image like
binaryImage = grayImage > sliderValue;
imshow(binaryImage);
or however you want to use it.

6 Kommentare

Varian Adisuryo
Varian Adisuryo am 25 Jul. 2016
Thank you so much for your kind help. I will try to make it. Thank you so much
Varian Adisuryo
Varian Adisuryo am 28 Jul. 2016
Hi Mr. Image Analyst, I've done it like you said and combine from your answer from another question in this forum but when I run it, the the result in the axes is just blank white whenever I move the slider. I'm a beginner at this so would you please to correct my script?
a=getappdata(0,'a');
a_gray=rgb2gray(a);
thresholdValue = uint8(get(handles.slider1, 'Value'));
sliderValue = get(handles.slider1, 'Value');
a_bw=im2bw(a_gray,thresholdValue);
axes(handles.axes2);
imshow(a_bw)
I'm very sorry if my script is confusing for you. please help
Adam
Adam am 28 Jul. 2016
Did you set the slider max to 255?
Varian Adisuryo
Varian Adisuryo am 28 Jul. 2016
wow thank you so much Mr. Adam, thank you so much. I changed the slider max to 255 and it works!! Thank you so much :)
Bram Mast
Bram Mast am 12 Jun. 2018
Hi Varian
How did you finally implement this ?
Image Analyst
Image Analyst am 12 Jun. 2018
I imagine he used my code. But you might switch now to App Designer instead of GUIDE as that's their new way forward.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by