How to show its results

2 visualizzazioni (ultimi 30 giorni)
shafaq nisar
shafaq nisar il 4 Giu 2017
Commentato: KSSV il 5 Giu 2017
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
  1 Commento
KSSV
KSSV il 5 Giu 2017
You have not given input properly....I suspect...

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by