You have not given input properly....I suspect...
How to show its results
1 次查看(过去 30 天)
显示 更早的评论
I have downloaded this code from internet. It gives (Error using svmtrain (line 259) TRAINING and Y must both contain at least one row with no missing values.
Error in svm_test (line 41) SVMStruct = svmtrain(arrayImage, class);) How to remove this error?
I want to show result in the form of image, how to do this? (it did not show any output)
clear all;
clc;
folder = 'RandomNoisrData';
dirImage = dir( folder );
numData = size(dirImage,1);
M ={} ;
%Read image data
for i=1:numData
nama = dirImage(i).name;
if regexp(nama, '(DNoise|RNoise)-[0-2]{1,2}.jpg')
B = cell(1,2);
if regexp(nama, 'Noise-[0-2]{1,2}.jpg')
B{1,1} = double(imread([folder, '/', nama]));
B{1,2} = 1;
elseif regexp(nama, 'VNoise-[0-2]{1,2}.jpg')
B{1,1} = double(imread([folder, '/', nama]));
B{1,2} = -1;
end
M = cat(1,M,B);
end
end
% Image conversion for SVM purposes
numDataTrain = size(M,1);
class = zeros(numDataTrain,1);
arrayImage = zeros(numDataTrain, 300 * 300);
for i=1:numDataTrain
im = M{i,1} ;
im = rgb2gray(im);
im = imresize(im, [300 300]);
im = reshape(im', 1, 300*300);
arrayImage(i,:) = im;
class(i) = M{i,2};
end
SVMStruct = svmtrain(arrayImage, class);
% Test for Random Noise
lionTest = double(imread('RandomNoiseData/TestImage3.jpg' ));
lionTest = rgb2gray(lionTest);
lionTest = imresize(lionTest, [300 300]);
lionTest = reshape(lionTest',1, 300*300);
result = svmclassify(SVMStruct, lionTest);
result;
Please help
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biotech and Pharmaceutical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!