1
$\begingroup$

Given a hand-drawn shape, I'd like to generate the corresponding symmetrical polished shapes such as circle, rectangle, triangle, trapezoid, square, parallelogram, etc.

A short video demonstration

Here below we can see a parallelogram, trapezoid, triangle and a circle. I was wondering how can I transform it into symmetrical polished shapes?

enter image description here

At first, I tried a simple approach with traditional computer vision algorithms, with OpenCV (no neural networks were involved), by counting the number of corners, but it failed miserably, since there are many edge cases within a user's doodler.

So, I was thinking to delve into CNN specifically U-Net for segmentation.

Can somebody please give me some suggestions on how to approach this kind of problem? I'd like to read some relevant articles and code about this subject for getting a better grasp of this kind of problem.

$\endgroup$
2
  • $\begingroup$ Depending on how you want to do this problem it could be really easy. Do you just want the ability to have simple shapes drawn? Because if you only care about a small sample of shapes, you can make a super simple classifier network that would have no trouble getting very high accuracy, then if it detects a square, just return an image of a square. But again, this depends on the complexity of the task. Will there be multiple shapes? Does the output need to resemble the dimensions of the input? $\endgroup$ – Recessive Jul 9 '20 at 5:42
  • $\begingroup$ @Recessive thank you for your questions, yes I would like to generate those polished shapes, But the actual position is important for me, and moreover the shapes can reside inside other shapes, therefore it's not only a classification problem. I have updated the question with more details. and have uploaded an image. $\endgroup$ – JammingThebBits Jul 9 '20 at 6:55
0
$\begingroup$

From how it looks, the most reliable method to try out is using Hough transform.

The Hough transform can be used to detect e.g. lines and circles in images (depending on which variant you are using; in this case it would amount to a combination of variants for both lines and circles obviously).

So, given some input image, the Hough transform tells you what the line/circle parameters are that have created a line in the input image. For example, given a line, it would tell you the intersection with the $y$-axis and the $slope$ of the line detected in the image. Then, you could use these parameter information to reconstruct lines and circles detected in the image.

The last remaining problem to be solved then is to check where a detected line starts and stops (since this is not obvious from line parameters like $m$ (=$slope$) and $b$ (=intersection with $y$-axis) in the equation $y = mx+b$ describing some line).

But for that, you could "walk" along a line in the image space and check where the line is present or not. Then, you can draw line segments in the reconstruction image when the corresponding elements are also present in the original image.

The problem with (C)NNs would be that they are sensitive to rotation and scale etc. You could of course take a tremendously large number of filters to account for shapes of different rotation and scale, but that would increase the demand for labeled training data again (which could of course be automatically be generated a priori in this simple case).

Anyway, I'd suggest checking out Hough transform. To get some feeling for it, there are lots of libraries available implementing it for Python or MatLab, for example.

For further information, check out Wikipedia or YouTube.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.