colors=15;
labbins=218;
dims=5;

fidbins=fopen('sketch_color_bin_nums.txt','r');
fidscores=fopen('sketch_color_bin_scores.txt','r');
fidproj=fopen('sketch_color_bin_nums_projected.txt','w');

load necessary218.mat

fprintf(fidproj, '%i\n', dims);
bins1=fscanf(fidbins,'%i',1);
bins2=fscanf(fidscores,'%i',1);

if bins1 ~= bins2
   error('bins1 ~= bins2')
end

for i=1:colors
   hist1=zeros(labbins,1);
   fprintf(1,'\n\n%i\n',i);
   for j=1:bins1
      bin=fscanf(fidbins,'%i',1);
      score=fscanf(fidscores,'%f',1);
      fprintf(1,'\t%i, %.3f\n', bin, score);
      if bin>0
	 hist1(bin)=score;
      end
   end
   hist2=U25*hist1(1:labbins-1);
   fprintf(fidproj, '%.3f\t', hist2(1:5));
   fprintf(fidproj, '\n');
end

fclose(fidbins);
fclose(fidscores);
fclose(fidproj);
