Optimize imlib_threshold