How does a trained classifier label a picture by its own?

1 visualización (últimos 30 días)
How does a trained classifier label a picture by its own? Let's say I have a training set, train it using the LDA classifier and it shows me the accuracy/similarities. How do I use this to apply on the picture I want to label?

Respuesta aceptada

Image Analyst
Image Analyst el 28 de En. de 2013
You have to do that in separate steps afterwards. Your classifier should give you some kinds of instructions for classifying pixels, for example, pixels darker than 130 are background, and pixels brighter than 130 are foreground.
  8 comentarios
Lester Lim
Lester Lim el 29 de En. de 2013
Thanks for the guidance, Im trying it now and might get back to you later.
Lester Lim
Lester Lim el 29 de En. de 2013
Editada: Lester Lim el 29 de En. de 2013
Yup, calculated it to be 100+ GB. Pardon for being a newbie at this, but by running separately, do you mean this? Or should I put in as another GUI button?
data = importdata('Trial data4.mat');
features=data(:,1:end-1); %split data without labels
lable=data(:,end); %get the labels
trainSamples = im2double(features);%training samples
trainClasses = im2double(lable);%training labels
testSamples = im2double(features);%test samples
lableimage = reshape(handles.lableimage,[],1);
testClasses = im2double(handles.lableimage);%test labels
disp('GUI: trainSamples is')
class(trainSamples)
disp('GUI: testSamples is')
class(testSamples)
mLDA = LDA(trainSamples, trainClasses');
mLDA.Compute();
clear data
transformedTrainSamples = mLDA.Transform(trainSamples, 1);
transformedTestSamples = mLDA.Transform(testSamples, 1);
calculatedClasses = knnclassify(transformedTestSamples, transformedTrainSamples, trainClasses);
simmilarity = [];
for i = 1 : 1 : length(testClasses)
similarity(i) = (testClasses(i)==calculatedClasses(i));
end
accuracy = sum(similarity) / length(testClasses);
fprintf('Testing: Accuracy is: %f %%\n', accuracy*100);
data = importdata('Trial data5.mat');
features=data(:,1:end-1); %split data without labels
lable=data(:,end); %get the labels
trainSamples = im2double(features);%training samples
trainClasses = im2double(lable);%training labels
testSamples = im2double(features);%test samples
lableimage = reshape(handles.lableimage,[],1);
testClasses = im2double(handles.lableimage);%test labels
disp('GUI: trainSamples is')
class(trainSamples)
disp('GUI: testSamples is')
class(testSamples)
mLDA = LDA(trainSamples, trainClasses');
mLDA.Compute();
clear data
transformedTrainSamples = mLDA.Transform(trainSamples, 1);
transformedTestSamples = mLDA.Transform(testSamples, 1);
calculatedClasses = knnclassify(transformedTestSamples, transformedTrainSamples, trainClasses);
simmilarity = [];
for i = 1 : 1 : length(testClasses)
similarity(i) = (testClasses(i)==calculatedClasses(i));
end
accuracy = sum(similarity) / length(testClasses);
fprintf('Testing: Accuracy is: %f %%\n', accuracy*100);
guidata(hObject, handles);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Classification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by