finished image expansion algorithim