Slider using GUI in matlab (Image processing)
显示 更早的评论
Hi, I´ve got this program in Matlab. But I need to put it on a GUI to add other filters and stuff like that. I can´t make it work. Please help.
function GaussianSlider()
clear
clc
close all
handles.Image = imread('peppers.png');
handles.fig = figure;
handles.axes1 = axes('Units','pixels','Position',[50 100 400 400]);
handles.slider = uicontrol('Style','slider','Position',[50 50 400 20],'Min',3,'Max',15,'Value',3);
handles.Listener = addlistener(handles.slider,'Value','PostSet',@(s,e) gaussian_blur(handles));
imshow(handles.Image,'Parent',handles.axes1);
guidata(handles.fig);
function gaussian_blur(handles)
slider_value = round(get(handles.slider,'Value'));
h = fspecial('gaussian',slider_value,slider_value);
handles.Image=imfilter(handles.Image,h,'conv');
axes(handles.axes1);
imshow(handles.Image)
end
end
采纳的回答
更多回答(2 个)
Image Analyst
2015-10-12
0 个投票
Get rid of the "clear" line of code.
Image Analyst
2015-10-12
0 个投票
Jose, you don't need to add a listener. Simply put a call to the blurring function in your callback for your slider. Here is a good example framework to get you started with GUIDE: http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
