Add padding to object in 4-channel image
<p>I have a 4-channel image (.png, .tif) like this one:</p>

<p><a href="https://i.stack.imgur.com/b6DGL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b6DGL.png" alt="enter image description here"></a></p>

<p>I am using OpenCV, and I would like to add padding of type <code>BORDER_REFLECT</code> around the flower. <code>copyMakeBorder</code> is not useful, since it adds padding to the edges of the image.</p>

<p>I can add certain padding if I split the image in bgr + alpha and apply <code>dilate</code> with <code>BORDER_REFLECT</code> option on the bgr image, but that solution spoils all the pixels of the flower.</p>

<p>Is there any way to perform a selective <code>BORDER_REFLECT</code> padding addition on a ROI defined by a binary mask?</p>

<p><strong><em>EDIT:</em></strong></p>

<p>The result I expect is something like (sorry I painted it very quickly with GIMP) :</p>

<p><a href="https://i.stack.imgur.com/yIXXK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yIXXK.png" alt="enter image description here"></a></p>

<p>I painted two black lines to delimit the old &amp; new contour of the flower after the padding, but of course those lines should not appear in the final result. The padding region (inside the two black lines) must be composed by mirrored pixels from the flower (I painted it yellow to make it understandable).</p>