partition_image(atx+size, aty, hsize-size,vsize, tol);
will produce ranges of hsize 1 and break the algorithm which assumes that depth <= max_part, or equivalently that a range is never smaller than size>>max_part. The algorithm assumes that both horizontal and vertical sizes have at least max_exponent-max_part zeroes in the least significant bits of their binary form.
x_exponent = (int)floor(log((double)hsize)/log(2.0));
is unstable if hsize is a power of two. for hsize = 64, here are some results on a 486:
You can fix the problem by using hsize+0.1 instead of hsize. Similarly, you can subtract 0.1 in:
bits_needed[i] = ceil(log((double)domain.no_h_domains[i]* (double)domain.no_v_domains[i])/log(2.0));
Yuval Fisher (yfisher@ucsd.edu)