Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: Searching for pixels along single-pixel branches

Tags:

opencv

I'm currently trying to find a neat way of storing separate "branches" in a binary image. This little animation explains it:

searching for branches

As I go along the branches I need to collect the pixel indices that makes up a single-pixel wide branch. When I hit a junction point it should split up and store the new branches.

One way of going about it is maybe to create a 3x3 subregion, find out if there are white pixels inside it, move it accordingly, create a junction point if there is more than two. Always store the previous subregion so one can use it for making sure that we don't move to regions we already scanned. It's a bit tricky to figure out how I would go about it though.

I basically need to reorder the pixels based on a "line/curve" hierarchy. Another part of the application will then redraw the figures, which internally works by creating lines between points hence the need to have them "ordered".

like image 223
prayforbacon Avatar asked Nov 13 '22 01:11

prayforbacon


1 Answers

I don't know if you could apply it in your case but you should take a look at cv::findContour. you will get a vector of points ordered.

http://docs.opencv.org/doc/tutorials/imgproc/shapedescriptors/find_contours/find_contours.html

like image 200
Poko Avatar answered Nov 15 '22 11:11

Poko