How to crop a circular image to inscribed square, then crop to inscribed circle, and finally crop to inscribed square?
The image you want to crop to is, geometrically, a square centered on the input image, half as large. This is because you're inscribing twice, each time the square shrinks by the square root of two, and dividing by SQRT(2) twice is the same thing as dividing by 2.
So if you have an input square of side D (or a circular image of diameter D), what you need to do is crop with center (D/2, D/2) and a side of D/2.
I would like to crop the circular image attached below according to the following:

crop input circular image to the unique square inscribed in the circle.
crop the square image down to the circle inscribed in the square
crop the circular image from the previous step down to square that inscribes image.

I am using python, opencv, and PIL. I have tried cropping with hard coding coordinates, but this obviously causes problems when applied to other images, so I would like a universal solution.
I have included a rough visualization of how I would like to crop it:
In addition, I have included the original image:
A code snippet with brief explanation would be greatly appreciated.