Android:平滑随机形状位图的边缘 [英] android: smooth out edges of random shape bitmap
问题描述
我有一个用户切割出的随机形状位图.我想淡化边框,即轮廓,以使其显得平滑.我该怎么办?为了获得位图中每个像素的边界和颜色,我逐像素遍历它.这需要很长时间,但我还是可以的. openCV是我唯一的选择吗?如果是,有人可以指出我关于逻辑方法的任何教程或建议吗?
I have an random shape bitmap cut out by user. I want to fade out its borders i.e. contours, so as to make it appear smooth. What should I do? To get the borders and color of every pixel in bitmap, I am traversing it pixel by pixel. It takes long time, still I am ok with it. Is openCV my only option? If yes, can anybody point me towards any tutorial or suggestion for logical approach?
推荐答案
您可以仅对形状运行平滑过滤器.
You can just run a smoothing filter on your shape.
在opencv中,您可以使用模糊功能或gaussainBlur.查看 http://docs.opencv.org/2.4/doc /tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html .
In opencv you can use the blur fnnction or gaussainBlur. Look at http://docs.opencv.org/2.4/doc/tutorials/imgproc/gausian_median_blur_bilateral_filter/gausian_median_blur_bilateral_filter.html.
您不必使用opencv,但我认为它将更轻松,更快捷.
You don't have to use opencv but i think it would be easier and faster.
如果您仍然不愿意,可以使用任何其他实现图像平滑的代码.
If you still don't want can use any other code that implement smoothing an image.
如果只想影响边框像素,请执行以下操作:
In case you just want to effect the border pixels do the following:
- 复制原始图像
- 过滤整个图像.
- 使用opencv findContours提取边界像素.
- 仅从模糊图像中复制边界及其附近的像素,然后将其复制到您在步骤1中所做的复制.
这篇关于Android:平滑随机形状位图的边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!