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

1 次查看(过去 30 天)
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?

采纳的回答

Image Analyst
Image Analyst 2013-1-28
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 个评论
Lester Lim
Lester Lim 2013-1-29
Thanks for the guidance, Im trying it now and might get back to you later.
Lester Lim
Lester Lim 2013-1-29
编辑:Lester Lim 2013-1-29
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);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by