RECODE and OPTIMIZE image functions