gpt4 book ai didi

image - 连接组件标记算法在某些情况下失败

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:33:24 24 4
gpt4 key购买 nike

我用过这个算法 http://www.codeproject.com/Articles/336915/Connected-Component-Labeling-Algorithm清除图像中的噪声。这是原始噪音 enter image description here

这是我得到的:

enter image description here

最终图像周围仍然存在噪点。有谁知道算法在哪里失败或可以推荐更有效的算法?谢谢

最佳答案

ImageMagick 用最少的努力就做得很好。它无论如何都安装在大多数 Linux 发行版上,并且可用于 OSX 和 Windows。像这样从命令行运行:

convert input.png                                   \
-colorspace gray -negate -threshold 10% \
-define connected-components:verbose=true \
-define connected-components:area-threshold=800 \
-connected-components 8 -auto-level output.png

输出

Objects (id: bounding-box centroid area mean-color):
0: 431x424+0+0 209.2,207.5 135697 srgb(13,13,13)
109: 236x273+120+84 231.7,223.0 47047 srgb(255,255,255)

enter image description here

如果您将阈值更改为仅显示面积大于(比如 50)的 Blob ,您会得到:

Objects (id: bounding-box centroid area mean-color):
0: 431x424+0+0 210.2,208.5 134262 srgb(11,11,11)
109: 236x273+120+84 231.7,223.0 47047 srgb(255,255,255)
1: 40x20+1+1 16.9,9.5 605 srgb(255,255,255)
190: 12x15+309+153 314.2,160.1 126 srgb(253,253,253)
83: 12x13+142+71 148.1,76.7 90 srgb(255,255,255)
164: 12x17+140+132 146.0,140.1 90 srgb(255,255,255)
347: 10x12+50+304 54.5,309.6 85 srgb(255,255,255)
440: 11x11+278+399 282.6,404.2 79 srgb(255,255,255)
448: 6x15+425+403 427.9,409.9 71 srgb(255,255,255)
151: 9x11+145+122 149.2,126.4 68 srgb(255,255,255)
93: 11x9+105+75 110.1,79.6 61 srgb(255,255,255)
170: 9x10+91+136 95.1,140.8 58 srgb(255,255,255)
258: 9x10+107+220 110.8,225.1 52 srgb(255,255,255)
53: 10x8+64+47 68.5,50.2 50 srgb(255,255,255)

enter image description here

或者,如果你想要一些 C 代码,你可以看看我的 answer here对于这个问题:

关于image - 连接组件标记算法在某些情况下失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28738746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com