图像处理

时间:2015-03-07 05:33:22

标签: c++ opencv image-processing transformation

我有几个位图图像,想要分割和访问连续色调非常高相关区域的位置(并且想知道大小),我的意思是连续色调区域(高相关区段)只有持有的区域完全相同的像素值。我有图像处理的经验,我使用的是c ++和opencv,但我没有找到一个库,我担心如果我进行编程我将失去性能,计算效率低下,而我需要进一步处理很多事情。在这个时候,但是由于这个科学离开的10年,我变得笨拙,我不能在我年轻的时候找到答案,如果你帮我解决这个问题,我将不胜感激因为我被困住了。感谢您的亲切阅读和帮助。

1 个答案:

答案 0 :(得分:1)

我可以使用ImageMagick来演示我的评论的概念,这个测试图像具有噪音的有用属性,这意味着你可以在SO的白色背景上看到它并且算法不应该看到它。

enter image description here

我可以像这样在15x15的平均面积上进行平均:

convert test.png -statistic mean 15x15 x.png

给出了这个

enter image description here

然后将阈值反转,以便您可以看到以白色标识的连续色调区域

convert test.png -statistic mean 15x15 test.png -compose difference -composite -depth 8 -threshold 1 -negate x.png

enter image description here

您可以尝试不同的模糊框宽度和高度,如下所示:

#!/bin/bash
for x in 3 7 15 25; do
   for y in 3 7 15 25; do
     convert -label "${x}x${y}" test.png -statistic mean ${x}x${y} miff:-
   done
done | montage - -frame 5 -tile 4x out.png

给出了这个:

enter image description here

和相应的蒙版图像因此:

enter image description here

您可以将其传递到Connected Components Analysis中,如下所示:

convert test.png -statistic mean 5x5                   \
        test.png -compose difference -composite        \
        -depth 8 -threshold 1 -negate                  \
        -define connected-components:verbose=true      \
        -define connected-components:area-threshold=20 \
        -connected-components 8 -auto-level blobs.png

将为您提供包含blob坐标

的内容
Objects (id: bounding-box centroid area mean-color):
  0: 500x500+0+0 270.8,271.7 177169 srgb(0,0,0)
  1: 216x216+52+41 159.5,148.5 46656 srgb(255,255,255)
  8: 114x114+63+351 119.5,407.5 10039 srgb(255,255,255)
  2: 81x100+354+47 394.0,96.5 8100 srgb(255,255,255)
  5: 49x49+348+204 372.0,228.0 2401 srgb(255,255,255)
  6: 358x5+55+287 233.5,289.0 1790 srgb(255,255,255)
  10: 45x45+244+383 265.9,405.0 1520 srgb(255,255,255)
  3: 4x289+451+181 452.5,325.0 1156 srgb(255,255,255)
  7: 122x4+57+309 117.5,310.5 488 srgb(255,255,255)
  9: 4x114+416+356 417.5,412.5 456 srgb(255,255,255)
  4: 15x15+312+185 319.0,192.0 225 srgb(255,255,255)

然后,我可以在原始图像的顶部勾勒出检测到的区域:

enter image description here