我有一个对图像进行分类的代码。
training1 = xlsread('Data Train');
% mentions the location of the training data matrix in the excel file
training = [training1(:,1) training1(:,2) training1(:,3) training1(:,4) training1(:,5) training1(:,6) training1(:,7) training1(:,8) training1(:,9) training1(:,10) training1(:,11) training1(:,12) training1(:,13) training1(:,14) training1(:,15) training1(:,16) training1(:,17) training1(:,18) training1(:,19) training1(:,20) training1(:,21) training1(:,22) training1(:,23) training1(:,24)];
% mentions input data variables
Z=[MeanR MeanG MeanB MeanH MeanS MeanV VarRed VarGreen VarBlue VarH VarS VarV RangeR RangeG RangeB RangeH RangeS RangeV sdR sdG sdB sdH sdS sdV];
%perform knn classification
result = knnsearch(training,Z);
if (result>=1 && result<=20)
set(handles.EditBox,'string','Raw');
elseif (result>=21 && result<=40)
set(handles.EditBox,'string','Undercook');
elseif (result>=41 && result<=60)
set(handles.EditBox,'string','Cook');
elseif (result>=61 && result<=80)
set(handles.EditBox,'string','Rotten');
end
knnsearch
语法是否仅默认k值为1?
怎样才能让
knnsearch
中的k值为5?
当我尝试将其更改为
k = 5;
result = knnsearch(training,Z,'K',k);
系统不显示分类结果。