De Boundary

download De Boundary

If you can't read please download the document

description

it representation classification of different classes using cluster based method. In this approach, we also shows boundary.

Transcript of De Boundary

function[out]=DE_boundary(Class1,Class2,Class3);training = cell(3,1);training{1} = Class1;training{2} = Class2;training{3} = Class3;sample_means = cell(length(training),1);for i=1:length(training),sample_means{i} = mean(training{i});endClass=[Class1;Class2;Class3];am=min(Class);bm=max(Class);xrange = [ceil(am(1))-1,ceil(bm(1))+1];yrange = [ceil(am(2))-1, ceil(bm(2))+1];inc = 0.1;[x, y] = meshgrid(xrange(1):inc:xrange(2), yrange(1):inc:yrange(2));image_size = size(x);xy = [x(:) y(:)];xy = [reshape(x, image_size(1)*image_size(2),1) reshape(y, image_size(1)*image_size(2),1)];numxypairs = length(xy); dist = [];for i=1:length(training), disttemp = sum(abs(xy - repmat(sample_means{i}, [numxypairs 1])), 2);dist = [dist disttemp];end[m,idx] = min(dist, [], 2);decisionmap = reshape(idx, image_size);imagesc(xrange,yrange,decisionmap);hold on;set(gca,'ydir','normal');% colormap for the classes:% class 1 = light red, 2 = light green, 3 = light bluecmap = [1 0.8 0.8; 0.95 1 0.95; 0.9 0.9 1];colormap(cmap);% plot the class training data.plot(training{1}(:,1),training{1}(:,2), 'r.');plot(training{2}(:,1),training{2}(:,2), 'go');plot(training{3}(:,1),training{3}(:,2), 'b*');% include legendlegend('Class 1', 'Class 2', 'Class 3','Location','NorthOutside', ...'Orientation', 'horizontal');% label the axes.xlabel('x');ylabel('y');decisionmap = reshape(idx, image_size);figure;%show the imageimagesc(xrange,yrange,decisionmap);hold on;set(gca,'ydir','normal');% colormap for the classes:% class 1 = light red, 2 = light green, 3 = light bluecmap = [1 0.8 0.8; 0.95 1 0.95; 0.9 0.9 1];colormap(cmap);% plot the class training data.plot(training{1}(:,1),training{1}(:,2), 'r.');plot(training{2}(:,1),training{2}(:,2), 'go');plot(training{3}(:,1),training{3}(:,2), 'b*');% include legendlegend('Class 1', 'Class 2', 'Class 3','Location','NorthOutside', ...'Orientation', 'horizontal');% label the axes.xlabel('x');ylabel('y');end