unshred icon indicating copy to clipboard operation
unshred copied to clipboard

Better background isolation.

Open dchaplinsky opened this issue 11 years ago • 4 comments

At the moment we are using rather simple technique to find shreds on a coloured background, which is coded here: https://github.com/dchaplinsky/unshred/blob/master/unshred/sheet.py#L165

It seems to be well commented, but if you need any info — feel free to contact me for clarifications.

This technique has pros:

  • Simple
  • Very quick
  • Produces good enough result. and cons:
  • It requires some manual work to make it work with new background colour (when you need to find diapason of HSV colours that will be threaten as a background). So it's not very robust (however, we have relatively small amount of different backgrounds, say, dozen or so).
  • in some cases it has problems when shred is not glued properly and has shadow or two shreds are glued too close to each other. I'll append some examples below.

I've tried different techniques, including:

  • Flood fill with different settings (however I did that in RGB space, so probably Lab or HSV will have better results). Results were unstable and slow.
  • Grabcut using diapason technique above as a seed. I've also tried to apply different kinds of erode/dilate/smooth stuff to seed mask. Results were unstable and VERY slow.

Probably we can benefit from some kind of adaptive thresholding from here

dchaplinsky avatar Sep 30 '14 22:09 dchaplinsky

99 126 172 173

dchaplinsky avatar Sep 30 '14 22:09 dchaplinsky

Here is grabcut solution.

dchaplinsky avatar Sep 30 '14 22:09 dchaplinsky

If that will help: there are fairly easy way to determine overlapping shreds like in example above: https://github.com/dchaplinsky/unshred/blob/master/unshred/features/geometry.py#L21

In general I think we might benefit from some heuristics based on geometry. Say, for example, if our shred is likely to be not isolated properly we might apply more aggressive algorithm on it.

dchaplinsky avatar Sep 30 '14 23:09 dchaplinsky

Can we use this to help separating shreds that are glued together? http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_watershed/py_watershed.html#watershed

dchaplinsky avatar Oct 09 '14 21:10 dchaplinsky