Not enough input arguments error(line 5).
4 views (last 30 days)
Show older comments
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 Comment
Adam
on 22 Mar 2018
Edited: Adam
on 22 Mar 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.
Accepted Answer
Jan
on 22 Mar 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 Comments
Jan
on 18 Apr 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.
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!