简体   繁体   中英

OpenCV Best method to automatically draw a straight line through points

what OpenCV Python tool would be the best to draw a straight line between multiple 'points' on an image ? Something like a BestFitLine but for thresoldedimage, not a plot

Thanks

source image在此处输入图片说明

processed image (binary threshold) the black dot are supposed to be each individual crop源图像(二进制阈值

what I'd like to have

在此处输入图片说明

I'm afraid Hough Lines will fail here. You could try ransac to get best estimated line, erase those points and run next ransac . Tough you still can encounter some troubles: exactly how many clusters do you want to recognize? You could set min score sample score for a line model. You'd also need to filter out horizontal lines.

There're ransac implementations in both scikit-learn and scikit-image .

如果您还没有尝试过,请使用 OpenCV 函数HoughLines()HoughLinesP()来检测图像中的线条。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM