function ConvertToContinuity_2(oldfn,newfn)
%function ConvertToContinuity_2(oldfn,newfn)
%
% reads the data as 81x81 columns in one matrix 
% returns a new matrix in Cont format
% only retain levels 4 5 and 6

load(oldfn,'X');%-->X

options.OrigSize = [81 81];
LineFeature = MaxHoughOnEach(X,options);
clear X;
X = LineFeature;
save(newfn,'X');

function LineFeature = MaxHoughOnEach(X,options);
%an image representation which makes explicit the line segments

d.OrigSize = [128 128];
d.DecimateSpan = 15;
options = ResolveMissingOptions(options,d);
c = floor(options.DecimateSpan/2);
for imgIdx = 1:size(X,2)
  fprintf('%d of %d \r',imgIdx, size(X,2));
  img = reshape(X(:,imgIdx),options.OrigSize);
  h = hough(img);
  h = maxfilter(h,options.DecimateSpan);
  lf = h(c:options.DecimateSpan:end,c:options.DecimateSpan:end);
  lf = lf(:);
  if(imgIdx == 1)
    LineFeature = zeros(length(lf),size(X,2));
  end
  LineFeature(:,imgIdx) = lf;
end
