Not enough input arguments error(line 5).

4 visualizaciones (últimos 30 días)
Subham Chatterjee
Subham Chatterjee el 22 de Mzo. de 2018
Comentada: Jan el 18 de Abr. de 2018
When I'm writing the following code:
function pushbutton3_Callback(hObject, eventdata, handles)
[filename pathname] = uigetfile({'*.png';'*.ipg'},'File Selector');
image = strcat(pathname, filename);
img1=imread(image);
axes(handles.axes1);
figure, imshow(img1);
h = waitbar(0,'Image is processing, Please wait...');
steps = 1000;
for step = 1:steps
waitbar(step / steps)
end
I1=rgb2gray(img1);
str=strel('disk',10);
test2=imopen(I1,str);
level = graythresh(test2);
bw = im2bw(test2,level);
str=strel('disk',25);
test3=imopen(bw,str);
axes(handles.axes4);
imshow(test3)
%draw borders
B = bwboundaries(test3);
axes(handles.axes4);
imshow(test3)
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 0.2)
end
%Print count
[labeled,numObjects] = bwlabel(test3,4);
set(handles.lbl_tot_obj,'string', numObjects);
%Print file name and location
set(handles.edit1,'string',filename);
set(handles.edit2,'string', image);
close(h)
end
The following error pops up:
Not enough input arguments.
Error in color (line 5)
axes(handles.axes1);
I used this image file as input -
I just want to know if there's a problem with the axes or i messed up somewhere along the way. Thank you.
  1 comentario
Adam
Adam el 22 de Mzo. de 2018
Editada: Adam el 22 de Mzo. de 2018
Where has this function come from? It looks like part of a GUIDE file, but the fact the error message points to line 5 suggests it is just a standalone file. Then again it also seems to think the file is called 'color', which cannot be the case if this is the whole file.
It is possible to have a function like this in a standalone file (though doesn't make much sense), but you have to make sure you pass the 3 arguments in that it is expecting if you have detached it from a GUIDE file.

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 22 de Mzo. de 2018
Use the debugger to find the reason of the problem: https://www.mathworks.com/help/matlab/matlab_prog/debugging-process-and-features.html . Set a breakpoint in the failing line and run the code again. When Matlab stops, check the contents of handles. I guess that this 3rd argument was not provided, when this callback was called. If this is the case, the problem is not in the shown code, but in the definition of the callback. Where and how did you define it?
  2 comentarios
Subham Chatterjee
Subham Chatterjee el 17 de Abr. de 2018
I messed up with the function call. Although I'm still confused with the arguments in the function call and how to work it out. I hope I'll recover with it in due time. Anyways thanks for your suggestion. Here's the original file from where I read about the code but was unable to decipher it:
https://www.researchgate.net/publication/320925518_RICE_GRAIN_CLASSIFICATION_MATLAB_CODE
Here's the complete project log:
https://www.researchgate.net/project/RICE-GRAIN-CLASSIFICATION-BASED-ON-THE-IMAGE-PROCESSING-TECHNIQUES
Jan
Jan el 18 de Abr. de 2018
This file contains the code of the callbacks only. I suggest to contact the author as ask for the FIG file in addition. Or create your own GUI and insert the code of the callbacks to your project.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by