Info

此问题已关闭。 请重新打开它进行编辑或回答。

Problems with executing a .m file inside a push callback

1 次查看(过去 30 天)
i have a err1.m program ,as follows
y=imread('c:/5.png');
gg=rgb2gray(y);
r=0;
f=5;
news=25;
b=20;
for i=6:894
for j=6:1594
vp=gg(i,j);
q=mean2(gg(i-5:i+5,j-5:j+5));
s=std2(gg(i-5:i+5,j-5:j+5));
zp = (vp-q)/s;
if(s<news),
if(s<f),
r = (news*(s/f));
else
r = 50;
end
end
nmean= b+(q-0)*((255-30)-(0+30))/(255-0);
np(i,j)= nmean + zp*r;
if(np(i,j)<=0)
newvp=0;
elseif(np(i,j)>=255)
newvp=255;
else
np(i,j)=np(i,j);
end
disp('Exec');
j;
end
end
imshow(np)
where i read an input image , apply some algorithm over it and print the resultant image . My objective is to create a GUI for this program , i called the .m file using push button callback , i used this code
% --- Executes on button press in Execute. function Execute_Callback(hObject, eventdata, handles) % hObject handle to Execute (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
err1
to run the file and i got no output and the process does not seem to end, the err1.m program works fine on its own , but i get no results when i call the .m file inside a push button callback. I'm just a beginner in using matlab . please help me find a solution.

回答(1 个)

Suman Saha
Suman Saha 2013-8-7
function SCORE3(action)
if nargin<1
action='initialize';
end;
if strcmp(action,'initialize')
close all;clc;
figNumber=figure('Name','S C O R E ','NumberTitle','off','Units','inches','Position',[1 0.5 9 7],'Resize','on','MenuBar','none');
colordef(figNumber,'black')
xpos=5.6; ypos=4.6; xw=1.5; yw=0.2;
%%%-------------------------------------------------
%----Initialize button------%%
initialization=uicontrol('Style','push','FontName','Times new roman','FontWeight','bold',... 'FontSize',12,'HorizontalAlignment','center','Units','inches','String','Initialize','BackgroundColor',[0.2071 0.6072 0.6299],'Callback','SCORE3(''initialize'')','Position',[xpos 0.6 1.4 0.3]);
%%----THE CLOSE BUTTON-----%
closee=uicontrol('Style','push','Units','inches','Position',[xpos 0.2 1.4 0.3],'String','C L O S E','FontName','monotype corsiva', ... 'ForegroundColor','black','BackgroundColor','red','FontWeight','bold','FontSize',15,'Callback','close(gcf)');
photo=uicontrol('Style','push','Units','inches','Tag','photo','Position',[5.3 2.1 1 0.3],'String','Upload Photo','Callback','SCORE3(''build'')', ... 'ForegroundColor',[0 1 1],'FontWeight','bold','Fontname','palatino','HorizontalAlignment','left','BackgroundColor',[0 0 0.3],'FontSize',10);
sig=uicontrol('Style','push','Units','inches','Tag','sig','Position',[5.3 1.7 1 0.3],'String','Upload sig','Callback','SCORE3(''build'')', ... 'ForegroundColor',[0 1 1],'FontWeight','bold','Fontname','palatino','HorizontalAlignment','left','BackgroundColor',[0 0 0.3],'FontSize',10);
%==========================================================================
set(figNumber,'Visible','on');
%============================================
elseif strcmp(action,'build')
if get(findobj(gcf,'Tag','photo'),'Value')
axes('Units','inches','Position',[6.7 2.0 1 1],'Visible','on');
axis off;
kl=photoup;
values=cell2mat(struct2cell(kl)); %now you can use it as for your requirement
image(values);
axis off;clc
end
%%%% It may not be necessary
if get(findobj(gcf,'Tag','sig'),'Value')
axes('Units','inches','Position',[6.6 1.8 1.2 0.2],'Visible','on');
axis off;
kl1=photoup;
image(cell2mat(struct2cell(kl1)));
axis off;
end
%%%%%----------------------
end
function kl=photoup()
kl=uiimport('-file'); % this function helps you to brows any picture of any

Community Treasure Hunt

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

Start Hunting!

Translated by