function test2
% Generate a table of edge pair likelihoods and distance
% priors.
%
% Copyright (C) 2001-2009 Center for Perceptual Systems

% Read histogram
fn='kodak_counts_16_8_72_72.txt';
[same,diff]=readhist(fn,16,72,72);

% Get distance dependent priors
b=beta(same,diff);

% Create a table of distance dependent likelihoods
l=ddl(same,diff);

% Write them out to a file
fn='kodak_table.txt';
fprintf('Writing %s\n',fn);
fid=fopen(fn,'w');
assert(fid~=-1,'Cannot open file for writing');

% Get number of degrees per bin
dpb=360/72;

% Generate bin numbers
[thdbin,phibin,dbin]=ind2sub([72,72,16],1:16*72*72);

% Get a linear index from bin numbers
ind=getindex(dbin,phibin,thdbin,16,72);

% Write them out to a table
fprintf(fid,'d\tphi\tthd\tL\tbeta\n');
fprintf(fid,'%d\t%d\t%d\t%f\t%f\n',[(dbin-1)*8+4;(phibin-1)*dpb;(thdbin-1)*dpb;l(ind);b(dbin)]);
