function [cluster_labels,num_clusters,cluster1_num,cluster2_num] = get_cluster_labels(h1,h2)

num_samples=[size(h1,1),size(h2,1)];

for i=1:size(h1,1),
    [v,ind]=max(h1(i,:));
    cluster_labels(i,1) = ind;
end

for i=1:size(h2,1),
    [v,ind]=max(h2(i,:));
    cluster_labels(i+num_samples(1),1) = ind;
end

index=1;
vals=[];
for i=1:num_samples(1),
      if(length(vals) == 0 | length(find(vals(:,2) == cluster_labels(i,1))) == 0) 
        vals = [vals; index, cluster_labels(i,1),1];
        cluster_labels(i,1) = index;
        index=index+1;
      else
          [a,b]=find(vals(:,2) == cluster_labels(i,1));
          cluster_labels(i,1) = vals(a,1);
          vals(a,3) = vals(a,3)+1;

      end
end
num_clusters(1)=index-1;
cluster1_num=vals(:,3)';


index=1;
vals=[];
offset=num_samples(1);
for i=1:num_samples(2),
      if(length(vals) == 0 |  length(find(vals(:,2) == cluster_labels(i+offset,1))) == 0) 
        vals = [vals; index, cluster_labels(i+offset,1),1];
        cluster_labels(i+offset,1) = index;
        index=index+1;
      else
          [a,b]=find(vals(:,2) == cluster_labels(i+offset,1));
          cluster_labels(i+offset,1) = vals(a,1);
          vals(a,3) = vals(a,3)+1;
      end
end
num_clusters(2)=index-1;
cluster2_num=vals(:,3)';


