%% Kimia_simple % Introductory PR experiment on blob images. % It loads the images, computes features, creates scatterplot % and estimates the nearest neighbor classification error. % % and % should be in the path % % . % See http://37steps.com/prtools for more. %% Section 1 Check availablity of toolboxes % and should be in the path if exist('ldc', 'file') ~= 2, error('PRTools not in path'); end if exist('kimia_images','file') ~= 2, error('PRDataFiles not in path'); end delfigs; % delete all figures to avoid clutter %% Section 2 load datafile % Show all images, class sizes and class names A = kimia_images; % accept downloading again, neglect warnings, figure; show(A,12); classnames(A) %% Section 3 Select two classes % B = selclass(A,char('camel','elephant')); figure; show(B,6); %% Section 4 Compute features % Compute for every object its % - area (sum of pixels inside) % - perimeter (sum of pixels on the contour) feat1 = im_stat([],'sum'); feat2 = filtim('bwperim')*im_stat([],'sum'); C = B*[feat1 feat2]*datasetm; C = setfeatlab(C,{'Size','Perimenter'}); disp(+C); %% Section 5 Scatterplots % Show the original scatterplot, % after normalization on variance, % and with a classifier figure; scatterd(C,'legend'); axis equal; fontsize(14); % Some tricky statements to get non-matching NN labels [~,nn] = min(distm(C)+1e100*eye(size(C,1))); hold on; scatterd(C(labcmp(getlab(C),getlab(C(nn,:))),:),'ko'); fontsize(14); D = C*mapex(scalem,'variance'); figure; scatterd(D,'legend'); axis equal; fontsize(14); % Some tricky statements to get non-matching NN labels [~,nn] = min(distm(D)+1e100*eye(size(D,1))); hold on; scatterd(D(labcmp(getlab(D),getlab(D(nn,:))),:),'ko'); fontsize(14); figure; scatterd(D,'legend'); axis equal; fontsize(14); plotc(knnc(D,1),'col'); fontsize(14); %% Section 6 First classification % Compute the nearest neighbor errors for the two scatterplots fprintf('LOO NN error of original features %4.2f\n',testk(C,1)); fprintf('LOO NN error of rescaled features %4.2f\n',testk(D,1));