fixed: wrong max j, and inaccurate pixel value