Completed gamma correction function