function [ parentout ] = makemapx(parent,k)
a=1;
b=3;
scoresmatrix=parent.score;
nrows=parent.cropmatrix(4)-parent.cropmatrix(2)+1;
[sobel_filt]=edge(rgb2gray(imfuse(reshape(scoresmatrix(:,a),nrows,[]),reshape(scoresmatrix(:,b),nrows,[]))),'sobel',[],'nothinning');
%sobel_filt=[];
xmatrix=scoresmatrix(:,[a b]);
tic;
[IDX,parentout.centroids,~,parentout.distances]=kmeans(xmatrix,k,'Maxiter',500,'emptyaction','drop','replicates',10,'Distance','sqeuclidean');
toc
clustmap=reshape(IDX,nrows,[]);
rIDX=mat2gray(clustmap);
scrsz = get(groot,'ScreenSize');
figure('Name','Classification Mapping','Position',[1 1 scrsz(3)*0.7 scrsz(4)]);
subplot(2,2,1:2);
imshow(rIDX);
colormap(jet);
str = sprintf('Class Map, Scores (%d:%d); k = %d',a,b,k);
title(str);
subplot(2,2,3),scatter(scoresmatrix(1:100:end,a),scoresmatrix(1:100:end,b),10,IDX(1:100:end),'filled');
xlim([-Inf Inf]); ylim([-Inf Inf]);
colormap(jet);
str = sprintf('Score %d',a);
xlabel(str);
str = sprintf('Score %d',b);
ylabel(str);
str = sprintf('Class Plot, Scores (%d:%d), k=%d',a,b,k);
title(str);
colorbar;
subplot(2,2,4), 
[sil,~]=silhouette(scoresmatrix(1:100:end,a:b),IDX(1:100:end),'sqeuclidean');
str = sprintf('Silhouette, Scores (%d:%d), k=%d',a,b,k);
title(str);
sil(isnan(sil))=[];
disp(sprintf('%f percent of Silhouette > 0, %f percent of Silhouette > 0.5, mean %f, entropy %f',100.*(size(sil(sil>0),1)./size(sil,1)),100.*(size(sil(sil>0.5),1)./size(sil,1)),mean(sil),entropy(sil)));

parentout.indices=IDX;
parentout.map=clustmap;
parentout.silhouette=sil;
parentout.sobelfilter=sobel_filt;
parentout.variables.score1=a;
parentout.variables.score2=b;
parentout.variables.k=k;
end