mergeLayers function

Merge layers in a recolorized image