Optimal image compression via block-based adaptive colour reduction with minimal contour effect