2

I have a black and white picture of curves and I want to extract minimum dots representing each curve. dots are connected by straight lines. this is an example of what I want:

enter image description here enter image description here

It is useful If I could know the precedence of dots especially in tied sections. I'm using c++ and opencv. What algorithms I should use for this problem?

ahamid555
  • 333
  • 4
  • 16

2 Answers2

2

OpenCV provides nice and simple function for this cv::approxPolyDP.

void approxPolyDP(InputArray curve, OutputArray approxCurve, double epsilon, bool closed)

A simple example:

std::vector<cv::Point> curve;
//fill curve
std::vector<cv::Point> approximated_polyline;
cv::approxPolyDP(Mat(curve), approximated_polyline, 3, false);
Humam Helfawi
  • 19,566
  • 15
  • 85
  • 160
  • but I don't have curve points. I used this method with my picture and it gave me exception at memory location. – ahamid555 Feb 22 '17 at 09:44
  • if you suggest an algorithm for that I would appreciate it. because I need some modification on it I need it to write myself. – ahamid555 Feb 22 '17 at 10:04
  • You apply contouring to get the points curve. but self intersection contours would be a problem for you. – Humam Helfawi Feb 22 '17 at 10:39
0

Key point detection algorithms should be of help. This page provides a brief history and opens up a wide array of literature to read and experiment. It might also be worthwhile to refer this survey on local invariant feature detectors.

dangiankit
  • 119
  • 4