input is flatten rgb image, not raw image