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

1 Ansicht (letzte 30 Tage)
Lester Lim
Lester Lim am 28 Jan. 2013
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?

Akzeptierte Antwort

Image Analyst
Image Analyst am 28 Jan. 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 Kommentare
Lester Lim
Lester Lim am 29 Jan. 2013
Thanks for the guidance, Im trying it now and might get back to you later.
Lester Lim
Lester Lim am 29 Jan. 2013
Bearbeitet: Lester Lim am 29 Jan. 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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by