0

How can I detect which shapes are tiled in this black and white tileable image, using python opencv?

enter image description here

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 (i.e. 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
Yasin
  • 609
  • 1
  • 10
  • 22
  • 1
    Please consider taking the tour and read the information guides in the **help center** (https://stackoverflow.com/help). Users are much more likely to help if you (1) show some research effort on your own, and (2) learn how to ask questions. Please provide a minimal, complete, and verifiable example to your specific problem. What have you tried so far? Please show some of your attempts/codes. One possibility might be to copy and concatenate the image horizontally so that the center section shows the full tiled regions. Then get the contours or blobs and match shapes perhaps using image moments – fmw42 Oct 20 '19 at 21:55
  • @fmw42 It's a general question about detecting tiled shapes in an image. I don't think it's as vague as you said. I've edited the question with more info about things I tried if it helps and what you suggested was one of them. – Yasin Oct 21 '19 at 05:50
  • `@Yasin`. It is not vague, but too broad for this forum. Read the help section regarding posting code that can be used to help answer a specific coding question. – fmw42 Oct 21 '19 at 17:04

1 Answers1

0

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.

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
  • This is a good idea but will only work horizontally or vertically if such a line can be found. If there are more nearby white patches, it wouldn't be possible to find the line. – Yasin Oct 23 '19 at 07:53