finished demosaic function