I'm trying to crop an image like this:

according to the blue border within the image, so that it has output similar to this:

so that the cropped image consists of the entire image within the borders. I have looked at similar posts and have thought about using cv2.findContours, but struggling with how I can process the image before passing it to the findContours function. Don't know if a threshold should be applied? Any help would be much appreciated.


