How to extract a rectangle in an image from identified lines I have thousands of images that look like this: