Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To get a better response you need to better limit the scope of your application. Here is something that might help you. I suppose your "crappy drawing" input is always similar to the one you provided in the sense that it has strong edges, and the color present on it is irrelevant. To solve (or, better, to get closer to a solution for) your problem in a simple way, you need to describe both images in terms of scale invariant descriptors.</p> <p>My take on it: binarize both images, count number of connected components (CCs) inside both, discard CCs of irrelevant size (too far from the median, mean, related to stddev, etc, you decide). You will possibly want to supplement the second step, to better discriminate your image from other inputs, i.e., the more powerful you want your approach to be, the more discriminant descriptors you will need. At some point you might also want to consider using SVM, or other machine learning techniques.</p> <p>So, the binarize step: perform a morphological gradient and discard weak gradient. This is very easy if the inputs are similar to what was posted. Here is what I get with a threshold at intensity 60 (I'm also assuming your input is in the range [0, 255]):</p> <p><img src="https://i.stack.imgur.com/mzJmFm.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/hWSXKm.png" alt="enter image description here"></p> <p>I quickly experimented with thresholds ranging till 90, and all them worked for these images. Cropping these is easy, and you can also flood fill the background and the object:</p> <p><img src="https://i.stack.imgur.com/ZbFUDm.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/i5FCym.png" alt="enter image description here"></p> <p>Now you can extract the connected components in white and do the analysis on them. In this case, the simplest thing to do is to count them. For these inputs, we get 12 in the "perfect" image and 14 in the "bad" one. But, in the "bad" one, we have 2 components of size 1 (there is only one pixel in each one of them), which are trivially eliminated. There are many other ways to compare the connected components, but I hope this can get you started. If you need the code for these tasks I can include it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload