Using gradients in masks to blend images