简体   繁体   English

如何检测平铺图像中的平铺形状(opencv)

[英]How to detect tiled shapes in tileable image (opencv)

How can I detect which shapes are tiled in this black and white tileable image, using python opencv?如何使用 python opencv 检测此黑白平铺图像中平铺了哪些形状?

在此处输入图像描述

The leftmost and rightmost white patches are continuation of each other and therefore should get detected.最左边和最右边的白斑是彼此连续的,因此应该被检测到。

I tried to offset/wrap the image horizontally and vertically and recheck the image for connected labels but if the patches are in the corner or very large, it would be quite tricky.我尝试水平和垂直偏移/包裹图像并重新检查图像是否有连接的标签,但如果补丁在角落或非常大,那将非常棘手。 Another option was to transform the image into polar coordinates (ie projecting on 3D sphere) and dealing with degrees instead of pixels, but it felt too complicated to do unless there are easier ways to go about it.另一种选择是将图像转换为极坐标(即投影在 3D 球体上)并处理度数而不是像素,但是除非有更简单的方法来处理 go,否则这样做感觉太复杂了。 A fast method I have in mind to do is我想到的一个快速方法是

  1. Check if the patch is on the borders检查补丁是否在边界上
  2. If yes, look for other labels that are on borders如果是,请查找边框上的其他标签
  3. Check position of both labels if they line up (not sure how to do it yet).检查两个标签的 position 是否对齐(尚不确定如何操作)。
  4. If they do, they belong to each other如果他们这样做,他们属于彼此

1) Find vertical cut line, which not contains white pixels. 1)找到不包含白色像素的垂直切割线。

2) Split the image vertically by the cut line. 2)通过切割线垂直分割图像。

3) Flip one of the image halves you got. 3)翻转你得到的一半图像。

4) Concatinate images vertically. 4)垂直连接图像。

5) Find connectes components. 5)查找连接组件。

6) Split it again and recombine halves to source image. 6)再次拆分并将其重新组合为源图像。

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

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