guys iam getting "not enough input argument" error...plz help me out in this program of color image segmentation....or if any one has a code for that give me... ihave tried it on 10-12 algos(giving same error)..i needed it badly ...for my project..i

1 view (last 30 days)
%Parameters
% inImg - Input Color Image
% nBins - No. of Bins for coarse representation
% winSize - Window size for histogram processing
% nClass - No. of classes
% outImg - Output Segmented Image
function outImg = colImgSeg(inImg, nBins, winSize, nClass)
s = size(inImg);
NbParam = nBins * nBins * nBins;
divis = 256 / nBins ;
s=size(inImg);
N=winSize;
n=(N-1)/2;
r=s(1)+2*n;
c=s(2)+2*n;
double temp(r,c,3);
temp=zeros(r,c,3);
out=zeros(r,c,3);
coarseImg = zeros(r,c);
TabLabel = zeros(1,NbParam);
inrImg = rgb2gray(inImg);
temp((n+1):(end-n),(n+1):(end-n),1)=inImg(:,:,1);
temp((n+1):(end-n),(n+1):(end-n),2)=inImg(:,:,2);
temp((n+1):(end-n),(n+1):(end-n),3)=inImg(:,:,3);
temp_color = temp;
for x=n+1:s(1)+n
for y=n+1:s(2)+n
e=1;
for k=x-n:x+n
f=1;
for l=y-n:y+n
mat(e,f,1)=temp(k,l,1);
mat(e,f,2)=temp(k,l,2);
mat(e,f,3)=temp(k,l,3);
f=f+1;
end
e=e+1;
end
sum_lab = 0;
for i = 1 : winSize
for j = 1 : winSize
lab = floor(mat(i,j,1)/divis)*(nBins*nBins);
lab = lab + floor(mat(i,j,2)/divis)*(nBins);
lab = lab + floor(mat(i,j,3)/divis);
lab = lab + 1;
TabLabel(lab) = TabLabel(lab) + 1;
sum_lab = sum_lab + lab;
end
end
coarseImg(x,y) = floor(sum_lab / (winSize * winSize));
end
end
trunCoarseImg(:,:) = coarseImg((n+1):(end-n),(n+1):(end-n));
tempVar = trunCoarseImg(:,:);
inImg_1D = double(tempVar(:));
fusedMap = kmeans(inImg_1D,nClass, 'EmptyAction', 'singleton');
fusedMapShow = uint8(fusedMap.*(255/nClass));
outImg = reshape(fusedMapShow,s(1),s(2));
  3 Comments
rachit tomar
rachit tomar on 4 May 2015
Edited: Walter Roberson on 4 May 2015
as u see i have placed 4 arguments in the main function outlmg
function outImg = colImgSeg(inImg, nBins, winSize, nClass)
the error displayed is:
"collmgseg" needs more input arguments
then showing cursor at the function arguments and saying " enter input values by tying them now , then press enter to save them. the values you enter will be set as the default values ."
now help me what to do.. it is giving error in the collmgseg function.
Walter Roberson
Walter Roberson on 4 May 2015
Show us the code you use to call this function, or show us the command line you are using to invoke the function. Are you trying to run the function by pressing F12 or using the menu item to run the code when the function is on the screen? That would not work: you need to invoke the function from the command line or from other code.

Sign in to comment.

Answers (1)

Jan
Jan on 4 May 2015
Edited: Jan on 4 May 2015
  1. Please format your code properly - see the "{} Code" button.
  2. Post the complete error message and explain, which line is failing. Letting the readers search this line is a waste of their time, because you have the required information on your screen.
  3. Did you search for "not enough input arguments" in this forum? The solution is always the same: A command is called with too few arguments. The the failing function is "colImgSeg", then please post how you call it. Did you provide 4 arguments?
  4. Post the relevant part of the code only. Would you read so many lines and invest so much time to find out, which line is failing?
  2 Comments
rachit tomar
rachit tomar on 4 May 2015
Edited: Walter Roberson on 4 May 2015
as u see i have placed 4 arguments in the main function outlmg
function outImg = colImgSeg(inImg, nBins, winSize, nClass)
the error displayed is:
"collmgseg" needs more input arguments
then showing cursor at the function arguments and saying " enter input values by tying them now , then press enter to save them. the values you enter will be set as the default values ."
now help me what to do.. it is giving error in the collmgseg function.
Image Analyst
Image Analyst on 4 May 2015
There is a difference between colImgSeg and collmgseg
And like Walter said, you can't simply click the green run triangle or type F5 to run this code. You have to call the function and supply arguments.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!