By assigning different quality to ROI (Region of Interest) and ROB (Region of Background), the ROI based image compression can provide higher quality for important regions with higher compression rate on entire image. However, the quality relation between ROI and ROB is usually defined empirically and hardly to be adaptive to all images. Great diversity among background regions is easy to cause unstable quality of the compressed images. This paper proposed a bit allocation optimization method for ROI based image compression. Using image redundancy analysis, the relationship of ROI and ROB in bit allocation is determined. Then, bit rates of ROI and ROB are adjusted adaptively. An application dependent learning based optimization model is trained to support the adjustment. As a result, the stable reconstructed image quality is obtained for different images. The experiment shows that it decreases average standard deviation of reconstructed image quality.