MATLAB: Automatically crop the border of an image

automatic cropbordercrop imageimage processingImage Processing Toolbox

Hi, how can I crop the image to its border. What I want is to upload an image and crop the borderline. I need a code to work for different sizes of images and also for different drawings.
Related Question