Not enough input arguments error(line 5).
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam
2018-3-22
编辑:Adam
2018-3-22
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.
采纳的回答
Jan
2018-3-22
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 个评论
Jan
2018-4-18
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!