要求对一幅水面图像用SVM实现分类,检测出水天线
下面的实现中用到steven gunn编写的纯matlab版svm工具箱
close all;
f = imread('水天线原图.jpg');
imshow(f);
title('鼠标左键点天空,鼠标中键点陆地,鼠标右键点水,Enter完成输入');
[x,y,button] = ginput; %读取鼠标点击坐标值和类型
% trNum1 = size ?怎样分别统计天空陆地和水面的训练样本个数
[trNum, n] = size(x); % 统计训练样本个数
[row, colum, value] = size(f);
% fR = f(:,:,1);
% fG = f(:,:,2);
% fB = f(:,:,3);
trX = zeros(trNum,3); %训练向量初始化
trY = zeros(trNum); %训练类别初始化
figure,
subplot(1,2,1);
title('训练样本分布');
hold on
for i=1:trNum;
trX(i,:) = [f(round(y(i)),round(x(i)),1),f(round(y(i)),round(x(i)),2),f(round(y(i)),round(x(i)),3)]