I have a list of connected pixels (tuples of x and y coordinates) forming the outer boundaries of a polygon in an image. How can I pick out its sides suppose they are all straight? What should I do if the lines are not too straight, and contain deviations? Is there anything readily made in Python Image Library or Numpy for such a task? Thanks!
You could use OpenCVs approxPolyDP
You can reduce the number of vertices using that function.
The functions approxPolyDP approximate a curve or a polygon with another curve/polygon with less vertices so that the distance between them is less or equal to the specified precision. It uses the Douglas-Peucker algorithm http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
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.