简体   繁体   English

平滑粗糙边缘轮廓opencv

[英]smoothing rough edges contour opencv

I have this image 我有这张图片

在此处输入图片说明

when you zoom it you can see the rough edges like this 缩放时,您会看到这样的粗糙边缘

在此处输入图片说明

I want to smoothen the rough edges such that they form an almost perfect curve/line,some what like this 我想平滑粗糙的边缘,使它们形成几乎完美的曲线/线,像这样 在此处输入图片说明

I tried this method Image edge smoothing But I can't seem to save it as a bmp file. 我尝试了这种方法图像边缘平滑,但是我似乎无法将其另存为bmp文件。 I tried Gaussian blur too but didn't get any much affect. 我也尝试过高斯模糊,但没有太大影响。 The outlines are contours extracted from a binary image. 轮廓是从二进制图像提取的轮廓。 Increasing the thickness of the contours removes the rough edges to a point but it changes the clear definition of the boundaries. 增加轮廓的厚度可以将粗糙边缘消除到一个点,但会更改边界的清晰定义。

EDIT:-How about filled binary images? 编辑:-如何填充二进制图像?

This 这个

在此处输入图片说明

to

在此处输入图片说明

Dilating would change the boundary too much. 扩张会大大改变边界。

What you are looking for is not possible in the manner you are thinking of. 您正在寻找的东西不可能以您所想的方式实现。 As @Miki stated, Digital images have an upper limit of resolution that you can not go further than it. 正如@Miki所说,数字图像具有分辨率的上限,您无法超越它。

The solution is to represent your curves as vectorized curves. 解决方案是将曲线表示为矢量化曲线。 Then you can render at any resolution you want. 然后,您可以以任何所需的分辨率进行渲染。 One possible solution is to use Bezier Curves to represent the contours (or Spline ). 一种可能的解决方案是使用贝塞尔曲线表示轮廓(或样条线)。 Then you may simply draw them with any resize fraction you want. 然后,您可以简单地用所需的任何大小调整比例绘制它们。

Here you can find some resources: 在这里您可以找到一些资源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM