a = 1.4; b = 0.3;
f = @(x) [a-x(1,:).^2+b*x(2,:);  x(1,:)]; % Henon map (vec func) w/ params a,b

N = 1000000;                                  % how many its
x = zeros(2, N+1);
x(:,1) = [0;0];
for n=1:N
  x(:,n+1) = f(x(:,n));
end
%plot(x(1,ns), x(2,ns), '.', 'markersize', 1);
%axis equal; axis([-2 2 -2 2]);

addpath boxcount

% provide x a 2-by-N array of points on the henon attractor

% convert the list of 2D points x to a binary image array im
s = 4096;                    % choose size of image (don't exceed memory!)
im = zeros(s,s);
a = min(x(1,:)); b = max(x(1,:)); c = min(x(2,:)); d = max(x(2,:));
wid = max(b-a, d-c);
l = sub2ind(size(im), 1+floor((s-1)*(x(1,:)-a)/wid), 1+floor((s-1)*(x(2,:)-c)/wid));
im(l) = 1;
figure; imagesc(im'); set(gca, 'ydir', 'normal'); colormap(1-gray); % check im

figure; boxcount(im, 'slope');




