update image in GUI without GUIDE
古いコメントを表示
I am new to GUI without GUIDE, and I would appreciate any help in completing this function. I need it to get the value from the slider and show me the updated image.
function making_SliderForIm(ImCh1,BWCh1)
global I
global Imask
Imask=BWCh1;
I=ImCh1;
imshow(I,[]);
%create a slider
sld=uicontrol('Style', 'slider',...
'Min',1,'Max',50,'Value',41,...
'Position', [400 20 120 20],...
'Callback', @SliderVal);
function SliderVal(source,event)
val=ceil(source.Value);
% Display segmented image
BWsIbf = activecontour(I,Imask, 1+val, 'edge');
[B,L] = bwboundaries(BWsIbf,'noholes');
imshow(I,[]);%label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 2);
end
end
end
回答 (1 件)
Image Analyst
2017 年 3 月 31 日
Simply get the value:
currentSliderValue = sld.Value;
whenever you need to retrieve the current value of the slider.
It should be as simple as that.
11 件のコメント
Peyman Obeidy
2017 年 3 月 31 日
Image Analyst
2017 年 3 月 31 日
OK, good luck with that. Let us know if you need help with that. If you do, post your image(s) and updated code.
Peyman Obeidy
2017 年 4 月 2 日
編集済み: per isakson
2017 年 4 月 3 日
Image Analyst
2017 年 4 月 2 日
I don't know why you don't just use GUIDE. Why make it hard on yourself by trying to handle all of the tedious details yourself? If you want to do a bunch of extra work because you like pain, then you'll have to figure out how to pass the variables between your various functions. For that, see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Peyman Obeidy
2017 年 4 月 3 日
Image Analyst
2017 年 4 月 3 日
Peyman Obeidy
2017 年 4 月 3 日
Image Analyst
2017 年 4 月 3 日
Attach all needed m-files with the paper clip icon.
Peyman Obeidy
2017 年 4 月 3 日
Image Analyst
2017 年 4 月 3 日
Where did you attach them? Your code here: https://www.mathworks.com/matlabcentral/answers/332877-update-image-in-gui-without-guide#comment_442232 is not a complete program.
Peyman Obeidy
2017 年 4 月 3 日
カテゴリ
ヘルプ センター および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!