Faster pure-JS color and contour detection