1

initial mask I have the above mask which is roughly the shape of a trapezium and want to convert it to this. This would mean the sides were straightened - especially the front side of the mask. I want to alter this mask to straighten the edges and not just create a mask with a trapezium shape of the same size as I want to repeat this process on other masks without the trapezium shape and vary for other masks with different shapes, most not regular. Is this possible?

Tried dilating and eroding without desired effects, although realised this would likely have little affect after.

1 Answers1

0

For this task, I guess method cv2.findContours() will be helpful. After you get the contours of your mask, you can play around with cv2.approxPolyDP() function to approximate your figure into some polygon. If you want your polygon to be convex, try cv2.convexHull(), also try cv2.boundingRect() or cv2.MinAreaRect(), though they will produce a right rectangle and rotated rectangle respectively.

Either way, try reading this article for more details on how to work with your mask. Though, there might be much more suitable functions in opencv for your current task.

Kad Rys
  • 30
  • 3