function [] = labcombinec( tri_bil,IDX,centermatrix,distancematrix,cluster1,threshold1,cluster2,threshold2 )
%Replots the scores plot and map for a single cluster. You must specify the
%scores matrix, the two scores, the index matrix, centroid matrix, distance
%matrix, the cluster of interest and the threshold squared distance.
%
%If the threshold is greater than the maximum sq distance, this reports the
%maximum sq distance. NB this uses the global nrows variable as input to
%reshape the image, ergo this only works with the latest scores matrix
%generated this session.
%
%OUTPUTS: none
global nrows
global Message
dlab=tri_bil(:,:,4);
IDX1=(IDX == cluster1).*distancematrix(:,cluster1);
IDX2=(IDX == cluster2).*distancematrix(:,cluster2);
IDX1t= IDX1 > 0 & IDX1 < threshold1;
IDX2t= IDX2 > 0 & IDX2 < threshold2;
rIDX1t=reshape(IDX1t,nrows,[]);
rIDX2t=reshape(IDX2t,nrows,[]);
rIDX12=rIDX1t+rIDX2t;
rIDX12=mat2gray(rIDX12);
imshow(rIDX12)
str = sprintf('Map of Clusters %d+%d, Threshold %f,%f',cluster1,cluster2,threshold1,threshold2);
title(str)
IDX1tp(:,1)=IDX1t.*dlab(:,2);
IDX1tp(:,2)=IDX1t.*dlab(:,3);
IDX1tp(IDX1tp == 0)=NaN;
IDX2tp(:,1)=IDX2t.*dlab(:,2);
IDX2tp(:,2)=IDX2t.*dlab(:,3);
IDX2tp(IDX2tp == 0)=NaN;
figure
scatter(IDX1tp(:,1),IDX1tp(:,2),1)
hold on
scatter(centermatrix(cluster1,1),centermatrix(cluster1,2),36,[1 0 0])
scatter(IDX2tp(:,1),IDX2tp(:,2),1)
scatter(centermatrix(cluster2,1),centermatrix(cluster2,2),36,[1 0 0])
hold off
xlabel('a*');
ylabel('b*');
str = sprintf('Distance-Thresholded a*b* Clusters, Clusters (%d,%d), Thr=%f,%f',cluster1,cluster2,threshold1,threshold2);
title(str);
end

