How can I remove the below mentioned error?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
"??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> gui_mainfcn"
the above quoted error I am getting when I run the code below (code refered, is from "DEEPTHI's Question asked on 24 Jan 2013)
function varargout = main(varargin)
% MAIN M-file for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help main
% Last Modified by GUIDE v2.5 18-Jan-2013 20:29:55
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before main is made visible.
function main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in loadImage.
function loadImage_Callback(hObject, eventdata, handles)
% hObject handle to loadImage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif';'*.*';},'pick an image file');
S=imread([pathname,filename]);
axes(handles.axes1);
imshow(S);
handles.S=S;
handles.a=[pathname,filename];
guidata(hObject,handles);
% --- Executes on button press in colorSearch.
function colorSearch_Callback(hObject, eventdata, handles)
% hObject handle to colorSearch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I=handles.a;
A=imread(I);
[X,map]=rgb2ind(A,256);
[handles.queryx,handles.querymap]=imread(I);
cd('C:\images');
fid=fopen('base.txt');
resultValues=[];
resultNames={};
i=1;
j=1;
while 1
imagename=fgetl(fid);
if ~ischar(imagename),break,end
disp(imagename);
Z=imread(imagename);
[Y,map1]=rgb2ind(Z,256);
D=quadratic(X,map,Y,map1);
resultValues(i)=D;
resultNames(j)={imagename};
i=i+1;
j=j+1;
end
fclose(fid);
[sortedValues,index]=sort(resultValues);
cd('C:\results');
fid=fopen('colorResults.txt','w+');
for i=1:10
tempstr=char(resultNames(index(i)));
fprintf(fid,'%s\r',tempstr);
disp(resultNames(index(i)));
disp(sortedValues(i));
disp('');
end
fclose(fid);
disp('color parts done');
displayResults('colorResults.txt','Color Results..');
cd('c:/results');
% --- Executes on button press in textureSearch.
function textureSearch_Callback(hObject, eventdata, handles)
% hObject handle to textureSearch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I=handles.a;
A=imread(I);
[handles.queryx,handles.querymap]=imread(I);
querymap=rgb2hsv(A);
cd('C:\images');
fid=fopen('base.txt');
queryEnergies=obtainEnergies(handles.queryx,6);
fresultValues=[];
fresultNames={};
i=1;
j=1;
while 1
imagename=fgetl(fid);
if ~ischar(imagename),break,end
X=imread(imagename);
imageEnergies=obtainEnergies(X,6);
E=euclideanDistance(queryEnergies,imageEnergies);
fresultValues(i)=E;
fresultNames(j)={imagename};
i=i+1;
j=j+1;
end
fclose(fid);
disp('Texture results obtained');
[sortedValues,index]=sort(fresultValues);
cd('C:\results');
fid=fopen('textureResults.txt','w+');
for i=1:10
imagename=char(fresultNames(index(i)));
fprintf(fid,'%s\r',imagename);
disp(imagename);
disp(sortedValues(i));
disp('');
end
fclose(fid);
disp('Texture parts done');
disp('Texture results saved...');
disp('');
displayResults('textureResults.txt','Texture Results');
cd('C:\results');
% --- Executes on button press in shapeSearch.
function shapeSearch_Callback(hObject, eventdata, handles)
% hObject handle to shapeSearch (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I=handles.a;
A=imread(I);
B=shape(A);
cd('C:\images');
fid=fopen('base.txt');
sresultValues=[];
sresultNames={};
i=1;
j=1;
while 1
imagename=fgetl(fid);
if ~ischar(imagename),break,end
K=imread(imagename);
result=shape(K);
if strcmp(result,'Square')
result='Square';
end
if strcmp(result,'Round')
result='Round';
end
if strcmp(result,'Triangle')
result='Triangle';
end
C=strcmp(B,result)
if C>0
sresultValues(i)=C;
sresultNames(j)={imagename};
i=i+1;
j=j+1;
end
end
disp('Shape results obtained');
fclose(fid);
cd('c:/results');
fid=fopen('shapeResults.txt','w+');
[sortedValues,index]=sort(sresultValues);
for i=1:10
imagename=char(sresultNames(index(i)));
fprintf(fid,'%s\r',imagename);
end
disp(imagename);
disp(sortedValues(i));
disp('');
fclose(fid);
disp('Shape parts done');
disp('Shape results saved...');
disp('');
displayResults('shapeResults.txt','Shape Results...');
cd('C:\results');
function value=quadratic(X1,map1,X2,map2)
[count1,y1]=imhist(X1,map1);
[count2,y2]=imhist(X2,map2);
q=count1-count2;
s=abs(q);
A=similarityMatrix(map1,map2);
d=s.'*A*s;
d=d^1/2;
d=d/1e8;
value=d;
function value=obtainEnergies(iMatrix,n)
dm=iMatrix;
energies=[];
i=1;
for j=1:5
[tl,tr,bl,br]=decompose(dm);
energies(i)=energyLevel(tl);
energies(i+1)=energyLevel(tr);
energies(i+2)=energyLevel(bl);
energies(i+3)=energyLevel(br);
i=i+4;
dm=tl;
end
sorted=-sort(-energies);
value=sorted(1:n);
function[Tl,Tr,Bl,Br]=decompose(imMatrix)
[A,B,C,D]=dwt2(imMatrix,'db1');
Tl=wcodemat(A);
Tr=wcodemat(B);
Bl=wcodemat(C);
Br=wcodemat(D);
function value=energyLevel(aMatrix)
[r,c]=size(aMatrix);
value=sum(sum(abs(aMatrix)))/(r*c);
function value=euclideanDistance(X,Y)
[r,c]=size(X);
e=[];
for i=1:c
e(i)=(X(i)-Y(i))^2;
end
Euclid=sqrt(sum(e));
value=Euclid;
function value=similarityMatrix(I,J)
[r,c]=size(I);
A=[];
for i=1:r
for j=1:r
M1=(I(i,2)*sin(I(i,1))-J(j,2)*sin(J(j,1)))^2;
M2=(I(i,2)*cos(I(i,1))-J(j,2)*cos(J(j,1)))^2;
M3=(I(i,3)-J(j,3))^2;
M0=sqrt(M1+M2+M3);
A(i,j)=1-(M0/sqrt(5));
end
end
value=A;
function result=shape(S)
S=im2bw(S);
[H,theta,rho]=hough(S);
datas=[];
for cnt=1:max(max(H))
datas(cnt)=sum(sum(H==cnt));
end
datas(datas==0)=NaN;
[maxval,maxind]=max(datas);
medval=median(datas);
[p]=polyfit(1:maxind-5,datas(1:maxind-5),2);
if maxval<3*medval
result='Triangle';
elseif p(3)>100
result='square';
else
result='Round';
end
function displayResults(filename,header)
figure('Position',[200 100 700 400],'MenuBar','none','Name',header,'Resize','off','NumberTitle','off');
fid=fopen(filename);
i=1;
while 1
imagename=fgetl(fid);
if ~ischar(imagename),break,end
x=imread(imagename);
subplot(2,5,i);
subimage(x);
xlabel(imagename);
i=i+1;
end
fclose(fid);
2 Commenti
Walter Roberson
il 22 Gen 2017
The reference appears to be to https://www.mathworks.com/matlabcentral/answers/59720-plz-solve-cbir-implementation
Walter Roberson
il 22 Gen 2017
I do not think it is useful to try to debug a known-broken program from 4 years ago that is missing its .fig file, especially since whatever .fig file was created might be responsible for the error.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!