简体   繁体   中英

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?

在此处输入图像描述

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. 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).
  4. If they do, they belong to each other

1) Find vertical cut line, which not contains white pixels.

2) Split the image vertically by the cut line.

3) Flip one of the image halves you got.

4) Concatinate images vertically.

5) Find connectes components.

6) Split it again and recombine halves to source image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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