本文介绍了在4通道图像中为对象添加填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的4通道图像(.png,.tif):

I have a 4-channel image (.png, .tif) like this one:

我正在使用OpenCV,我想在花的周围添加 BORDER_REFLECT 类型的填充。 copyMakeBorder 没用,因为它会在图像的边缘添加填充。

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

我可以添加某些填充我将图像拆分为bgr + alpha并在bgr图像上应用 dilate BORDER_REFLECT 选项,但该解决方案会破坏所有花的像素。

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

有没有办法在由定义的ROI上执行选择性 BORDER_REFLECT 填充添加二元面具?

Is there any way to perform a selective BORDER_REFLECT padding addition on a ROI defined by a binary mask?

编辑:

我期望的结果是(对不起我用GIMP快速绘制):

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

我画了两条黑线来划定旧的&填充后花的新轮廓,但当然这些线不应出现在最终结果中。填充区域(在两条黑线内)必须由来自花的镜像像素组成(我将其涂成黄色以使其可理解)。

I painted two black lines to delimit the old & 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).

推荐答案

此问题已在此处解决并解决:

The issue has been already addressed and solved here:

这篇关于在4通道图像中为对象添加填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:16
查看更多