Improve cost weighting and fixed the image_offset position.