1 | initial version |
The easiest approach to test would be a simple erode/dilate. Just draw your green contour as a (white) filled pylygon on a black background and call erode for some iterations. This will shrink your goal rectangle but also remove the additional lines. If you then call dilate for the same number of iterations, the rectangle will be (approximately) the same size as before, but without your additional lines.