This is my first post here so I'd like to say hi to everyone. I've been using imagemagick for some time now, however recently I've encountered problem I cannot cope with alone. That's why I've decided to turn to you for help. Consider the image below:

Given the image with black border and circular area of interest (not necessarily white), my objective is to extract the biggest square subimage of the this area as shown by the red square. I will be grateful for your help.
Cheers