Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect simple curves and lines in the grayscale image

I've an image with a bunch of simple grayscale primitive geometry (curves, 'saw'-lines, ellipses, triangles, stars) drawn by lines of width about 8-10 pixels.

How to perform statistical analysis of the image? I need at least following two parameters:

  1. Number of sharp angles
  2. Number of curves.

I've tried doing it myself by extracting contours, shrinking till they have edges connected (i.e. become curves) and analysing them by differential functions, but it takes too much time for big images.

A suppose there is some kind of algorithm of curve/angle/angle sharpness detection?

What i need is either an open-source framework (java/javascript prefferably) to do such stuff or at least name of algorithm to detect curves/'saw' lines.

like image 943
setec Avatar asked Apr 30 '14 08:04

setec


1 Answers

The Hough transform may be helpful to you in identifying curves. If you only need to count, it should work just fine. It can be generalized to detect any geometric shape that can be described using parameters, or any shape whatsoever using template matching. However, that can be expensive.

For sharp corners, you can use Harris corner detection as mentioned by @Diego in the above comment.

Definitely also check out jfeaturelib, it's helpful in extracting features from images (although if you just want to count/detect them it might be a little heavy-duty for your purposes).

Below are some implementations that may help you on your way:

  • Hough transform in java
  • Hough transform in javascript
  • Harris corner detection in java
  • Harris corner detection in javascript

You also might want to check out ImageJ by the NIH, there are quite a few Java plugins that may be helpful to you. It's used by many biologists (like me!) to detect image features and has hundreds of plugins for almost any conceivable purpose.

There are also many helpful questions on SO.

like image 164
Luigi Avatar answered Oct 30 '22 16:10

Luigi